phantomjs-binaries 1.8.0 → 1.8.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/phantomjs-binaries/version.rb +1 -1
- data/phantomjs-binaries.gemspec +1 -1
- metadata +3 -23
- data/bin/bootstrap.js +0 -342
- data/bin/casperjs +0 -58
- data/bin/usage.txt +0 -11
- data/modules/casper.js +0 -2101
- data/modules/cli.js +0 -138
- data/modules/clientutils.js +0 -781
- data/modules/colorizer.js +0 -130
- data/modules/events.js +0 -259
- data/modules/http.js +0 -70
- data/modules/mouse.js +0 -109
- data/modules/pagestack.js +0 -166
- data/modules/querystring.js +0 -187
- data/modules/tester.js +0 -1161
- data/modules/utils.js +0 -581
- data/modules/vendors/coffee-script.js +0 -8
- data/modules/xunit.js +0 -155
- data/package.json +0 -35
data/modules/mouse.js
DELETED
@@ -1,109 +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 exports require*/
|
32
|
-
|
33
|
-
var utils = require('utils');
|
34
|
-
|
35
|
-
exports.create = function create(casper) {
|
36
|
-
"use strict";
|
37
|
-
return new Mouse(casper);
|
38
|
-
};
|
39
|
-
|
40
|
-
var Mouse = function Mouse(casper) {
|
41
|
-
"use strict";
|
42
|
-
if (!utils.isCasperObject(casper)) {
|
43
|
-
throw new CasperError('Mouse() needs a Casper instance');
|
44
|
-
}
|
45
|
-
|
46
|
-
var slice = Array.prototype.slice;
|
47
|
-
|
48
|
-
var nativeEvents = ['mouseup', 'mousedown', 'click', 'mousemove'];
|
49
|
-
var emulatedEvents = ['mouseover', 'mouseout'];
|
50
|
-
var supportedEvents = nativeEvents.concat(emulatedEvents);
|
51
|
-
|
52
|
-
function computeCenter(selector) {
|
53
|
-
var bounds = casper.getElementBounds(selector);
|
54
|
-
if (utils.isClipRect(bounds)) {
|
55
|
-
var x = Math.round(bounds.left + bounds.width / 2);
|
56
|
-
var y = Math.round(bounds.top + bounds.height / 2);
|
57
|
-
return [x, y];
|
58
|
-
}
|
59
|
-
}
|
60
|
-
|
61
|
-
function processEvent(type, args) {
|
62
|
-
if (!utils.isString(type) || supportedEvents.indexOf(type) === -1) {
|
63
|
-
throw new CasperError('Mouse.processEvent(): Unsupported mouse event type: ' + type);
|
64
|
-
}
|
65
|
-
if (emulatedEvents.indexOf(type) > -1) {
|
66
|
-
casper.log("Mouse.processEvent(): no native fallback for type " + type, "warning");
|
67
|
-
}
|
68
|
-
args = slice.call(args); // cast Arguments -> Array
|
69
|
-
casper.emit('mouse.' + type.replace('mouse', ''), args);
|
70
|
-
switch (args.length) {
|
71
|
-
case 0:
|
72
|
-
throw new CasperError('Mouse.processEvent(): Too few arguments');
|
73
|
-
case 1:
|
74
|
-
// selector
|
75
|
-
casper.page.sendEvent.apply(casper.page, [type].concat(computeCenter(args[0])));
|
76
|
-
break;
|
77
|
-
case 2:
|
78
|
-
// coordinates
|
79
|
-
if (!utils.isNumber(args[0]) || !utils.isNumber(args[1])) {
|
80
|
-
throw new CasperError('Mouse.processEvent(): No valid coordinates passed: ' + args);
|
81
|
-
}
|
82
|
-
casper.page.sendEvent(type, args[0], args[1]);
|
83
|
-
break;
|
84
|
-
default:
|
85
|
-
throw new CasperError('Mouse.processEvent(): Too many arguments');
|
86
|
-
}
|
87
|
-
}
|
88
|
-
|
89
|
-
this.processEvent = function() {
|
90
|
-
processEvent(arguments[0], slice.call(arguments, 1));
|
91
|
-
};
|
92
|
-
|
93
|
-
this.click = function click() {
|
94
|
-
processEvent('click', arguments);
|
95
|
-
};
|
96
|
-
|
97
|
-
this.down = function down() {
|
98
|
-
processEvent('mousedown', arguments);
|
99
|
-
};
|
100
|
-
|
101
|
-
this.move = function move() {
|
102
|
-
processEvent('mousemove', arguments);
|
103
|
-
};
|
104
|
-
|
105
|
-
this.up = function up() {
|
106
|
-
processEvent('mouseup', arguments);
|
107
|
-
};
|
108
|
-
};
|
109
|
-
exports.Mouse = Mouse;
|
data/modules/pagestack.js
DELETED
@@ -1,166 +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 exports phantom require*/
|
32
|
-
|
33
|
-
var utils = require('utils');
|
34
|
-
var f = utils.format;
|
35
|
-
|
36
|
-
function create() {
|
37
|
-
"use strict";
|
38
|
-
return new Stack();
|
39
|
-
}
|
40
|
-
exports.create = create;
|
41
|
-
|
42
|
-
/**
|
43
|
-
* Popups container. Implements Array prototype.
|
44
|
-
*
|
45
|
-
*/
|
46
|
-
var Stack = function Stack(){};
|
47
|
-
exports.Stack = Stack;
|
48
|
-
|
49
|
-
Stack.prototype = [];
|
50
|
-
|
51
|
-
/**
|
52
|
-
* Cleans the stack from closed popup.
|
53
|
-
*
|
54
|
-
* @param WebPage closed Closed popup page instance
|
55
|
-
* @return Number New stack length
|
56
|
-
*/
|
57
|
-
Stack.prototype.clean = function clean(closed) {
|
58
|
-
"use strict";
|
59
|
-
var closedIndex = -1;
|
60
|
-
this.forEach(function(popup, index) {
|
61
|
-
if (closed === popup) {
|
62
|
-
closedIndex = index;
|
63
|
-
}
|
64
|
-
});
|
65
|
-
if (closedIndex > -1) {
|
66
|
-
this.splice(closedIndex, 1);
|
67
|
-
}
|
68
|
-
return this.length;
|
69
|
-
};
|
70
|
-
|
71
|
-
/**
|
72
|
-
* Finds a popup matching the provided information. Information can be:
|
73
|
-
*
|
74
|
-
* - RegExp: matching page url
|
75
|
-
* - String: strict page url value
|
76
|
-
* - WebPage: a direct WebPage instance
|
77
|
-
*
|
78
|
-
* @param Mixed popupInfo
|
79
|
-
* @return WebPage
|
80
|
-
*/
|
81
|
-
Stack.prototype.find = function find(popupInfo) {
|
82
|
-
"use strict";
|
83
|
-
var popup, type = utils.betterTypeOf(popupInfo);
|
84
|
-
switch (type) {
|
85
|
-
case "regexp":
|
86
|
-
popup = this.findByRegExp(popupInfo);
|
87
|
-
break;
|
88
|
-
case "string":
|
89
|
-
popup = this.findByURL(popupInfo);
|
90
|
-
break;
|
91
|
-
case "qtruntimeobject": // WebPage
|
92
|
-
popup = popupInfo;
|
93
|
-
if (!utils.isWebPage(popup) || !this.some(function(popupPage) {
|
94
|
-
if (popupInfo.id && popupPage.id) {
|
95
|
-
return popupPage.id === popup.id;
|
96
|
-
}
|
97
|
-
return popupPage.url === popup.url;
|
98
|
-
})) {
|
99
|
-
throw new CasperError("Invalid or missing popup.");
|
100
|
-
}
|
101
|
-
break;
|
102
|
-
default:
|
103
|
-
throw new CasperError(f("Invalid popupInfo type: %s.", type));
|
104
|
-
}
|
105
|
-
return popup;
|
106
|
-
};
|
107
|
-
|
108
|
-
/**
|
109
|
-
* Finds the first popup which url matches a given RegExp.
|
110
|
-
*
|
111
|
-
* @param RegExp regexp
|
112
|
-
* @return WebPage
|
113
|
-
*/
|
114
|
-
Stack.prototype.findByRegExp = function findByRegExp(regexp) {
|
115
|
-
"use strict";
|
116
|
-
var popup = this.filter(function(popupPage) {
|
117
|
-
return regexp.test(popupPage.url);
|
118
|
-
})[0];
|
119
|
-
if (!popup) {
|
120
|
-
throw new CasperError(f("Couldn't find popup with url matching pattern %s", regexp));
|
121
|
-
}
|
122
|
-
return popup;
|
123
|
-
};
|
124
|
-
|
125
|
-
/**
|
126
|
-
* Finds the first popup matching a given url.
|
127
|
-
*
|
128
|
-
* @param String url The child WebPage url
|
129
|
-
* @return WebPage
|
130
|
-
*/
|
131
|
-
Stack.prototype.findByURL = function findByURL(string) {
|
132
|
-
"use strict";
|
133
|
-
var popup = this.filter(function(popupPage) {
|
134
|
-
return popupPage.url.indexOf(string) !== -1;
|
135
|
-
})[0];
|
136
|
-
if (!popup) {
|
137
|
-
throw new CasperError(f("Couldn't find popup with url containing '%s'", string));
|
138
|
-
}
|
139
|
-
return popup;
|
140
|
-
};
|
141
|
-
|
142
|
-
/**
|
143
|
-
* Returns a human readable list of current active popup urls.
|
144
|
-
*
|
145
|
-
* @return Array Mapped stack.
|
146
|
-
*/
|
147
|
-
Stack.prototype.list = function list() {
|
148
|
-
"use strict";
|
149
|
-
return this.map(function(popup) {
|
150
|
-
try {
|
151
|
-
return popup.url;
|
152
|
-
} catch (e) {
|
153
|
-
return '<deleted>';
|
154
|
-
}
|
155
|
-
});
|
156
|
-
};
|
157
|
-
|
158
|
-
/**
|
159
|
-
* String representation of current instance.
|
160
|
-
*
|
161
|
-
* @return String
|
162
|
-
*/
|
163
|
-
Stack.prototype.toString = function toString() {
|
164
|
-
"use strict";
|
165
|
-
return f("[Object Stack], having %d popup(s)" % this.length);
|
166
|
-
};
|
data/modules/querystring.js
DELETED
@@ -1,187 +0,0 @@
|
|
1
|
-
// Copyright Joyent, Inc. and other Node contributors.
|
2
|
-
//
|
3
|
-
// Permission is hereby granted, free of charge, to any person obtaining a
|
4
|
-
// copy of this software and associated documentation files (the
|
5
|
-
// "Software"), to deal in the Software without restriction, including
|
6
|
-
// without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
8
|
-
// persons to whom the Software is furnished to do so, subject to the
|
9
|
-
// following conditions:
|
10
|
-
//
|
11
|
-
// The above copyright notice and this permission notice shall be included
|
12
|
-
// in all copies or substantial portions of the Software.
|
13
|
-
//
|
14
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
15
|
-
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
17
|
-
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
18
|
-
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
19
|
-
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
20
|
-
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
-
|
22
|
-
// Query String Utilities
|
23
|
-
|
24
|
-
var QueryString = exports;
|
25
|
-
//var urlDecode = process.binding('http_parser').urlDecode; // phantomjs incompatible
|
26
|
-
|
27
|
-
|
28
|
-
// If obj.hasOwnProperty has been overridden, then calling
|
29
|
-
// obj.hasOwnProperty(prop) will break.
|
30
|
-
// See: https://github.com/joyent/node/issues/1707
|
31
|
-
function hasOwnProperty(obj, prop) {
|
32
|
-
return Object.prototype.hasOwnProperty.call(obj, prop);
|
33
|
-
}
|
34
|
-
|
35
|
-
|
36
|
-
function charCode(c) {
|
37
|
-
return c.charCodeAt(0);
|
38
|
-
}
|
39
|
-
|
40
|
-
|
41
|
-
// a safe fast alternative to decodeURIComponent
|
42
|
-
QueryString.unescapeBuffer = function(s, decodeSpaces) {
|
43
|
-
var out = new Buffer(s.length);
|
44
|
-
var state = 'CHAR'; // states: CHAR, HEX0, HEX1
|
45
|
-
var n, m, hexchar;
|
46
|
-
|
47
|
-
for (var inIndex = 0, outIndex = 0; inIndex <= s.length; inIndex++) {
|
48
|
-
var c = s.charCodeAt(inIndex);
|
49
|
-
switch (state) {
|
50
|
-
case 'CHAR':
|
51
|
-
switch (c) {
|
52
|
-
case charCode('%'):
|
53
|
-
n = 0;
|
54
|
-
m = 0;
|
55
|
-
state = 'HEX0';
|
56
|
-
break;
|
57
|
-
case charCode('+'):
|
58
|
-
if (decodeSpaces) c = charCode(' ');
|
59
|
-
// pass thru
|
60
|
-
default:
|
61
|
-
out[outIndex++] = c;
|
62
|
-
break;
|
63
|
-
}
|
64
|
-
break;
|
65
|
-
|
66
|
-
case 'HEX0':
|
67
|
-
state = 'HEX1';
|
68
|
-
hexchar = c;
|
69
|
-
if (charCode('0') <= c && c <= charCode('9')) {
|
70
|
-
n = c - charCode('0');
|
71
|
-
} else if (charCode('a') <= c && c <= charCode('f')) {
|
72
|
-
n = c - charCode('a') + 10;
|
73
|
-
} else if (charCode('A') <= c && c <= charCode('F')) {
|
74
|
-
n = c - charCode('A') + 10;
|
75
|
-
} else {
|
76
|
-
out[outIndex++] = charCode('%');
|
77
|
-
out[outIndex++] = c;
|
78
|
-
state = 'CHAR';
|
79
|
-
break;
|
80
|
-
}
|
81
|
-
break;
|
82
|
-
|
83
|
-
case 'HEX1':
|
84
|
-
state = 'CHAR';
|
85
|
-
if (charCode('0') <= c && c <= charCode('9')) {
|
86
|
-
m = c - charCode('0');
|
87
|
-
} else if (charCode('a') <= c && c <= charCode('f')) {
|
88
|
-
m = c - charCode('a') + 10;
|
89
|
-
} else if (charCode('A') <= c && c <= charCode('F')) {
|
90
|
-
m = c - charCode('A') + 10;
|
91
|
-
} else {
|
92
|
-
out[outIndex++] = charCode('%');
|
93
|
-
out[outIndex++] = hexchar;
|
94
|
-
out[outIndex++] = c;
|
95
|
-
break;
|
96
|
-
}
|
97
|
-
out[outIndex++] = 16 * n + m;
|
98
|
-
break;
|
99
|
-
}
|
100
|
-
}
|
101
|
-
|
102
|
-
// TODO support returning arbitrary buffers.
|
103
|
-
|
104
|
-
return out.slice(0, outIndex - 1);
|
105
|
-
};
|
106
|
-
|
107
|
-
|
108
|
-
QueryString.unescape = function(s, decodeSpaces) {
|
109
|
-
return QueryString.unescapeBuffer(s, decodeSpaces).toString();
|
110
|
-
};
|
111
|
-
|
112
|
-
|
113
|
-
QueryString.escape = function(str) {
|
114
|
-
return encodeURIComponent(str);
|
115
|
-
};
|
116
|
-
|
117
|
-
var stringifyPrimitive = function(v) {
|
118
|
-
switch (typeof v) {
|
119
|
-
case 'string':
|
120
|
-
return v;
|
121
|
-
|
122
|
-
case 'boolean':
|
123
|
-
return v ? 'true' : 'false';
|
124
|
-
|
125
|
-
case 'number':
|
126
|
-
return isFinite(v) ? v : '';
|
127
|
-
|
128
|
-
default:
|
129
|
-
return '';
|
130
|
-
}
|
131
|
-
};
|
132
|
-
|
133
|
-
|
134
|
-
QueryString.stringify = QueryString.encode = function(obj, sep, eq, name) {
|
135
|
-
sep = sep || '&';
|
136
|
-
eq = eq || '=';
|
137
|
-
obj = (obj === null) ? undefined : obj;
|
138
|
-
|
139
|
-
switch (typeof obj) {
|
140
|
-
case 'object':
|
141
|
-
return Object.keys(obj).map(function(k) {
|
142
|
-
if (Array.isArray(obj[k])) {
|
143
|
-
return obj[k].map(function(v) {
|
144
|
-
return QueryString.escape(stringifyPrimitive(k)) +
|
145
|
-
eq +
|
146
|
-
QueryString.escape(stringifyPrimitive(v));
|
147
|
-
}).join(sep);
|
148
|
-
} else {
|
149
|
-
return QueryString.escape(stringifyPrimitive(k)) +
|
150
|
-
eq +
|
151
|
-
QueryString.escape(stringifyPrimitive(obj[k]));
|
152
|
-
}
|
153
|
-
}).join(sep);
|
154
|
-
|
155
|
-
default:
|
156
|
-
if (!name) return '';
|
157
|
-
return QueryString.escape(stringifyPrimitive(name)) + eq +
|
158
|
-
QueryString.escape(stringifyPrimitive(obj));
|
159
|
-
}
|
160
|
-
};
|
161
|
-
|
162
|
-
// Parse a key=val string.
|
163
|
-
QueryString.parse = QueryString.decode = function(qs, sep, eq) {
|
164
|
-
sep = sep || '&';
|
165
|
-
eq = eq || '=';
|
166
|
-
var obj = {};
|
167
|
-
|
168
|
-
if (typeof qs !== 'string' || qs.length === 0) {
|
169
|
-
return obj;
|
170
|
-
}
|
171
|
-
|
172
|
-
qs.split(sep).forEach(function(kvp) {
|
173
|
-
var x = kvp.split(eq);
|
174
|
-
var k = QueryString.unescape(x[0], true);
|
175
|
-
var v = QueryString.unescape(x.slice(1).join(eq), true);
|
176
|
-
|
177
|
-
if (!hasOwnProperty(obj, k)) {
|
178
|
-
obj[k] = v;
|
179
|
-
} else if (!Array.isArray(obj[k])) {
|
180
|
-
obj[k] = [obj[k], v];
|
181
|
-
} else {
|
182
|
-
obj[k].push(v);
|
183
|
-
}
|
184
|
-
});
|
185
|
-
|
186
|
-
return obj;
|
187
|
-
};
|