selenium-webdriver 3.0.0-beta-1 → 3.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.
- package/CHANGES.md +109 -0
- package/LICENSE +1 -1
- package/README.md +7 -6
- package/chrome.js +31 -128
- package/edge.js +13 -91
- package/example/chrome_android.js +18 -13
- package/example/chrome_mobile_emulation.js +19 -15
- package/example/google_search.js +11 -11
- package/example/google_search_generator.js +23 -18
- package/example/google_search_test.js +31 -17
- package/example/logging.js +9 -17
- package/example/parallel_flows.js +3 -0
- package/firefox/binary.js +17 -0
- package/firefox/index.js +198 -101
- package/firefox/profile.js +24 -3
- package/http/util.js +95 -59
- package/ie.js +6 -10
- package/index.js +636 -2
- package/lib/actions.js +18 -10
- package/lib/atoms/getAttribute.js +11 -0
- package/lib/atoms/isDisplayed.js +106 -0
- package/lib/firefox/amd64/libnoblur64.so +0 -0
- package/lib/firefox/i386/libnoblur.so +0 -0
- package/lib/firefox/webdriver.xpi +0 -0
- package/lib/http.js +159 -46
- package/lib/logging.js +7 -1
- package/lib/promise.js +602 -358
- package/lib/proxy.js +28 -0
- package/lib/session.js +1 -1
- package/lib/test/build.js +26 -28
- package/lib/test/data/formPage.html +1 -0
- package/lib/test/fileserver.js +12 -10
- package/lib/test/httpserver.js +4 -6
- package/lib/test/index.js +18 -11
- package/lib/test/promise.js +79 -0
- package/lib/webdriver.js +587 -479
- package/opera.js +12 -88
- package/package.json +13 -14
- package/phantomjs.js +7 -14
- package/remote/index.js +201 -30
- package/safari.js +62 -416
- package/test/actions_test.js +9 -11
- package/test/chrome/options_test.js +8 -8
- package/test/chrome/service_test.js +2 -2
- package/test/cookie_test.js +57 -57
- package/test/element_finding_test.js +201 -185
- package/test/execute_script_test.js +108 -111
- package/test/fingerprint_test.js +16 -11
- package/test/firefox/firefox_test.js +75 -49
- package/test/firefox/profile_test.js +1 -3
- package/test/http/util_test.js +21 -27
- package/test/io_test.js +2 -5
- package/test/lib/http_test.js +8 -6
- package/test/lib/promise_aplus_test.js +48 -44
- package/test/lib/promise_error_test.js +687 -611
- package/test/lib/promise_flow_test.js +1810 -1806
- package/test/lib/promise_generator_test.js +227 -225
- package/test/lib/promise_test.js +864 -835
- package/test/lib/until_test.js +1 -1
- package/test/lib/webdriver_test.js +520 -424
- package/test/logging_test.js +43 -45
- package/test/net/portprober_test.js +23 -24
- package/test/page_loading_test.js +84 -78
- package/test/phantomjs/execute_phantomjs_test.js +11 -25
- package/test/proxy_test.js +23 -23
- package/test/remote_test.js +22 -22
- package/test/safari_test.js +108 -0
- package/test/session_test.js +11 -10
- package/test/stale_element_test.js +18 -16
- package/test/tag_name_test.js +7 -5
- package/test/testing/assert_test.js +2 -3
- package/test/testing/index_test.js +163 -117
- package/test/upload_test.js +13 -13
- package/test/window_test.js +94 -70
- package/testing/index.js +176 -37
- package/builder.js +0 -553
- package/lib/safari/client.js +0 -56
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
|
|
18
18
|
'use strict';
|
|
19
19
|
|
|
20
|
-
var path = require('path');
|
|
21
20
|
var fail = require('assert').fail;
|
|
22
21
|
|
|
23
22
|
var webdriver = require('..'),
|
|
@@ -30,24 +29,24 @@ var webdriver = require('..'),
|
|
|
30
29
|
test.suite(function(env) {
|
|
31
30
|
var driver;
|
|
32
31
|
|
|
33
|
-
test.before(function() {
|
|
34
|
-
driver = env.builder().build();
|
|
32
|
+
test.before(function*() {
|
|
33
|
+
driver = yield env.builder().build();
|
|
35
34
|
});
|
|
36
35
|
|
|
37
36
|
test.after(function() {
|
|
38
|
-
driver.quit();
|
|
37
|
+
return driver.quit();
|
|
39
38
|
});
|
|
40
39
|
|
|
41
40
|
test.beforeEach(function() {
|
|
42
|
-
driver.get(test.Pages.echoPage);
|
|
41
|
+
return driver.get(test.Pages.echoPage);
|
|
43
42
|
});
|
|
44
43
|
|
|
45
44
|
describe('executeScript;', function() {
|
|
46
45
|
var shouldHaveFailed = new Error('Should have failed');
|
|
47
46
|
|
|
48
47
|
test.it('fails if script throws', function() {
|
|
49
|
-
execute('throw new Error("boom")')
|
|
50
|
-
.then(function() { throw
|
|
48
|
+
return execute('throw new Error("boom")')
|
|
49
|
+
.then(function() { throw shouldHaveFailed; })
|
|
51
50
|
.catch(function(e) {
|
|
52
51
|
// The java WebDriver server adds a bunch of crap to error messages.
|
|
53
52
|
// Error message will just be "JavaScript error" for IE.
|
|
@@ -56,72 +55,72 @@ test.suite(function(env) {
|
|
|
56
55
|
});
|
|
57
56
|
|
|
58
57
|
test.it('fails if script does not parse', function() {
|
|
59
|
-
execute('throw function\\*')
|
|
60
|
-
.then(function() { throw
|
|
58
|
+
return execute('throw function\\*')
|
|
59
|
+
.then(function() { throw shouldHaveFailed; })
|
|
61
60
|
.catch(function(e) {
|
|
62
61
|
assert(e).notEqualTo(shouldHaveFailed);
|
|
63
62
|
});
|
|
64
63
|
});
|
|
65
64
|
|
|
66
65
|
describe('scripts;', function() {
|
|
67
|
-
test.it('do not pollute the global scope', function() {
|
|
68
|
-
execute('var x = 1;');
|
|
69
|
-
assert(execute('return typeof x;')).equalTo('undefined');
|
|
66
|
+
test.it('do not pollute the global scope', function*() {
|
|
67
|
+
yield execute('var x = 1;');
|
|
68
|
+
yield assert(execute('return typeof x;')).equalTo('undefined');
|
|
70
69
|
});
|
|
71
70
|
|
|
72
|
-
test.it('can set global variables', function() {
|
|
73
|
-
execute('window.x = 1234;');
|
|
74
|
-
assert(execute('return x;')).equalTo(1234);
|
|
71
|
+
test.it('can set global variables', function*() {
|
|
72
|
+
yield execute('window.x = 1234;');
|
|
73
|
+
yield assert(execute('return x;')).equalTo(1234);
|
|
75
74
|
});
|
|
76
75
|
|
|
77
|
-
test.it('may be defined as a function expression', function() {
|
|
78
|
-
|
|
76
|
+
test.it('may be defined as a function expression', function*() {
|
|
77
|
+
let result = yield execute(function() {
|
|
79
78
|
return 1234 + 'abc';
|
|
80
|
-
})
|
|
79
|
+
});
|
|
80
|
+
assert(result).equalTo('1234abc');
|
|
81
81
|
});
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
describe('return values;', function() {
|
|
85
85
|
|
|
86
86
|
test.it('returns undefined as null', function() {
|
|
87
|
-
assert(execute('var x; return x;')).isNull();
|
|
87
|
+
return assert(execute('var x; return x;')).isNull();
|
|
88
88
|
});
|
|
89
89
|
|
|
90
90
|
test.it('can return null', function() {
|
|
91
|
-
assert(execute('return null;')).isNull();
|
|
91
|
+
return assert(execute('return null;')).isNull();
|
|
92
92
|
});
|
|
93
93
|
|
|
94
|
-
test.it('can return numbers', function() {
|
|
95
|
-
assert(execute('return 1234')).equalTo(1234);
|
|
96
|
-
assert(execute('return 3.1456')).equalTo(3.1456);
|
|
94
|
+
test.it('can return numbers', function*() {
|
|
95
|
+
yield assert(execute('return 1234')).equalTo(1234);
|
|
96
|
+
yield assert(execute('return 3.1456')).equalTo(3.1456);
|
|
97
97
|
});
|
|
98
98
|
|
|
99
99
|
test.it('can return strings', function() {
|
|
100
|
-
assert(execute('return "hello"')).equalTo('hello');
|
|
100
|
+
return assert(execute('return "hello"')).equalTo('hello');
|
|
101
101
|
});
|
|
102
102
|
|
|
103
|
-
test.it('can return booleans', function() {
|
|
104
|
-
assert(execute('return true')).equalTo(true);
|
|
105
|
-
assert(execute('return false')).equalTo(false);
|
|
103
|
+
test.it('can return booleans', function*() {
|
|
104
|
+
yield assert(execute('return true')).equalTo(true);
|
|
105
|
+
yield assert(execute('return false')).equalTo(false);
|
|
106
106
|
});
|
|
107
107
|
|
|
108
108
|
test.it('can return an array of primitives', function() {
|
|
109
|
-
execute('var x; return [1, false, null, 3.14, x]')
|
|
109
|
+
return execute('var x; return [1, false, null, 3.14, x]')
|
|
110
110
|
.then(verifyJson([1, false, null, 3.14, null]));
|
|
111
111
|
});
|
|
112
112
|
|
|
113
113
|
test.it('can return nested arrays', function() {
|
|
114
|
-
execute('return [[1, 2, [3]]]')
|
|
115
|
-
.then(verifyJson([[1, 2, [3]]]));
|
|
114
|
+
return execute('return [[1, 2, [3]]]').then(verifyJson([[1, 2, [3]]]));
|
|
116
115
|
});
|
|
117
116
|
|
|
118
|
-
test.ignore(env.browsers(Browser.IE
|
|
117
|
+
test.ignore(env.browsers(Browser.IE)).
|
|
119
118
|
it('can return empty object literal', function() {
|
|
120
|
-
execute('return {}').then(verifyJson({}));
|
|
119
|
+
return execute('return {}').then(verifyJson({}));
|
|
121
120
|
});
|
|
122
121
|
|
|
123
122
|
test.it('can return object literals', function() {
|
|
124
|
-
execute('return {a: 1, b: false, c: null}').then(
|
|
123
|
+
return execute('return {a: 1, b: false, c: null}').then(result => {
|
|
125
124
|
verifyJson(['a', 'b', 'c'])(Object.keys(result).sort());
|
|
126
125
|
assert(result.a).equalTo(1);
|
|
127
126
|
assert(result.b).equalTo(false);
|
|
@@ -130,118 +129,116 @@ test.suite(function(env) {
|
|
|
130
129
|
});
|
|
131
130
|
|
|
132
131
|
test.it('can return complex object literals', function() {
|
|
133
|
-
execute('return {a:{b: "hello"}}')
|
|
132
|
+
return execute('return {a:{b: "hello"}}')
|
|
133
|
+
.then(verifyJson({a:{b: 'hello'}}));
|
|
134
134
|
});
|
|
135
135
|
|
|
136
|
-
test.it('can return dom elements as web elements', function() {
|
|
137
|
-
|
|
138
|
-
.
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
136
|
+
test.it('can return dom elements as web elements', function*() {
|
|
137
|
+
let result =
|
|
138
|
+
yield execute('return document.querySelector(".header.host")');
|
|
139
|
+
assert(result).instanceOf(webdriver.WebElement);
|
|
140
|
+
|
|
141
|
+
return assert(result.getText()).startsWith('host: ');
|
|
142
142
|
});
|
|
143
143
|
|
|
144
|
-
test.it('can return array of dom elements', function() {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
144
|
+
test.it('can return array of dom elements', function*() {
|
|
145
|
+
let result = yield execute(
|
|
146
|
+
'var nodes = document.querySelectorAll(".request,.host");' +
|
|
147
|
+
'return [nodes[0], nodes[1]];');
|
|
148
|
+
assert(result.length).equalTo(2);
|
|
149
149
|
|
|
150
|
-
|
|
151
|
-
|
|
150
|
+
assert(result[0]).instanceOf(webdriver.WebElement);
|
|
151
|
+
yield assert(result[0].getText()).startsWith('GET ');
|
|
152
152
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
});
|
|
153
|
+
assert(result[1]).instanceOf(webdriver.WebElement);
|
|
154
|
+
yield assert(result[1].getText()).startsWith('host: ');
|
|
156
155
|
});
|
|
157
156
|
|
|
158
|
-
test.it('can return a NodeList as an array of web elements', function() {
|
|
159
|
-
|
|
160
|
-
.
|
|
161
|
-
assert(result.length).equalTo(2);
|
|
157
|
+
test.it('can return a NodeList as an array of web elements', function*() {
|
|
158
|
+
let result =
|
|
159
|
+
yield execute('return document.querySelectorAll(".request,.host");')
|
|
162
160
|
|
|
163
|
-
|
|
164
|
-
assert(result[0].getText()).startsWith('GET ');
|
|
161
|
+
assert(result.length).equalTo(2);
|
|
165
162
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
163
|
+
assert(result[0]).instanceOf(webdriver.WebElement);
|
|
164
|
+
yield assert(result[0].getText()).startsWith('GET ');
|
|
165
|
+
|
|
166
|
+
assert(result[1]).instanceOf(webdriver.WebElement);
|
|
167
|
+
yield assert(result[1].getText()).startsWith('host: ');
|
|
169
168
|
});
|
|
170
169
|
|
|
171
|
-
test.it('can return object literal with element property', function() {
|
|
172
|
-
execute('return {a: document.body}')
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
170
|
+
test.it('can return object literal with element property', function*() {
|
|
171
|
+
let result = yield execute('return {a: document.body}');
|
|
172
|
+
|
|
173
|
+
assert(result.a).instanceOf(webdriver.WebElement);
|
|
174
|
+
yield assert(result.a.getTagName()).equalTo('body');
|
|
176
175
|
});
|
|
177
176
|
});
|
|
178
177
|
|
|
179
178
|
describe('parameters;', function() {
|
|
180
|
-
test.it('can pass numeric arguments', function() {
|
|
181
|
-
assert(execute('return arguments[0]', 12)).equalTo(12);
|
|
182
|
-
assert(execute('return arguments[0]', 3.14)).equalTo(3.14);
|
|
179
|
+
test.it('can pass numeric arguments', function*() {
|
|
180
|
+
yield assert(execute('return arguments[0]', 12)).equalTo(12);
|
|
181
|
+
yield assert(execute('return arguments[0]', 3.14)).equalTo(3.14);
|
|
183
182
|
});
|
|
184
183
|
|
|
185
|
-
test.it('can pass boolean arguments', function() {
|
|
186
|
-
assert(execute('return arguments[0]', true)).equalTo(true);
|
|
187
|
-
assert(execute('return arguments[0]', false)).equalTo(false);
|
|
184
|
+
test.it('can pass boolean arguments', function*() {
|
|
185
|
+
yield assert(execute('return arguments[0]', true)).equalTo(true);
|
|
186
|
+
yield assert(execute('return arguments[0]', false)).equalTo(false);
|
|
188
187
|
});
|
|
189
188
|
|
|
190
|
-
test.it('can pass string arguments', function() {
|
|
191
|
-
assert(execute('return arguments[0]', 'hi')).equalTo('hi');
|
|
189
|
+
test.it('can pass string arguments', function*() {
|
|
190
|
+
yield assert(execute('return arguments[0]', 'hi')).equalTo('hi');
|
|
192
191
|
});
|
|
193
192
|
|
|
194
|
-
test.it('can pass null arguments', function() {
|
|
195
|
-
assert(execute('return arguments[0] === null', null)).equalTo(true);
|
|
196
|
-
assert(execute('return arguments[0]', null)).equalTo(null);
|
|
193
|
+
test.it('can pass null arguments', function*() {
|
|
194
|
+
yield assert(execute('return arguments[0] === null', null)).equalTo(true);
|
|
195
|
+
yield assert(execute('return arguments[0]', null)).equalTo(null);
|
|
197
196
|
});
|
|
198
197
|
|
|
199
|
-
test.it('passes undefined as a null argument', function() {
|
|
198
|
+
test.it('passes undefined as a null argument', function*() {
|
|
200
199
|
var x;
|
|
201
|
-
assert(execute('return arguments[0] === null', x)).equalTo(true);
|
|
202
|
-
assert(execute('return arguments[0]', x)).equalTo(null);
|
|
200
|
+
yield assert(execute('return arguments[0] === null', x)).equalTo(true);
|
|
201
|
+
yield assert(execute('return arguments[0]', x)).equalTo(null);
|
|
203
202
|
});
|
|
204
203
|
|
|
205
|
-
test.it('can pass multiple arguments', function() {
|
|
206
|
-
assert(execute('return arguments.length')).equalTo(0);
|
|
207
|
-
assert(execute('return arguments.length', 1, 'a', false)).equalTo(3);
|
|
204
|
+
test.it('can pass multiple arguments', function*() {
|
|
205
|
+
yield assert(execute('return arguments.length')).equalTo(0);
|
|
206
|
+
yield assert(execute('return arguments.length', 1, 'a', false)).equalTo(3);
|
|
208
207
|
});
|
|
209
208
|
|
|
210
|
-
test.ignore(env.browsers(Browser.FIREFOX)).
|
|
211
|
-
it('can return arguments object as array', function() {
|
|
212
|
-
execute('return arguments', 1, 'a', false)
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
209
|
+
test.ignore(env.browsers(Browser.FIREFOX, Browser.SAFARI)).
|
|
210
|
+
it('can return arguments object as array', function*() {
|
|
211
|
+
let val = yield execute('return arguments', 1, 'a', false);
|
|
212
|
+
|
|
213
|
+
assert(val.length).equalTo(3);
|
|
214
|
+
assert(val[0]).equalTo(1);
|
|
215
|
+
assert(val[1]).equalTo('a');
|
|
216
|
+
assert(val[2]).equalTo(false);
|
|
218
217
|
});
|
|
219
218
|
|
|
220
|
-
test.it('can pass object literal', function() {
|
|
221
|
-
execute(
|
|
219
|
+
test.it('can pass object literal', function*() {
|
|
220
|
+
let result = yield execute(
|
|
222
221
|
'return [typeof arguments[0], arguments[0].a]', {a: 'hello'})
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
assert(result[1]).equalTo('hello');
|
|
226
|
-
});
|
|
222
|
+
assert(result[0]).equalTo('object');
|
|
223
|
+
assert(result[1]).equalTo('hello');
|
|
227
224
|
});
|
|
228
225
|
|
|
229
|
-
test.it('WebElement arguments are passed as DOM elements', function() {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
.
|
|
226
|
+
test.it('WebElement arguments are passed as DOM elements', function*() {
|
|
227
|
+
let el = yield driver.findElement(By.tagName('div'));
|
|
228
|
+
let result =
|
|
229
|
+
yield execute('return arguments[0].tagName.toLowerCase();', el);
|
|
230
|
+
assert(result).equalTo('div');
|
|
233
231
|
});
|
|
234
232
|
|
|
235
|
-
test.it('can pass array containing object literals', function() {
|
|
236
|
-
execute('return arguments[0]', [{color: "red"}])
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
});
|
|
233
|
+
test.it('can pass array containing object literals', function*() {
|
|
234
|
+
let result = yield execute('return arguments[0]', [{color: "red"}]);
|
|
235
|
+
assert(result.length).equalTo(1);
|
|
236
|
+
assert(result[0].color).equalTo('red');
|
|
240
237
|
});
|
|
241
238
|
|
|
242
239
|
test.it('does not modify object literal parameters', function() {
|
|
243
240
|
var input = {color: 'red'};
|
|
244
|
-
execute('return arguments[0];', input).then(verifyJson(input));
|
|
241
|
+
return execute('return arguments[0];', input).then(verifyJson(input));
|
|
245
242
|
});
|
|
246
243
|
});
|
|
247
244
|
|
|
@@ -249,7 +246,7 @@ test.suite(function(env) {
|
|
|
249
246
|
describe('issue 8223;', function() {
|
|
250
247
|
describe('using for..in loops;', function() {
|
|
251
248
|
test.it('can return array built from for-loop index', function() {
|
|
252
|
-
execute(function() {
|
|
249
|
+
return execute(function() {
|
|
253
250
|
var ret = [];
|
|
254
251
|
for (var i = 0; i < 3; i++) {
|
|
255
252
|
ret.push(i);
|
|
@@ -259,7 +256,7 @@ test.suite(function(env) {
|
|
|
259
256
|
});
|
|
260
257
|
|
|
261
258
|
test.it('can copy input array contents', function() {
|
|
262
|
-
execute(function(input) {
|
|
259
|
+
return execute(function(input) {
|
|
263
260
|
var ret = [];
|
|
264
261
|
for (var i in input) {
|
|
265
262
|
ret.push(input[i]);
|
|
@@ -269,7 +266,7 @@ test.suite(function(env) {
|
|
|
269
266
|
});
|
|
270
267
|
|
|
271
268
|
test.it('can iterate over input object keys', function() {
|
|
272
|
-
execute(function(thing) {
|
|
269
|
+
return execute(function(thing) {
|
|
273
270
|
var ret = [];
|
|
274
271
|
for (var w in thing.words) {
|
|
275
272
|
ret.push(thing.words[w].word);
|
|
@@ -282,7 +279,7 @@ test.suite(function(env) {
|
|
|
282
279
|
describe('recursive functions;', function() {
|
|
283
280
|
test.it('can build array from input', function() {
|
|
284
281
|
var input = ['fa', 'fe', 'fi'];
|
|
285
|
-
execute(function(thearray) {
|
|
282
|
+
return execute(function(thearray) {
|
|
286
283
|
var ret = [];
|
|
287
284
|
function build_response(thearray, ret) {
|
|
288
285
|
ret.push(thearray.shift());
|
|
@@ -295,7 +292,7 @@ test.suite(function(env) {
|
|
|
295
292
|
|
|
296
293
|
test.it('can build array from elements in object', function() {
|
|
297
294
|
var input = {words: [{word: 'fa'}, {word: 'fe'}, {word: 'fi'}]};
|
|
298
|
-
execute(function(thing) {
|
|
295
|
+
return execute(function(thing) {
|
|
299
296
|
var ret = [];
|
|
300
297
|
function build_response(thing, ret) {
|
|
301
298
|
var item = thing.words.shift();
|
|
@@ -343,7 +340,7 @@ test.suite(function(env) {
|
|
|
343
340
|
|
|
344
341
|
function verifyJson(expected) {
|
|
345
342
|
return function(actual) {
|
|
346
|
-
assert(JSON.stringify(actual)).equalTo(JSON.stringify(expected));
|
|
343
|
+
return assert(JSON.stringify(actual)).equalTo(JSON.stringify(expected));
|
|
347
344
|
};
|
|
348
345
|
}
|
|
349
346
|
|
package/test/fingerprint_test.js
CHANGED
|
@@ -35,21 +35,26 @@ test.suite(function(env) {
|
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
describe('fingerprinting', function() {
|
|
38
|
-
test.it('it should fingerprint the navigator object', function() {
|
|
39
|
-
driver.get(Pages.simpleTestPage);
|
|
40
|
-
|
|
38
|
+
test.it('it should fingerprint the navigator object', function*() {
|
|
39
|
+
yield driver.get(Pages.simpleTestPage);
|
|
40
|
+
|
|
41
|
+
let wd = yield driver.executeScript('return navigator.webdriver');
|
|
42
|
+
assert(wd).equalTo(true);
|
|
41
43
|
});
|
|
42
44
|
|
|
43
|
-
test.it('fingerprint must not be writable', function() {
|
|
44
|
-
driver.get(Pages.simpleTestPage);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
.
|
|
45
|
+
test.it('fingerprint must not be writable', function*() {
|
|
46
|
+
yield driver.get(Pages.simpleTestPage);
|
|
47
|
+
|
|
48
|
+
let wd = yield driver.executeScript(
|
|
49
|
+
'navigator.webdriver = "ohai"; return navigator.webdriver');
|
|
50
|
+
assert(wd).equalTo(true);
|
|
48
51
|
});
|
|
49
52
|
|
|
50
|
-
test.it('leaves fingerprint on svg pages', function() {
|
|
51
|
-
driver.get(Pages.svgPage);
|
|
52
|
-
|
|
53
|
+
test.it('leaves fingerprint on svg pages', function*() {
|
|
54
|
+
yield driver.get(Pages.svgPage);
|
|
55
|
+
|
|
56
|
+
let wd = yield driver.executeScript('return navigator.webdriver');
|
|
57
|
+
assert(wd).equalTo(true);
|
|
53
58
|
});
|
|
54
59
|
});
|
|
55
60
|
|
|
@@ -44,11 +44,30 @@ test.suite(function(env) {
|
|
|
44
44
|
|
|
45
45
|
test.afterEach(function() {
|
|
46
46
|
if (driver) {
|
|
47
|
-
driver.quit();
|
|
47
|
+
return driver.quit();
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Runs a test that requires Firefox Developer Edition. The test will be
|
|
53
|
+
* skipped if dev cannot be found on the current system.
|
|
54
|
+
*/
|
|
55
|
+
function runWithFirefoxDev(options, testFn) {
|
|
56
|
+
let binary = new firefox.Binary();
|
|
57
|
+
binary.useDevEdition();
|
|
58
|
+
return binary.locate().then(exe => {
|
|
59
|
+
options.setBinary(exe);
|
|
60
|
+
driver = env.builder()
|
|
61
|
+
.setFirefoxOptions(options)
|
|
62
|
+
.build();
|
|
63
|
+
return driver.call(testFn);
|
|
64
|
+
}, err => {
|
|
65
|
+
console.warn(
|
|
66
|
+
'Skipping test: could not find Firefox Dev Edition: ' + err);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
test.it('can start Firefox with custom preferences', function*() {
|
|
52
71
|
var profile = new firefox.Profile();
|
|
53
72
|
profile.setPreference('general.useragent.override', 'foo;bar');
|
|
54
73
|
|
|
@@ -58,68 +77,72 @@ test.suite(function(env) {
|
|
|
58
77
|
setFirefoxOptions(options).
|
|
59
78
|
build();
|
|
60
79
|
|
|
61
|
-
driver.get('data:text/html,<html><div>content</div></html>');
|
|
80
|
+
yield driver.get('data:text/html,<html><div>content</div></html>');
|
|
62
81
|
|
|
63
|
-
var userAgent = driver.executeScript(
|
|
82
|
+
var userAgent = yield driver.executeScript(
|
|
64
83
|
'return window.navigator.userAgent');
|
|
65
84
|
assert(userAgent).equalTo('foo;bar');
|
|
66
85
|
});
|
|
67
86
|
|
|
68
87
|
test.it('can start Firefox with a jetpack extension', function() {
|
|
69
|
-
|
|
88
|
+
let profile = new firefox.Profile();
|
|
70
89
|
profile.addExtension(JETPACK_EXTENSION);
|
|
71
90
|
|
|
72
|
-
|
|
91
|
+
let options = new firefox.Options().setProfile(profile);
|
|
73
92
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
93
|
+
return runWithFirefoxDev(options, function*() {
|
|
94
|
+
yield loadJetpackPage(driver,
|
|
95
|
+
'data:text/html;charset=UTF-8,<html><div>content</div></html>');
|
|
77
96
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
97
|
+
let text =
|
|
98
|
+
yield driver.findElement({id: 'jetpack-sample-banner'}).getText();
|
|
99
|
+
assert(text).equalTo('Hello, world!');
|
|
100
|
+
});
|
|
82
101
|
});
|
|
83
102
|
|
|
84
103
|
test.it('can start Firefox with a normal extension', function() {
|
|
85
|
-
|
|
104
|
+
let profile = new firefox.Profile();
|
|
86
105
|
profile.addExtension(NORMAL_EXTENSION);
|
|
87
106
|
|
|
88
|
-
|
|
107
|
+
let options = new firefox.Options().setProfile(profile);
|
|
89
108
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
build();
|
|
109
|
+
return runWithFirefoxDev(options, function*() {
|
|
110
|
+
yield driver.get('data:text/html,<html><div>content</div></html>');
|
|
93
111
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
112
|
+
let footer =
|
|
113
|
+
yield driver.findElement({id: 'sample-extension-footer'});
|
|
114
|
+
let text = yield footer.getText();
|
|
115
|
+
assert(text).equalTo('Goodbye');
|
|
116
|
+
});
|
|
97
117
|
});
|
|
98
118
|
|
|
99
119
|
test.it('can start Firefox with multiple extensions', function() {
|
|
100
|
-
|
|
120
|
+
let profile = new firefox.Profile();
|
|
101
121
|
profile.addExtension(JETPACK_EXTENSION);
|
|
102
122
|
profile.addExtension(NORMAL_EXTENSION);
|
|
103
123
|
|
|
104
|
-
|
|
124
|
+
let options = new firefox.Options().setProfile(profile);
|
|
105
125
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
126
|
+
return runWithFirefoxDev(options, function*() {
|
|
127
|
+
yield loadJetpackPage(driver,
|
|
128
|
+
'data:text/html;charset=UTF-8,<html><div>content</div></html>');
|
|
129
|
+
|
|
130
|
+
let banner =
|
|
131
|
+
yield driver.findElement({id: 'jetpack-sample-banner'}).getText();
|
|
132
|
+
assert(banner).equalTo('Hello, world!');
|
|
109
133
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
.equalTo('Goodbye');
|
|
134
|
+
let footer =
|
|
135
|
+
yield driver.findElement({id: 'sample-extension-footer'})
|
|
136
|
+
.getText();
|
|
137
|
+
assert(footer).equalTo('Goodbye');
|
|
138
|
+
});
|
|
116
139
|
});
|
|
117
140
|
|
|
118
141
|
function loadJetpackPage(driver, url) {
|
|
119
142
|
// On linux the jetpack extension does not always run the first time
|
|
120
143
|
// we load a page. If this happens, just reload the page (a simple
|
|
121
144
|
// refresh doesn't appear to work).
|
|
122
|
-
driver.wait(function() {
|
|
145
|
+
return driver.wait(function() {
|
|
123
146
|
driver.get(url);
|
|
124
147
|
return driver.findElements({id: 'jetpack-sample-banner'})
|
|
125
148
|
.then(found => found.length > 0);
|
|
@@ -131,21 +154,21 @@ test.suite(function(env) {
|
|
|
131
154
|
var driver1, driver2;
|
|
132
155
|
|
|
133
156
|
test.ignore(env.isRemote).
|
|
134
|
-
it('can start multiple sessions with single binary instance', function() {
|
|
157
|
+
it('can start multiple sessions with single binary instance', function*() {
|
|
135
158
|
var options = new firefox.Options().setBinary(new firefox.Binary);
|
|
136
159
|
env.builder().setFirefoxOptions(options);
|
|
137
|
-
driver1 = env.builder().build();
|
|
138
|
-
driver2 = env.builder().build();
|
|
160
|
+
driver1 = yield env.builder().build();
|
|
161
|
+
driver2 = yield env.builder().build();
|
|
139
162
|
// Ok if this doesn't fail.
|
|
140
163
|
});
|
|
141
164
|
|
|
142
|
-
test.afterEach(function() {
|
|
165
|
+
test.afterEach(function*() {
|
|
143
166
|
if (driver1) {
|
|
144
|
-
driver1.quit();
|
|
167
|
+
yield driver1.quit();
|
|
145
168
|
}
|
|
146
169
|
|
|
147
170
|
if (driver2) {
|
|
148
|
-
driver2.quit();
|
|
171
|
+
yield driver2.quit();
|
|
149
172
|
}
|
|
150
173
|
});
|
|
151
174
|
});
|
|
@@ -153,32 +176,35 @@ test.suite(function(env) {
|
|
|
153
176
|
describe('context switching', function() {
|
|
154
177
|
var driver;
|
|
155
178
|
|
|
156
|
-
test.beforeEach(function() {
|
|
157
|
-
driver = env.builder().build();
|
|
179
|
+
test.beforeEach(function*() {
|
|
180
|
+
driver = yield env.builder().build();
|
|
158
181
|
});
|
|
159
182
|
|
|
160
183
|
test.afterEach(function() {
|
|
161
184
|
if (driver) {
|
|
162
|
-
driver.quit();
|
|
185
|
+
return driver.quit();
|
|
163
186
|
}
|
|
164
187
|
});
|
|
165
188
|
|
|
166
189
|
test.ignore(() => !env.isMarionette).
|
|
167
190
|
it('can get context', function() {
|
|
168
|
-
assert(driver.getContext()).equalTo(Context.CONTENT);
|
|
191
|
+
return assert(driver.getContext()).equalTo(Context.CONTENT);
|
|
169
192
|
});
|
|
170
193
|
|
|
171
194
|
test.ignore(() => !env.isMarionette).
|
|
172
|
-
it('can set context', function() {
|
|
173
|
-
driver.setContext(Context.CHROME);
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
195
|
+
it('can set context', function*() {
|
|
196
|
+
yield driver.setContext(Context.CHROME);
|
|
197
|
+
let ctxt = yield driver.getContext();
|
|
198
|
+
assert(ctxt).equalTo(Context.CHROME);
|
|
199
|
+
|
|
200
|
+
yield driver.setContext(Context.CONTENT);
|
|
201
|
+
ctxt = yield driver.getContext();
|
|
202
|
+
assert(ctxt).equalTo(Context.CONTENT);
|
|
177
203
|
});
|
|
178
204
|
|
|
179
205
|
test.ignore(() => !env.isMarionette).
|
|
180
206
|
it('throws on unknown context', function() {
|
|
181
|
-
driver.setContext("foo").then(assert.fail, function(e) {
|
|
207
|
+
return driver.setContext("foo").then(assert.fail, function(e) {
|
|
182
208
|
assert(e).instanceOf(error.InvalidArgumentError);
|
|
183
209
|
});
|
|
184
210
|
});
|
|
@@ -26,8 +26,7 @@ var promise = require('../..').promise,
|
|
|
26
26
|
Profile = require('../../firefox/profile').Profile,
|
|
27
27
|
decode = require('../../firefox/profile').decode,
|
|
28
28
|
loadUserPrefs = require('../../firefox/profile').loadUserPrefs,
|
|
29
|
-
io = require('../../io')
|
|
30
|
-
it = require('../../testing').it;
|
|
29
|
+
io = require('../../io');
|
|
31
30
|
|
|
32
31
|
|
|
33
32
|
var JETPACK_EXTENSION = path.join(__dirname,
|
|
@@ -53,7 +52,6 @@ describe('Profile', function() {
|
|
|
53
52
|
|
|
54
53
|
it('allows overriding mutable properties', function() {
|
|
55
54
|
var profile = new Profile();
|
|
56
|
-
assert.equal('about:blank', profile.getPreference('browser.newtab.url'));
|
|
57
55
|
|
|
58
56
|
profile.setPreference('browser.newtab.url', 'http://www.example.com');
|
|
59
57
|
assert.equal('http://www.example.com',
|