bump 1.0
Showing
6 changed files
with
11 additions
and
170 deletions
1 | CasperJS Changelog | 1 | CasperJS Changelog |
2 | ================== | 2 | ================== |
3 | 3 | ||
4 | XXXX-XX-XX, v1.0.0 | 4 | 2012-12-24, v1.0.0 |
5 | ------------------ | 5 | ------------------ |
6 | 6 | ||
7 | ### Important Changes & Caveats | 7 | ### Important Changes & Caveats |
8 | 8 | ||
9 | - PhantomJS 1.6.x support has been dropped. Both PhantomJS 1.7 & 1.8 will be supported. | 9 | - PhantomJS 1.6.x support has been dropped. Both PhantomJS [1.7](http://phantomjs.org/release-1.7.html) & [1.8](http://phantomjs.org/release-1.8.html) will be supported. |
10 | - the deprecated `injector` module has been removed from the codebase (RIP dude) | ||
11 | - a [`1.0` maintenance branch](https://github.com/n1k0/casperjs/tree/1.0) has been created | ||
12 | - CasperJS 1.1 development is now taking place on the `master` branch | ||
10 | 13 | ||
11 | ### Bugfixes & enhancements | 14 | ### Bugfixes & enhancements |
12 | 15 | ... | ... |
modules/injector.js
deleted
100644 → 0
1 | /*! | ||
2 | * Casper is a navigation utility for PhantomJS. | ||
3 | * | ||
4 | * Documentation: http://casperjs.org/ | ||
5 | * Repository: http://github.com/n1k0/casperjs | ||
6 | * | ||
7 | * Copyright (c) 2011-2012 Nicolas Perriault | ||
8 | * | ||
9 | * Part of source code is Copyright Joyent, Inc. and other Node contributors. | ||
10 | * | ||
11 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
12 | * copy of this software and associated documentation files (the "Software"), | ||
13 | * to deal in the Software without restriction, including without limitation | ||
14 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
15 | * and/or sell copies of the Software, and to permit persons to whom the | ||
16 | * Software is furnished to do so, subject to the following conditions: | ||
17 | * | ||
18 | * The above copyright notice and this permission notice shall be included | ||
19 | * in all copies or substantial portions of the Software. | ||
20 | * | ||
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
22 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
24 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
26 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
27 | * DEALINGS IN THE SOFTWARE. | ||
28 | * | ||
29 | */ | ||
30 | |||
31 | /*global CasperError console encodeURIComponent escape exports require*/ | ||
32 | |||
33 | // WARNING: this module is deprecated since CasperJS 1.0.0-RC3 | ||
34 | |||
35 | var utils = require('utils'); | ||
36 | |||
37 | exports.create = function create(fn) { | ||
38 | "use strict"; | ||
39 | return new FunctionArgsInjector(fn); | ||
40 | }; | ||
41 | |||
42 | /** | ||
43 | * Function argument injector. | ||
44 | * | ||
45 | * FIXME: use new Function() instead of eval() | ||
46 | */ | ||
47 | var FunctionArgsInjector = function FunctionArgsInjector(fn) { | ||
48 | "use strict"; | ||
49 | console.error('Warning: the injector module has been deprecated.'); | ||
50 | |||
51 | if (!utils.isFunction(fn)) { | ||
52 | throw new CasperError("FunctionArgsInjector() can only process functions"); | ||
53 | } | ||
54 | this.fn = fn; | ||
55 | |||
56 | this.extract = function extract(fn) { | ||
57 | var match = /^function\s?(\w+)?\s?\((.*)\)\s?\{([\s\S]*)\}/i.exec(fn.toString().trim()); | ||
58 | if (match && match.length > 1) { | ||
59 | var args = match[2].split(',').map(function _map(arg) { | ||
60 | return arg.replace(new RegExp(/\/\*+.*\*\//ig), "").trim(); | ||
61 | }).filter(function _filter(arg) { | ||
62 | return arg; | ||
63 | }) || []; | ||
64 | return { | ||
65 | name: match[1] ? match[1].trim() : null, | ||
66 | args: args, | ||
67 | body: match[3] ? match[3].trim() : '' | ||
68 | }; | ||
69 | } | ||
70 | }; | ||
71 | |||
72 | this.process = function process(values) { | ||
73 | var fnObj = this.extract(this.fn); | ||
74 | if (!utils.isObject(fnObj)) { | ||
75 | throw new CasperError("Unable to process function " + this.fn.toString()); | ||
76 | } | ||
77 | var inject = this.getArgsInjectionString(fnObj.args, values); | ||
78 | var newFn = new Function([inject, fnObj.body].join('\n')); | ||
79 | newFn.name = fnObj.name || ''; | ||
80 | return newFn; | ||
81 | }; | ||
82 | |||
83 | this.getArgsInjectionString = function getArgsInjectionString(args, values) { | ||
84 | values = typeof values === "object" ? values : {}; | ||
85 | var jsonValues = escape(encodeURIComponent(JSON.stringify(values))); | ||
86 | var inject = [ | ||
87 | 'var __casper_params__ = JSON.parse(decodeURIComponent(unescape(\'' + jsonValues + '\')));' | ||
88 | ]; | ||
89 | args.forEach(function _forEach(arg) { | ||
90 | if (arg in values) { | ||
91 | inject.push('var ' + arg + '=__casper_params__["' + arg + '"];'); | ||
92 | } | ||
93 | }); | ||
94 | return inject.join('\n') + '\n'; | ||
95 | }; | ||
96 | }; | ||
97 | exports.FunctionArgsInjector = FunctionArgsInjector; |
1 | { | 1 | { |
2 | "name": "casperjs", | 2 | "name": "casperjs", |
3 | "description": "Navigation scripting & testing utility for PhantomJS", | 3 | "description": "Navigation scripting & testing utility for PhantomJS", |
4 | "version": "1.0.0-RC6", | 4 | "version": "1.0.0", |
5 | "keywords": [ | 5 | "keywords": [ |
6 | "phantomjs", | 6 | "phantomjs", |
7 | "javascript" | 7 | "javascript" | ... | ... |
1 | %define name casperjs | 1 | %define name casperjs |
2 | %define version 1.0.0 | 2 | %define version 1.0.0 |
3 | %define release RC4_1 | 3 | %define release 1_1 |
4 | %define prefix /usr | 4 | %define prefix /usr |
5 | 5 | ||
6 | %define mybuilddir %{_builddir}/%{name}-%{version}-root | 6 | %define mybuilddir %{_builddir}/%{name}-%{version}-root |
... | @@ -67,7 +67,6 @@ cp -R tests/* %{mybuilddir}%{prefix}/share/%{name}/tests/ | ... | @@ -67,7 +67,6 @@ cp -R tests/* %{mybuilddir}%{prefix}/share/%{name}/tests/ |
67 | %{prefix}/share/%{name}/modules/colorizer.js | 67 | %{prefix}/share/%{name}/modules/colorizer.js |
68 | %{prefix}/share/%{name}/modules/events.js | 68 | %{prefix}/share/%{name}/modules/events.js |
69 | %{prefix}/share/%{name}/modules/http.js | 69 | %{prefix}/share/%{name}/modules/http.js |
70 | %{prefix}/share/%{name}/modules/injector.js | ||
71 | %{prefix}/share/%{name}/modules/mouse.js | 70 | %{prefix}/share/%{name}/modules/mouse.js |
72 | %{prefix}/share/%{name}/modules/querystring.js | 71 | %{prefix}/share/%{name}/modules/querystring.js |
73 | %{prefix}/share/%{name}/modules/tester.js | 72 | %{prefix}/share/%{name}/modules/tester.js |
... | @@ -186,7 +185,6 @@ cp -R tests/* %{mybuilddir}%{prefix}/share/%{name}/tests/ | ... | @@ -186,7 +185,6 @@ cp -R tests/* %{mybuilddir}%{prefix}/share/%{name}/tests/ |
186 | %{prefix}/share/%{name}/tests/suites/fs.js | 185 | %{prefix}/share/%{name}/tests/suites/fs.js |
187 | %{prefix}/share/%{name}/tests/suites/.casper | 186 | %{prefix}/share/%{name}/tests/suites/.casper |
188 | %{prefix}/share/%{name}/tests/suites/tester.js | 187 | %{prefix}/share/%{name}/tests/suites/tester.js |
189 | %{prefix}/share/%{name}/tests/suites/injector.js | ||
190 | %{prefix}/share/%{name}/tests/suites/clientutils.js | 188 | %{prefix}/share/%{name}/tests/suites/clientutils.js |
191 | %{prefix}/share/%{name}/tests/suites/http_status.js | 189 | %{prefix}/share/%{name}/tests/suites/http_status.js |
192 | %{prefix}/share/%{name}/tests/suites/xunit.js | 190 | %{prefix}/share/%{name}/tests/suites/xunit.js |
... | @@ -195,6 +193,9 @@ cp -R tests/* %{mybuilddir}%{prefix}/share/%{name}/tests/ | ... | @@ -195,6 +193,9 @@ cp -R tests/* %{mybuilddir}%{prefix}/share/%{name}/tests/ |
195 | %{prefix}/share/%{name}/tests/run.js | 193 | %{prefix}/share/%{name}/tests/run.js |
196 | 194 | ||
197 | %changelog | 195 | %changelog |
196 | * Mon Dec 24 2012 Nicolas Perriault <nicolas@perriault.net> | ||
197 | - removed 'injector.js' module | ||
198 | |||
198 | * Mon Dec 10 2012 Jan Schaumann <jschauma@etsy.com> | 199 | * Mon Dec 10 2012 Jan Schaumann <jschauma@etsy.com> |
199 | - include 'tests' | 200 | - include 'tests' |
200 | 201 | ... | ... |
tests/suites/injector.js
deleted
100644 → 0
1 | /*global casper*/ | ||
2 | /*jshint strict:false*/ | ||
3 | var t = casper.test; | ||
4 | var createInjector = function(fn, values) { | ||
5 | return require('injector').create(fn, values); | ||
6 | }; | ||
7 | var testFn = function(a, b) { return a + b; }; | ||
8 | var injector = createInjector(testFn); | ||
9 | var extract = injector.extract(testFn); | ||
10 | |||
11 | t.comment('FunctionArgsInjector.extract()'); | ||
12 | t.assertType(extract, "object", 'FunctionArgsInjector.extract() returns an object'); | ||
13 | t.assertEquals(extract.name, null, 'FunctionArgsInjector.extract() process function name as expected'); | ||
14 | t.assertEquals(extract.body, 'return a + b;', 'FunctionArgsInjector.extract() process function body as expected'); | ||
15 | t.assertEquals(extract.args, ['a', 'b'], 'FunctionArgsInjector.extract() process function args as expected'); | ||
16 | |||
17 | function Plop(foo, bar) { | ||
18 | return 'foo: ' + foo +', bar: ' + bar; | ||
19 | } | ||
20 | function Plip() { return 'plop'; } | ||
21 | function foo_bar(boz) {} | ||
22 | var gni = function ($bubu_bibi, __popo__) {}; | ||
23 | var gno = function ( arg1, /*plop*/ arg2 ) { }; | ||
24 | function issue129(term) { | ||
25 | // see issue #129 | ||
26 | return term; | ||
27 | // see issue #129 | ||
28 | } | ||
29 | t.assertEquals(injector.extract(Plop), { | ||
30 | name: 'Plop', | ||
31 | args: ['foo', 'bar'], | ||
32 | body: "return 'foo: ' + foo +', bar: ' + bar;" | ||
33 | }, 'FunctionArgsInjector.extract() handles named functions with arguments and body'); | ||
34 | t.assertEquals(injector.extract(Plip), { | ||
35 | name: 'Plip', | ||
36 | args: [], | ||
37 | body: "return 'plop';" | ||
38 | }, 'FunctionArgsInjector.extract() handles functions with no arguments'); | ||
39 | t.assertEquals(injector.extract(foo_bar), { | ||
40 | name: 'foo_bar', | ||
41 | args: ['boz'], | ||
42 | body: "" | ||
43 | }, 'FunctionArgsInjector.extract() handles functions with no body'); | ||
44 | t.assertEquals(injector.extract(gni), { | ||
45 | name: null, | ||
46 | args: ['$bubu_bibi', '__popo__'], | ||
47 | body: "" | ||
48 | }, 'FunctionArgsInjector.extract() handles anonymous functions with complex args passed'); | ||
49 | t.assertEquals(injector.extract(gno), { | ||
50 | name: null, | ||
51 | args: ['arg1', 'arg2'], | ||
52 | body: "" | ||
53 | }, 'FunctionArgsInjector.extract() handles can filter comments in function args'); | ||
54 | |||
55 | t.comment('FunctionArgsInjector.process()'); | ||
56 | var processed; | ||
57 | eval('processed = ' + injector.process({ a: 1, b: 2 })); | ||
58 | |||
59 | t.assertType(processed, "function", 'FunctionArgsInjector.process() processed a function'); | ||
60 | t.assertEquals(processed(), 3, 'FunctionArgsInjector.process() processed the function correctly'); | ||
61 | |||
62 | // Issue #129 | ||
63 | var fnIssue129 = createInjector(issue129).process({term: 'fixed'}); | ||
64 | t.assertEquals(fnIssue129('fixed'), 'fixed', 'FunctionArgsInjector.process() has issue #129 fixed'); | ||
65 | |||
66 | t.done(12); |
-
Please register or sign in to post a comment