casperjs 1.0.0.RC1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +289 -1
- data/CONTRIBUTING.md +93 -0
- data/CONTRIBUTORS.md +53 -0
- data/README.md +29 -1
- data/batchbin/casperjs.bat +5 -0
- data/bin/bootstrap.js +164 -114
- data/bin/casperjs +84 -0
- data/bin/usage.txt +2 -1
- data/casperjs.gemspec +7 -4
- data/modules/casper.js +661 -239
- data/modules/clientutils.js +240 -54
- data/modules/colorizer.js +2 -1
- data/modules/events.js +13 -1
- data/modules/http.js +70 -0
- data/modules/mouse.js +1 -2
- data/modules/pagestack.js +166 -0
- data/modules/tester.js +1013 -659
- data/modules/utils.js +519 -367
- data/modules/vendors/coffee-script.js +2 -2
- data/modules/xunit.js +56 -24
- data/package.json +2 -2
- data/rpm/casperjs.spec +203 -0
- data/rpm/mkrpm.sh +25 -0
- data/rubybin/casperjs +9 -4
- data/samples/bbcshots.coffee +11 -10
- data/samples/bbcshots.js +16 -15
- data/samples/cliplay.js +3 -0
- data/samples/customevents.js +3 -0
- data/samples/customlogging.coffee +17 -19
- data/samples/customlogging.js +26 -27
- data/samples/download.js +4 -1
- data/samples/dynamic.js +3 -0
- data/samples/each.js +3 -0
- data/samples/events.js +4 -2
- data/samples/extends.js +4 -1
- data/samples/googlelinks.coffee +4 -1
- data/samples/googlelinks.js +10 -3
- data/samples/googlematch.coffee +1 -1
- data/samples/googlematch.js +5 -2
- data/samples/googlepagination.js +4 -1
- data/samples/googletesting.js +3 -0
- data/samples/logcolor.js +3 -0
- data/samples/metaextract.js +3 -0
- data/samples/multirun.js +3 -0
- data/samples/screenshot.js +4 -1
- data/samples/statushandlers.js +4 -1
- data/samples/steptimeout.js +3 -0
- data/samples/timeout.js +4 -1
- data/samples/translate.coffee +23 -0
- data/samples/translate.js +30 -0
- data/tests/commands/mytest.js +14 -0
- data/tests/commands/script.js +3 -0
- data/tests/run.js +82 -37
- data/tests/sample_modules/config.json +1 -0
- data/tests/sample_modules/csmodule.coffee +1 -0
- data/tests/sample_modules/jsmodule.js +1 -0
- data/tests/selftest.js +57 -0
- data/tests/site/dummy.js +1 -0
- data/tests/site/field-array.html +14 -0
- data/tests/site/frame1.html +10 -0
- data/tests/site/frame2.html +11 -0
- data/tests/site/frame3.html +11 -0
- data/tests/site/frames.html +12 -0
- data/tests/site/global.html +6 -1
- data/tests/site/includes/include1.js +6 -0
- data/tests/site/includes/include2.js +6 -0
- data/tests/site/index.html +3 -0
- data/tests/site/popup.html +19 -0
- data/tests/site/resources.html +7 -8
- data/tests/site/urls.html +14 -0
- data/tests/suites/casper/agent.js +3 -1
- data/tests/suites/casper/alert.js +14 -0
- data/tests/suites/casper/auth.js +24 -0
- data/tests/suites/casper/capture.js +12 -12
- data/tests/suites/casper/click.js +11 -1
- data/tests/suites/casper/confirm.js +24 -16
- data/tests/suites/casper/debug.js +10 -0
- data/tests/suites/casper/elementattribute.js +3 -1
- data/tests/suites/casper/encode.js +6 -2
- data/tests/suites/casper/evaluate.js +78 -18
- data/tests/suites/casper/events.js +3 -1
- data/tests/suites/casper/exists.js +3 -1
- data/tests/suites/casper/fetchtext.js +3 -1
- data/tests/suites/casper/flow.coffee +1 -1
- data/tests/suites/casper/formfill.js +39 -4
- data/tests/suites/casper/frames.js +43 -0
- data/tests/suites/casper/global.js +9 -3
- data/tests/suites/casper/headers.js +41 -0
- data/tests/suites/casper/history.js +3 -1
- data/tests/suites/casper/hooks.js +3 -1
- data/tests/suites/casper/keys.js +15 -0
- data/tests/suites/casper/location.js +21 -0
- data/tests/suites/casper/logging.js +3 -1
- data/tests/suites/casper/mouseevents.js +3 -1
- data/tests/suites/casper/onerror.js +3 -1
- data/tests/suites/casper/open.js +63 -1
- data/tests/suites/casper/popup.js +86 -0
- data/tests/suites/casper/prompt.js +11 -15
- data/tests/suites/casper/request.js +36 -0
- data/tests/suites/casper/resources.coffee +5 -5
- data/tests/suites/casper/scripts.js +32 -0
- data/tests/suites/casper/start.js +3 -1
- data/tests/suites/casper/steps.js +4 -2
- data/tests/suites/casper/urls.js +21 -0
- data/tests/suites/casper/viewport.js +3 -1
- data/tests/suites/casper/visible.js +3 -1
- data/tests/suites/casper/wait.js +22 -12
- data/tests/suites/casper/xpath.js +3 -1
- data/tests/suites/cli.js +3 -1
- data/tests/suites/clientutils.js +57 -3
- data/tests/suites/coffee.coffee +1 -1
- data/tests/suites/fs.js +3 -1
- data/tests/suites/http_status.js +19 -3
- data/tests/suites/popup.js +33 -0
- data/tests/suites/require.js +31 -0
- data/tests/suites/tester.js +134 -29
- data/tests/suites/utils.js +108 -8
- data/tests/suites/xunit.js +37 -6
- metadata +49 -15
- data/modules/injector.js +0 -93
- data/tests/suites/injector.js +0 -64
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: casperjs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
4
|
+
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
|
10
|
-
version: 1.0.0.RC1
|
9
|
+
version: 1.0.0
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Nicolas Perriault
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: rubybin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date:
|
17
|
+
date: 2013-01-04 00:00:00 +08:00
|
19
18
|
default_executable:
|
20
19
|
dependencies: []
|
21
20
|
|
@@ -33,20 +32,27 @@ extra_rdoc_files:
|
|
33
32
|
- LICENSE.md
|
34
33
|
- README.md
|
35
34
|
files:
|
35
|
+
- CHANGELOG.md
|
36
|
+
- CONTRIBUTING.md
|
37
|
+
- CONTRIBUTORS.md
|
36
38
|
- LICENSE.md
|
37
39
|
- README.md
|
38
|
-
- CHANGELOG.md
|
39
40
|
- package.json
|
40
41
|
- casperjs.gemspec
|
41
42
|
- bin/bootstrap.js
|
43
|
+
- bin/casperjs
|
42
44
|
- bin/usage.txt
|
45
|
+
- batchbin/casperjs.bat
|
46
|
+
- rpm/casperjs.spec
|
47
|
+
- rpm/mkrpm.sh
|
43
48
|
- modules/casper.js
|
44
49
|
- modules/cli.js
|
45
50
|
- modules/clientutils.js
|
46
51
|
- modules/colorizer.js
|
47
52
|
- modules/events.js
|
48
|
-
- modules/
|
53
|
+
- modules/http.js
|
49
54
|
- modules/mouse.js
|
55
|
+
- modules/pagestack.js
|
50
56
|
- modules/querystring.js
|
51
57
|
- modules/tester.js
|
52
58
|
- modules/utils.js
|
@@ -92,31 +98,52 @@ files:
|
|
92
98
|
- samples/steptimeout.js
|
93
99
|
- samples/timeout.coffee
|
94
100
|
- samples/timeout.js
|
101
|
+
- samples/translate.coffee
|
102
|
+
- samples/translate.js
|
103
|
+
- tests/commands/mytest.js
|
104
|
+
- tests/commands/script.js
|
95
105
|
- tests/run.js
|
106
|
+
- tests/sample_modules/config.json
|
107
|
+
- tests/sample_modules/csmodule.coffee
|
108
|
+
- tests/sample_modules/jsmodule.js
|
109
|
+
- tests/selftest.js
|
96
110
|
- tests/site/alert.html
|
97
111
|
- tests/site/click.html
|
98
112
|
- tests/site/confirm.html
|
113
|
+
- tests/site/dummy.js
|
99
114
|
- tests/site/elementattribute.html
|
100
115
|
- tests/site/error.html
|
116
|
+
- tests/site/field-array.html
|
101
117
|
- tests/site/form.html
|
118
|
+
- tests/site/frame1.html
|
119
|
+
- tests/site/frame2.html
|
120
|
+
- tests/site/frame3.html
|
121
|
+
- tests/site/frames.html
|
102
122
|
- tests/site/global.html
|
103
123
|
- tests/site/images/phantom.png
|
124
|
+
- tests/site/includes/include1.js
|
125
|
+
- tests/site/includes/include2.js
|
104
126
|
- tests/site/index.html
|
105
127
|
- tests/site/mouse-events.html
|
106
128
|
- tests/site/multiple-forms.html
|
107
129
|
- tests/site/page1.html
|
108
130
|
- tests/site/page2.html
|
109
131
|
- tests/site/page3.html
|
132
|
+
- tests/site/popup.html
|
110
133
|
- tests/site/prompt.html
|
111
134
|
- tests/site/resources.html
|
112
135
|
- tests/site/result.html
|
113
136
|
- tests/site/test.html
|
137
|
+
- tests/site/urls.html
|
114
138
|
- tests/site/visible.html
|
115
139
|
- tests/site/waitFor.html
|
116
140
|
- tests/suites/casper/agent.js
|
141
|
+
- tests/suites/casper/alert.js
|
142
|
+
- tests/suites/casper/auth.js
|
117
143
|
- tests/suites/casper/capture.js
|
118
144
|
- tests/suites/casper/click.js
|
119
145
|
- tests/suites/casper/confirm.js
|
146
|
+
- tests/suites/casper/debug.js
|
120
147
|
- tests/suites/casper/elementattribute.js
|
121
148
|
- tests/suites/casper/encode.js
|
122
149
|
- tests/suites/casper/evaluate.js
|
@@ -125,17 +152,25 @@ files:
|
|
125
152
|
- tests/suites/casper/fetchtext.js
|
126
153
|
- tests/suites/casper/flow.coffee
|
127
154
|
- tests/suites/casper/formfill.js
|
155
|
+
- tests/suites/casper/frames.js
|
128
156
|
- tests/suites/casper/global.js
|
157
|
+
- tests/suites/casper/headers.js
|
129
158
|
- tests/suites/casper/history.js
|
130
159
|
- tests/suites/casper/hooks.js
|
160
|
+
- tests/suites/casper/keys.js
|
161
|
+
- tests/suites/casper/location.js
|
131
162
|
- tests/suites/casper/logging.js
|
132
163
|
- tests/suites/casper/mouseevents.js
|
133
164
|
- tests/suites/casper/onerror.js
|
134
165
|
- tests/suites/casper/open.js
|
166
|
+
- tests/suites/casper/popup.js
|
135
167
|
- tests/suites/casper/prompt.js
|
168
|
+
- tests/suites/casper/request.js
|
136
169
|
- tests/suites/casper/resources.coffee
|
170
|
+
- tests/suites/casper/scripts.js
|
137
171
|
- tests/suites/casper/start.js
|
138
172
|
- tests/suites/casper/steps.js
|
173
|
+
- tests/suites/casper/urls.js
|
139
174
|
- tests/suites/casper/viewport.js
|
140
175
|
- tests/suites/casper/visible.js
|
141
176
|
- tests/suites/casper/wait.js
|
@@ -145,10 +180,11 @@ files:
|
|
145
180
|
- tests/suites/coffee.coffee
|
146
181
|
- tests/suites/fs.js
|
147
182
|
- tests/suites/http_status.js
|
148
|
-
- tests/suites/
|
149
|
-
- tests/suites/tester.js
|
150
|
-
- tests/suites/utils.js
|
183
|
+
- tests/suites/require.js
|
151
184
|
- tests/suites/xunit.js
|
185
|
+
- tests/suites/popup.js
|
186
|
+
- tests/suites/utils.js
|
187
|
+
- tests/suites/tester.js
|
152
188
|
- tests/testdir/01_a/abc.js
|
153
189
|
- tests/testdir/01_a/def.js
|
154
190
|
- tests/testdir/02_b/abc.js
|
@@ -174,15 +210,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
174
210
|
version: "0"
|
175
211
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
176
212
|
requirements:
|
177
|
-
- - "
|
213
|
+
- - ">="
|
178
214
|
- !ruby/object:Gem::Version
|
179
215
|
segments:
|
180
|
-
-
|
181
|
-
|
182
|
-
- 1
|
183
|
-
version: 1.3.1
|
216
|
+
- 0
|
217
|
+
version: "0"
|
184
218
|
requirements:
|
185
|
-
- PhantomJS v1.
|
219
|
+
- PhantomJS v1.7
|
186
220
|
rubyforge_project:
|
187
221
|
rubygems_version: 1.3.6
|
188
222
|
signing_key:
|
data/modules/injector.js
DELETED
@@ -1,93 +0,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
|
-
var utils = require('utils');
|
34
|
-
|
35
|
-
exports.create = function create(fn) {
|
36
|
-
"use strict";
|
37
|
-
return new FunctionArgsInjector(fn);
|
38
|
-
};
|
39
|
-
|
40
|
-
/**
|
41
|
-
* Function argument injector.
|
42
|
-
*
|
43
|
-
* FIXME: use new Function() instead of eval()
|
44
|
-
*/
|
45
|
-
var FunctionArgsInjector = function FunctionArgsInjector(fn) {
|
46
|
-
"use strict";
|
47
|
-
if (!utils.isFunction(fn)) {
|
48
|
-
throw new CasperError("FunctionArgsInjector() can only process functions");
|
49
|
-
}
|
50
|
-
this.fn = fn;
|
51
|
-
|
52
|
-
this.extract = function extract(fn) {
|
53
|
-
var match = /^function\s?(\w+)?\s?\((.*)\)\s?\{([\s\S]*)\}/i.exec(fn.toString().trim());
|
54
|
-
if (match && match.length > 1) {
|
55
|
-
var args = match[2].split(',').map(function _map(arg) {
|
56
|
-
return arg.replace(new RegExp(/\/\*+.*\*\//ig), "").trim();
|
57
|
-
}).filter(function _filter(arg) {
|
58
|
-
return arg;
|
59
|
-
}) || [];
|
60
|
-
return {
|
61
|
-
name: match[1] ? match[1].trim() : null,
|
62
|
-
args: args,
|
63
|
-
body: match[3] ? match[3].trim() : ''
|
64
|
-
};
|
65
|
-
}
|
66
|
-
};
|
67
|
-
|
68
|
-
this.process = function process(values) {
|
69
|
-
var fnObj = this.extract(this.fn);
|
70
|
-
if (!utils.isObject(fnObj)) {
|
71
|
-
throw new CasperError("Unable to process function " + this.fn.toString());
|
72
|
-
}
|
73
|
-
var inject = this.getArgsInjectionString(fnObj.args, values);
|
74
|
-
var newFn = new Function([inject, fnObj.body].join('\n'));
|
75
|
-
newFn.name = fnObj.name || '';
|
76
|
-
return newFn;
|
77
|
-
};
|
78
|
-
|
79
|
-
this.getArgsInjectionString = function getArgsInjectionString(args, values) {
|
80
|
-
values = typeof values === "object" ? values : {};
|
81
|
-
var jsonValues = escape(encodeURIComponent(JSON.stringify(values)));
|
82
|
-
var inject = [
|
83
|
-
'var __casper_params__ = JSON.parse(decodeURIComponent(unescape(\'' + jsonValues + '\')));'
|
84
|
-
];
|
85
|
-
args.forEach(function _forEach(arg) {
|
86
|
-
if (arg in values) {
|
87
|
-
inject.push('var ' + arg + '=__casper_params__["' + arg + '"];');
|
88
|
-
}
|
89
|
-
});
|
90
|
-
return inject.join('\n') + '\n';
|
91
|
-
};
|
92
|
-
};
|
93
|
-
exports.FunctionArgsInjector = FunctionArgsInjector;
|
data/tests/suites/injector.js
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
var t = casper.test;
|
2
|
-
var createInjector = function(fn, values) {
|
3
|
-
return require('injector').create(fn, values);
|
4
|
-
};
|
5
|
-
var testFn = function(a, b) { return a + b; };
|
6
|
-
var injector = createInjector(testFn);
|
7
|
-
var extract = injector.extract(testFn);
|
8
|
-
|
9
|
-
t.comment('FunctionArgsInjector.extract()');
|
10
|
-
t.assertType(extract, "object", 'FunctionArgsInjector.extract() returns an object');
|
11
|
-
t.assertEquals(extract.name, null, 'FunctionArgsInjector.extract() process function name as expected');
|
12
|
-
t.assertEquals(extract.body, 'return a + b;', 'FunctionArgsInjector.extract() process function body as expected');
|
13
|
-
t.assertEquals(extract.args, ['a', 'b'], 'FunctionArgsInjector.extract() process function args as expected');
|
14
|
-
|
15
|
-
function Plop(foo, bar) {
|
16
|
-
return 'foo: ' + foo +', bar: ' + bar;
|
17
|
-
}
|
18
|
-
function Plip() { return 'plop'; }
|
19
|
-
function foo_bar(boz) {}
|
20
|
-
var gni = function ($bubu_bibi, __popo__) {};
|
21
|
-
var gno = function ( arg1, /*plop*/ arg2 ) { };
|
22
|
-
function issue129(term) {
|
23
|
-
// see issue #129
|
24
|
-
return term;
|
25
|
-
// see issue #129
|
26
|
-
}
|
27
|
-
t.assertEquals(injector.extract(Plop), {
|
28
|
-
name: 'Plop',
|
29
|
-
args: ['foo', 'bar'],
|
30
|
-
body: "return 'foo: ' + foo +', bar: ' + bar;"
|
31
|
-
}, 'FunctionArgsInjector.extract() handles named functions with arguments and body');
|
32
|
-
t.assertEquals(injector.extract(Plip), {
|
33
|
-
name: 'Plip',
|
34
|
-
args: [],
|
35
|
-
body: "return 'plop';"
|
36
|
-
}, 'FunctionArgsInjector.extract() handles functions with no arguments');
|
37
|
-
t.assertEquals(injector.extract(foo_bar), {
|
38
|
-
name: 'foo_bar',
|
39
|
-
args: ['boz'],
|
40
|
-
body: ""
|
41
|
-
}, 'FunctionArgsInjector.extract() handles functions with no body');
|
42
|
-
t.assertEquals(injector.extract(gni), {
|
43
|
-
name: null,
|
44
|
-
args: ['$bubu_bibi', '__popo__'],
|
45
|
-
body: ""
|
46
|
-
}, 'FunctionArgsInjector.extract() handles anonymous functions with complex args passed');
|
47
|
-
t.assertEquals(injector.extract(gno), {
|
48
|
-
name: null,
|
49
|
-
args: ['arg1', 'arg2'],
|
50
|
-
body: ""
|
51
|
-
}, 'FunctionArgsInjector.extract() handles can filter comments in function args');
|
52
|
-
|
53
|
-
t.comment('FunctionArgsInjector.process()');
|
54
|
-
var processed;
|
55
|
-
eval('processed = ' + injector.process({ a: 1, b: 2 }));
|
56
|
-
|
57
|
-
t.assertType(processed, "function", 'FunctionArgsInjector.process() processed a function');
|
58
|
-
t.assertEquals(processed(), 3, 'FunctionArgsInjector.process() processed the function correctly');
|
59
|
-
|
60
|
-
// Issue #129
|
61
|
-
var fnIssue129 = createInjector(issue129).process({term: 'fixed'});
|
62
|
-
t.assertEquals(fnIssue129('fixed'), 'fixed', 'FunctionArgsInjector.process() has issue #129 fixed');
|
63
|
-
|
64
|
-
t.done();
|