selenium-webdriver 3.3.0 → 4.0.0-alpha.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 +273 -0
- package/NOTICE +1 -1
- package/README.md +28 -36
- package/chrome.js +221 -146
- package/edge.js +43 -118
- package/example/chrome_android.js +8 -9
- package/example/chrome_mobile_emulation.js +9 -10
- package/example/firefox_channels.js +23 -19
- package/example/google_search.js +3 -3
- package/example/google_search_test.js +39 -27
- package/example/headless.js +55 -0
- package/example/logging.js +40 -7
- package/firefox.js +769 -0
- package/http/index.js +41 -4
- package/http/util.js +11 -6
- package/ie.js +57 -98
- package/index.js +182 -115
- package/io/index.js +59 -0
- package/io/zip.js +214 -0
- package/jasmine.json +11 -0
- package/lib/actions.js +68 -63
- package/lib/atoms/get-attribute.js +9 -0
- package/lib/atoms/is-displayed.js +73 -78
- package/lib/by.js +9 -1
- package/lib/capabilities.js +303 -201
- package/lib/command.js +28 -50
- package/lib/error.js +113 -42
- package/lib/http.js +167 -135
- package/lib/input.js +1044 -8
- package/lib/promise.js +222 -3331
- package/lib/proxy.js +134 -39
- package/lib/test/bootstrap_jasmine.js +28 -0
- package/lib/test/data/actions/click.html +24 -0
- package/lib/test/data/actions/drag.html +77 -0
- package/lib/test/data/actions/record_click.html +21 -0
- package/lib/test/data/chrome/download.html +2 -0
- package/lib/test/data/click_tests/disabled_element.html +12 -0
- package/lib/test/data/content-editable.html +10 -0
- package/lib/test/data/firefox/webextension.xpi +0 -0
- package/lib/test/data/inputs.html +42 -0
- package/lib/test/data/key_logger.html +34 -0
- package/lib/test/data/nestedElements.html +10 -1
- package/lib/test/data/scrolling_tests/page_with_partially_hidden_element.html +14 -0
- package/lib/test/data/selectPage.html +12 -0
- package/lib/test/data/simpleTest.html +5 -0
- package/lib/test/data/single_text_input.html +12 -0
- package/lib/test/data/upload_invisible.html +45 -0
- package/lib/test/fileserver.js +23 -19
- package/lib/test/index.js +30 -244
- package/lib/test/resources.js +0 -1
- package/lib/webdriver.js +770 -939
- package/net/index.js +21 -25
- package/net/portprober.js +51 -68
- package/package.json +6 -4
- package/remote/index.js +18 -30
- package/safari.js +42 -129
- package/test/actions_test.js +173 -18
- package/test/builder_test.js +106 -0
- package/test/chrome/devtools_test.js +93 -0
- package/test/chrome/options_test.js +48 -154
- package/test/chrome/service_test.js +7 -7
- package/test/cookie_test.js +77 -63
- package/test/element_finding_test.js +206 -201
- package/test/execute_script_test.js +115 -114
- package/test/fingerprint_test.js +16 -15
- package/test/firefox_test.js +251 -0
- package/test/http/http_test.js +18 -1
- package/test/http/util_test.js +2 -2
- package/test/{io_test.js → io/io_test.js} +40 -1
- package/test/io/zip_test.js +127 -0
- package/test/lib/by_test.js +21 -0
- package/test/lib/error_test.js +55 -8
- package/test/lib/http_test.js +18 -130
- package/test/lib/input_test.js +1379 -0
- package/test/lib/promise_test.js +473 -908
- package/test/lib/webdriver_test.js +357 -825
- package/test/logging_test.js +37 -43
- package/test/page_loading_test.js +70 -86
- package/test/proxy_test.js +64 -72
- package/test/rect_test.js +14 -25
- package/test/remote_test.js +13 -32
- package/test/safari_test.js +7 -71
- package/test/stale_element_test.js +20 -23
- package/test/tag_name_test.js +10 -9
- package/test/upload_test.js +27 -35
- package/test/window_test.js +72 -85
- package/testing/index.js +386 -315
- package/.npmignore +0 -2
- package/example/async_await_test.js +0 -68
- package/example/google_search_generator.js +0 -50
- package/example/parallel_flows.js +0 -54
- package/firefox/binary.js +0 -344
- package/firefox/extension.js +0 -187
- package/firefox/index.js +0 -722
- package/firefox/profile.js +0 -430
- package/lib/atoms/getAttribute.js +0 -12
- package/lib/events.js +0 -210
- package/lib/firefox/webdriver.json +0 -70
- package/lib/firefox/webdriver.xpi +0 -0
- package/lib/test/data/firefox/jetpack-sample.xpi +0 -0
- package/lib/test/data/firefox/sample.xpi +0 -0
- package/lib/test/promise.js +0 -79
- package/opera.js +0 -405
- package/phantomjs.js +0 -282
- package/test/firefox/extension_test.js +0 -96
- package/test/firefox/firefox_test.js +0 -226
- package/test/firefox/profile_test.js +0 -185
- package/test/lib/events_test.js +0 -177
- package/test/lib/promise_aplus_test.js +0 -78
- package/test/lib/promise_error_test.js +0 -884
- package/test/lib/promise_flow_test.js +0 -2288
- package/test/lib/promise_generator_test.js +0 -310
- package/test/phantomjs/execute_phantomjs_test.js +0 -59
- package/test/session_test.js +0 -54
- package/test/testing/assert_test.js +0 -373
- package/test/testing/index_test.js +0 -224
- package/testing/assert.js +0 -378
package/firefox/profile.js
DELETED
|
@@ -1,430 +0,0 @@
|
|
|
1
|
-
// Licensed to the Software Freedom Conservancy (SFC) under one
|
|
2
|
-
// or more contributor license agreements. See the NOTICE file
|
|
3
|
-
// distributed with this work for additional information
|
|
4
|
-
// regarding copyright ownership. The SFC licenses this file
|
|
5
|
-
// to you under the Apache License, Version 2.0 (the
|
|
6
|
-
// "License"); you may not use this file except in compliance
|
|
7
|
-
// with the License. You may obtain a copy of the License at
|
|
8
|
-
//
|
|
9
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
//
|
|
11
|
-
// Unless required by applicable law or agreed to in writing,
|
|
12
|
-
// software distributed under the License is distributed on an
|
|
13
|
-
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
-
// KIND, either express or implied. See the License for the
|
|
15
|
-
// specific language governing permissions and limitations
|
|
16
|
-
// under the License.
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @fileoverview Profile management module. This module is considered internal;
|
|
20
|
-
* users should use {@link selenium-webdriver/firefox}.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
'use strict';
|
|
24
|
-
|
|
25
|
-
const AdmZip = require('adm-zip'),
|
|
26
|
-
fs = require('fs'),
|
|
27
|
-
path = require('path'),
|
|
28
|
-
vm = require('vm');
|
|
29
|
-
|
|
30
|
-
const isDevMode = require('../lib/devmode'),
|
|
31
|
-
Symbols = require('../lib/symbols'),
|
|
32
|
-
io = require('../io'),
|
|
33
|
-
extension = require('./extension');
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
/** @const */
|
|
37
|
-
const WEBDRIVER_PREFERENCES_PATH = isDevMode
|
|
38
|
-
? path.join(__dirname, '../../../firefox-driver/webdriver.json')
|
|
39
|
-
: path.join(__dirname, '../lib/firefox/webdriver.json');
|
|
40
|
-
|
|
41
|
-
/** @const */
|
|
42
|
-
const WEBDRIVER_EXTENSION_PATH = isDevMode
|
|
43
|
-
? path.join(__dirname,
|
|
44
|
-
'../../../../build/javascript/firefox-driver/webdriver.xpi')
|
|
45
|
-
: path.join(__dirname, '../lib/firefox/webdriver.xpi');
|
|
46
|
-
|
|
47
|
-
/** @const */
|
|
48
|
-
const WEBDRIVER_EXTENSION_NAME = 'fxdriver@googlecode.com';
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
/** @type {Object} */
|
|
53
|
-
var defaultPreferences = null;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Synchronously loads the default preferences used for the FirefoxDriver.
|
|
57
|
-
* @return {!Object} The default preferences JSON object.
|
|
58
|
-
*/
|
|
59
|
-
function getDefaultPreferences() {
|
|
60
|
-
if (!defaultPreferences) {
|
|
61
|
-
var contents = /** @type {string} */(
|
|
62
|
-
fs.readFileSync(WEBDRIVER_PREFERENCES_PATH, 'utf8'));
|
|
63
|
-
defaultPreferences = /** @type {!Object} */(JSON.parse(contents));
|
|
64
|
-
}
|
|
65
|
-
return defaultPreferences;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Parses a user.js file in a Firefox profile directory.
|
|
71
|
-
* @param {string} f Path to the file to parse.
|
|
72
|
-
* @return {!Promise<!Object>} A promise for the parsed preferences as
|
|
73
|
-
* a JSON object. If the file does not exist, an empty object will be
|
|
74
|
-
* returned.
|
|
75
|
-
*/
|
|
76
|
-
function loadUserPrefs(f) {
|
|
77
|
-
return io.read(f).then(
|
|
78
|
-
function onSuccess(contents) {
|
|
79
|
-
var prefs = {};
|
|
80
|
-
var context = vm.createContext({
|
|
81
|
-
'user_pref': function(key, value) {
|
|
82
|
-
prefs[key] = value;
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
vm.runInContext(contents.toString(), context, f);
|
|
86
|
-
return prefs;
|
|
87
|
-
},
|
|
88
|
-
function onError(err) {
|
|
89
|
-
if (err && err.code === 'ENOENT') {
|
|
90
|
-
return {};
|
|
91
|
-
}
|
|
92
|
-
throw err;
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* @param {!Object} prefs The default preferences to write. Will be
|
|
100
|
-
* overridden by user.js preferences in the template directory and the
|
|
101
|
-
* frozen preferences required by WebDriver.
|
|
102
|
-
* @param {string} dir Path to the directory write the file to.
|
|
103
|
-
* @return {!Promise<string>} A promise for the profile directory,
|
|
104
|
-
* to be fulfilled when user preferences have been written.
|
|
105
|
-
*/
|
|
106
|
-
function writeUserPrefs(prefs, dir) {
|
|
107
|
-
var userPrefs = path.join(dir, 'user.js');
|
|
108
|
-
return loadUserPrefs(userPrefs).then(function(overrides) {
|
|
109
|
-
Object.assign(prefs, overrides);
|
|
110
|
-
Object.assign(prefs, getDefaultPreferences()['frozen']);
|
|
111
|
-
|
|
112
|
-
var contents = Object.keys(prefs).map(function(key) {
|
|
113
|
-
return 'user_pref(' + JSON.stringify(key) + ', ' +
|
|
114
|
-
JSON.stringify(prefs[key]) + ');';
|
|
115
|
-
}).join('\n');
|
|
116
|
-
|
|
117
|
-
return new Promise((resolve, reject) => {
|
|
118
|
-
fs.writeFile(userPrefs, contents, function(err) {
|
|
119
|
-
err && reject(err) || resolve(dir);
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Installs a group of extensions in the given profile directory. If the
|
|
128
|
-
* WebDriver extension is not included in this set, the default version
|
|
129
|
-
* bundled with this package will be installed.
|
|
130
|
-
* @param {!Array.<string>} extensions The extensions to install, as a
|
|
131
|
-
* path to an unpacked extension directory or a path to a xpi file.
|
|
132
|
-
* @param {string} dir The profile directory to install to.
|
|
133
|
-
* @param {boolean=} opt_excludeWebDriverExt Whether to skip installation of
|
|
134
|
-
* the default WebDriver extension.
|
|
135
|
-
* @return {!Promise<string>} A promise for the main profile directory
|
|
136
|
-
* once all extensions have been installed.
|
|
137
|
-
*/
|
|
138
|
-
function installExtensions(extensions, dir, opt_excludeWebDriverExt) {
|
|
139
|
-
var hasWebDriver = !!opt_excludeWebDriverExt;
|
|
140
|
-
var next = 0;
|
|
141
|
-
var extensionDir = path.join(dir, 'extensions');
|
|
142
|
-
|
|
143
|
-
return new Promise(function(fulfill, reject) {
|
|
144
|
-
io.mkdir(extensionDir).then(installNext, reject);
|
|
145
|
-
|
|
146
|
-
function installNext() {
|
|
147
|
-
if (next >= extensions.length) {
|
|
148
|
-
if (hasWebDriver) {
|
|
149
|
-
fulfill(dir);
|
|
150
|
-
} else {
|
|
151
|
-
install(WEBDRIVER_EXTENSION_PATH);
|
|
152
|
-
}
|
|
153
|
-
} else {
|
|
154
|
-
install(extensions[next++]);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function install(ext) {
|
|
159
|
-
extension.install(ext, extensionDir).then(function(id) {
|
|
160
|
-
hasWebDriver = hasWebDriver || (id === WEBDRIVER_EXTENSION_NAME);
|
|
161
|
-
installNext();
|
|
162
|
-
}, reject);
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Decodes a base64 encoded profile.
|
|
170
|
-
* @param {string} data The base64 encoded string.
|
|
171
|
-
* @return {!Promise<string>} A promise for the path to the decoded profile
|
|
172
|
-
* directory.
|
|
173
|
-
*/
|
|
174
|
-
function decode(data) {
|
|
175
|
-
return io.tmpFile().then(function(file) {
|
|
176
|
-
var buf = new Buffer(data, 'base64');
|
|
177
|
-
return io.write(file, buf)
|
|
178
|
-
.then(io.tmpDir)
|
|
179
|
-
.then(function(dir) {
|
|
180
|
-
var zip = new AdmZip(file);
|
|
181
|
-
zip.extractAllTo(dir); // Sync only? Why?? :-(
|
|
182
|
-
return dir;
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Models a Firefox profile directory for use with the FirefoxDriver. The
|
|
191
|
-
* {@code Profile} directory uses an in-memory model until
|
|
192
|
-
* {@link #writeToDisk} or {@link #encode} is called.
|
|
193
|
-
*/
|
|
194
|
-
class Profile {
|
|
195
|
-
/**
|
|
196
|
-
* @param {string=} opt_dir Path to an existing Firefox profile directory to
|
|
197
|
-
* use a template for this profile. If not specified, a blank profile will
|
|
198
|
-
* be used.
|
|
199
|
-
*/
|
|
200
|
-
constructor(opt_dir) {
|
|
201
|
-
/** @private {!Object} */
|
|
202
|
-
this.preferences_ = {};
|
|
203
|
-
|
|
204
|
-
/** @private {boolean} */
|
|
205
|
-
this.nativeEventsEnabled_ = true;
|
|
206
|
-
|
|
207
|
-
/** @private {(string|undefined)} */
|
|
208
|
-
this.template_ = opt_dir;
|
|
209
|
-
|
|
210
|
-
/** @private {number} */
|
|
211
|
-
this.port_ = 0;
|
|
212
|
-
|
|
213
|
-
/** @private {!Array<string>} */
|
|
214
|
-
this.extensions_ = [];
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* @return {(string|undefined)} Path to an existing Firefox profile directory
|
|
219
|
-
* to use as a template when writing this Profile to disk.
|
|
220
|
-
*/
|
|
221
|
-
getTemplateDir() {
|
|
222
|
-
return this.template_;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Registers an extension to be included with this profile.
|
|
227
|
-
* @param {string} extension Path to the extension to include, as either an
|
|
228
|
-
* unpacked extension directory or the path to a xpi file.
|
|
229
|
-
*/
|
|
230
|
-
addExtension(extension) {
|
|
231
|
-
this.extensions_.push(extension);
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
/**
|
|
235
|
-
* @return {!Array<string>} A list of extensions to install in this profile.
|
|
236
|
-
*/
|
|
237
|
-
getExtensions() {
|
|
238
|
-
return this.extensions_;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Sets a desired preference for this profile.
|
|
243
|
-
* @param {string} key The preference key.
|
|
244
|
-
* @param {(string|number|boolean)} value The preference value.
|
|
245
|
-
* @throws {Error} If attempting to set a frozen preference.
|
|
246
|
-
*/
|
|
247
|
-
setPreference(key, value) {
|
|
248
|
-
var frozen = getDefaultPreferences()['frozen'];
|
|
249
|
-
if (frozen.hasOwnProperty(key) && frozen[key] !== value) {
|
|
250
|
-
throw Error('You may not set ' + key + '=' + JSON.stringify(value)
|
|
251
|
-
+ '; value is frozen for proper WebDriver functionality ('
|
|
252
|
-
+ key + '=' + JSON.stringify(frozen[key]) + ')');
|
|
253
|
-
}
|
|
254
|
-
this.preferences_[key] = value;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* Returns the currently configured value of a profile preference. This does
|
|
259
|
-
* not include any defaults defined in the profile's template directory user.js
|
|
260
|
-
* file (if a template were specified on construction).
|
|
261
|
-
* @param {string} key The desired preference.
|
|
262
|
-
* @return {(string|number|boolean|undefined)} The current value of the
|
|
263
|
-
* requested preference.
|
|
264
|
-
*/
|
|
265
|
-
getPreference(key) {
|
|
266
|
-
return this.preferences_[key];
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* @return {!Object} A copy of all currently configured preferences.
|
|
271
|
-
*/
|
|
272
|
-
getPreferences() {
|
|
273
|
-
return Object.assign({}, this.preferences_);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* Specifies which host the driver should listen for commands on. If not
|
|
278
|
-
* specified, the driver will default to "localhost". This option should be
|
|
279
|
-
* specified when "localhost" is not mapped to the loopback address
|
|
280
|
-
* (127.0.0.1) in `/etc/hosts`.
|
|
281
|
-
*
|
|
282
|
-
* @param {string} host the host the driver should listen for commands on
|
|
283
|
-
*/
|
|
284
|
-
setHost(host) {
|
|
285
|
-
this.preferences_['webdriver_firefox_allowed_hosts'] = host;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* @return {number} The port this profile is currently configured to use, or
|
|
290
|
-
* 0 if the port will be selected at random when the profile is written
|
|
291
|
-
* to disk.
|
|
292
|
-
*/
|
|
293
|
-
getPort() {
|
|
294
|
-
return this.port_;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* Sets the port to use for the WebDriver extension loaded by this profile.
|
|
299
|
-
* @param {number} port The desired port, or 0 to use any free port.
|
|
300
|
-
*/
|
|
301
|
-
setPort(port) {
|
|
302
|
-
this.port_ = port;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* @return {boolean} Whether the FirefoxDriver is configured to automatically
|
|
307
|
-
* accept untrusted SSL certificates.
|
|
308
|
-
*/
|
|
309
|
-
acceptUntrustedCerts() {
|
|
310
|
-
return !!this.preferences_['webdriver_accept_untrusted_certs'];
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* Sets whether the FirefoxDriver should automatically accept untrusted SSL
|
|
315
|
-
* certificates.
|
|
316
|
-
* @param {boolean} value .
|
|
317
|
-
*/
|
|
318
|
-
setAcceptUntrustedCerts(value) {
|
|
319
|
-
this.preferences_['webdriver_accept_untrusted_certs'] = !!value;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
* Sets whether to assume untrusted certificates come from untrusted issuers.
|
|
324
|
-
* @param {boolean} value .
|
|
325
|
-
*/
|
|
326
|
-
setAssumeUntrustedCertIssuer(value) {
|
|
327
|
-
this.preferences_['webdriver_assume_untrusted_issuer'] = !!value;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* @return {boolean} Whether to assume untrusted certs come from untrusted
|
|
332
|
-
* issuers.
|
|
333
|
-
*/
|
|
334
|
-
assumeUntrustedCertIssuer() {
|
|
335
|
-
return !!this.preferences_['webdriver_assume_untrusted_issuer'];
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
/**
|
|
339
|
-
* Sets whether to use native events with this profile.
|
|
340
|
-
* @param {boolean} enabled .
|
|
341
|
-
*/
|
|
342
|
-
setNativeEventsEnabled(enabled) {
|
|
343
|
-
this.nativeEventsEnabled_ = enabled;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
/**
|
|
347
|
-
* Returns whether native events are enabled in this profile.
|
|
348
|
-
* @return {boolean} .
|
|
349
|
-
*/
|
|
350
|
-
nativeEventsEnabled() {
|
|
351
|
-
return this.nativeEventsEnabled_;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
/**
|
|
355
|
-
* Writes this profile to disk.
|
|
356
|
-
* @param {boolean=} opt_excludeWebDriverExt Whether to exclude the WebDriver
|
|
357
|
-
* extension from the generated profile. Used to reduce the size of an
|
|
358
|
-
* {@link #encode() encoded profile} since the server will always install
|
|
359
|
-
* the extension itself.
|
|
360
|
-
* @return {!Promise<string>} A promise for the path to the new profile
|
|
361
|
-
* directory.
|
|
362
|
-
*/
|
|
363
|
-
writeToDisk(opt_excludeWebDriverExt) {
|
|
364
|
-
var profileDir = io.tmpDir();
|
|
365
|
-
if (this.template_) {
|
|
366
|
-
profileDir = profileDir.then(function(dir) {
|
|
367
|
-
return io.copyDir(
|
|
368
|
-
/** @type {string} */(this.template_),
|
|
369
|
-
dir, /(parent\.lock|lock|\.parentlock)/);
|
|
370
|
-
}.bind(this));
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
// Freeze preferences for async operations.
|
|
374
|
-
var prefs = {};
|
|
375
|
-
Object.assign(prefs, getDefaultPreferences()['mutable']);
|
|
376
|
-
Object.assign(prefs, getDefaultPreferences()['frozen']);
|
|
377
|
-
Object.assign(prefs, this.preferences_);
|
|
378
|
-
|
|
379
|
-
// Freeze extensions for async operations.
|
|
380
|
-
var extensions = this.extensions_.concat();
|
|
381
|
-
|
|
382
|
-
return profileDir.then(function(dir) {
|
|
383
|
-
return writeUserPrefs(prefs, dir);
|
|
384
|
-
}).then(function(dir) {
|
|
385
|
-
return installExtensions(extensions, dir, !!opt_excludeWebDriverExt);
|
|
386
|
-
});
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
/**
|
|
390
|
-
* Write profile to disk, compress its containing directory, and return
|
|
391
|
-
* it as a Base64 encoded string.
|
|
392
|
-
*
|
|
393
|
-
* @return {!Promise<string>} A promise for the encoded profile as
|
|
394
|
-
* Base64 string.
|
|
395
|
-
*
|
|
396
|
-
*/
|
|
397
|
-
encode() {
|
|
398
|
-
return this.writeToDisk(true).then(function(dir) {
|
|
399
|
-
var zip = new AdmZip();
|
|
400
|
-
zip.addLocalFolder(dir, '');
|
|
401
|
-
// Stored compression, see https://en.wikipedia.org/wiki/Zip_(file_format)
|
|
402
|
-
zip.getEntries().forEach(function(entry) {
|
|
403
|
-
entry.header.method = 0;
|
|
404
|
-
});
|
|
405
|
-
|
|
406
|
-
return io.tmpFile().then(function(file) {
|
|
407
|
-
zip.writeZip(file); // Sync! Why oh why :-(
|
|
408
|
-
return io.read(file);
|
|
409
|
-
});
|
|
410
|
-
}).then(function(data) {
|
|
411
|
-
return data.toString('base64');
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
/**
|
|
416
|
-
* Encodes this profile as a zipped, base64 encoded directory.
|
|
417
|
-
* @return {!Promise<string>} A promise for the encoded profile.
|
|
418
|
-
*/
|
|
419
|
-
[Symbols.serialize]() {
|
|
420
|
-
return this.encode();
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
// PUBLIC API
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
exports.Profile = Profile;
|
|
429
|
-
exports.decode = decode;
|
|
430
|
-
exports.loadUserPrefs = loadUserPrefs;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// GENERATED CODE - DO NOT EDIT
|
|
2
|
-
module.exports = function(){return function(){var aa="function"==typeof Object.defineProperties?Object.defineProperty:function(a,c,b){if(b.get||b.set)throw new TypeError("ES3 does not support getters and setters.");a!=Array.prototype&&a!=Object.prototype&&(a[c]=b.value)},ba="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global?global:this;
|
|
3
|
-
function e(a,c){if(c){for(var b=ba,d=a.split("."),f=0;f<d.length-1;f++){var h=d[f];h in b||(b[h]={});b=b[h]}d=d[d.length-1];f=b[d];h=c(f);h!=f&&null!=h&&aa(b,d,{configurable:!0,writable:!0,value:h})}}
|
|
4
|
-
e("String.prototype.repeat",function(a){return a?a:function(a){var b;if(null==this)throw new TypeError("The 'this' value for String.prototype.repeat must not be null or undefined");b=this+"";if(0>a||1342177279<a)throw new RangeError("Invalid count value");a|=0;for(var d="";a;)if(a&1&&(d+=b),a>>>=1)b+=b;return d}});e("Math.sign",function(a){return a?a:function(a){a=Number(a);return!a||isNaN(a)?a:0<a?1:-1}});var g=this;function l(a){return"string"==typeof a};function m(a,c){this.a=n[a]||p;this.message=c||"";var b=this.a.replace(/((?:^|\s+)[a-z])/g,function(a){return a.toUpperCase().replace(/^[\s\xa0]+/g,"")}),d=b.length-5;if(0>d||b.indexOf("Error",d)!=d)b+="Error";this.name=b;b=Error(this.message);b.name=this.name;this.stack=b.stack||""}
|
|
5
|
-
(function(){var a=Error;function c(){}c.prototype=a.prototype;m.b=a.prototype;m.prototype=new c;m.prototype.constructor=m;m.a=function(b,c,f){for(var h=Array(arguments.length-2),k=2;k<arguments.length;k++)h[k-2]=arguments[k];return a.prototype[c].apply(b,h)}})();var p="unknown error",n={15:"element not selectable",11:"element not visible"};n[31]=p;n[30]=p;n[24]="invalid cookie domain";n[29]="invalid element coordinates";n[12]="invalid element state";n[32]="invalid selector";n[51]="invalid selector";
|
|
6
|
-
n[52]="invalid selector";n[17]="javascript error";n[405]="unsupported operation";n[34]="move target out of bounds";n[27]="no such alert";n[7]="no such element";n[8]="no such frame";n[23]="no such window";n[28]="script timeout";n[33]="session not created";n[10]="stale element reference";n[21]="timeout";n[25]="unable to set cookie";n[26]="unexpected alert open";n[13]=p;n[9]="unknown command";m.prototype.toString=function(){return this.name+": "+this.message};var q=String.prototype.trim?function(a){return a.trim()}:function(a){return a.replace(/^[\s\xa0]+|[\s\xa0]+$/g,"")};
|
|
7
|
-
function r(a,c){for(var b=0,d=q(String(a)).split("."),f=q(String(c)).split("."),h=Math.max(d.length,f.length),k=0;!b&&k<h;k++){var S=d[k]||"",ja=f[k]||"",ka=RegExp("(\\d*)(\\D*)","g"),la=RegExp("(\\d*)(\\D*)","g");do{var t=ka.exec(S)||["","",""],u=la.exec(ja)||["","",""];if(0==t[0].length&&0==u[0].length)break;b=v(0==t[1].length?0:parseInt(t[1],10),0==u[1].length?0:parseInt(u[1],10))||v(0==t[2].length,0==u[2].length)||v(t[2],u[2])}while(!b)}return b}function v(a,c){return a<c?-1:a>c?1:0};var w;a:{var x=g.navigator;if(x){var y=x.userAgent;if(y){w=y;break a}}w=""}function z(a){return-1!=w.indexOf(a)};function ca(a,c){for(var b=a.length,d=l(a)?a.split(""):a,f=0;f<b;f++)f in d&&c.call(void 0,d[f],f,a)};function A(){return z("iPhone")&&!z("iPod")&&!z("iPad")};function B(){return z("Opera")||z("OPR")}function C(){return(z("Chrome")||z("CriOS"))&&!B()&&!z("Edge")};var D=B(),E=z("Trident")||z("MSIE"),F=z("Edge"),G=z("Gecko")&&!(-1!=w.toLowerCase().indexOf("webkit")&&!z("Edge"))&&!(z("Trident")||z("MSIE"))&&!z("Edge"),da=-1!=w.toLowerCase().indexOf("webkit")&&!z("Edge");function ea(){var a=w;if(G)return/rv\:([^\);]+)(\)|;)/.exec(a);if(F)return/Edge\/([\d\.]+)/.exec(a);if(E)return/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(a);if(da)return/WebKit\/(\S+)/.exec(a)}function H(){var a=g.document;return a?a.documentMode:void 0}
|
|
8
|
-
var I=function(){if(D&&g.opera){var a;var c=g.opera.version;try{a=c()}catch(b){a=c}return a}a="";(c=ea())&&(a=c?c[1]:"");return E&&(c=H(),null!=c&&c>parseFloat(a))?String(c):a}(),J={},K=g.document,L=K&&E?H()||("CSS1Compat"==K.compatMode?parseInt(I,10):5):void 0;!G&&!E||E&&9<=Number(L)||G&&(J["1.9.1"]||(J["1.9.1"]=0<=r(I,"1.9.1")));E&&(J["9"]||(J["9"]=0<=r(I,"9")));var fa=z("Firefox"),ga=A()||z("iPod"),ha=z("iPad"),M=z("Android")&&!(C()||z("Firefox")||B()||z("Silk")),ia=C(),N=z("Safari")&&!(C()||z("Coast")||B()||z("Edge")||z("Silk")||z("Android"))&&!(A()||z("iPad")||z("iPod"));var ma={SCRIPT:1,STYLE:1,HEAD:1,IFRAME:1,OBJECT:1},na={IMG:" ",BR:"\n"};function oa(a,c,b){if(!(a.nodeName in ma))if(3==a.nodeType)b?c.push(String(a.nodeValue).replace(/(\r\n|\r|\n)/g,"")):c.push(a.nodeValue);else if(a.nodeName in na)c.push(na[a.nodeName]);else for(a=a.firstChild;a;)oa(a,c,b),a=a.nextSibling};function O(a){return(a=a.exec(w))?a[1]:""}var pa=function(){if(fa)return O(/Firefox\/([0-9.]+)/);if(E||F||D)return I;if(ia)return O(/Chrome\/([0-9.]+)/);if(N&&!(A()||z("iPad")||z("iPod")))return O(/Version\/([0-9.]+)/);if(ga||ha){var a=/Version\/(\S+).*Mobile\/(\S+)/.exec(w);if(a)return a[1]+"."+a[2]}else if(M)return(a=O(/Android\s+([0-9.]+)/))?a:O(/Version\/([0-9.]+)/);return""}();var qa;function P(a){ra?qa(a):M?r(sa,a):r(pa,a)}var ra=function(){if(!G)return!1;var a=g.Components;if(!a)return!1;try{if(!a.classes)return!1}catch(f){return!1}var c=a.classes,a=a.interfaces,b=c["@mozilla.org/xpcom/version-comparator;1"].getService(a.nsIVersionComparator),d=c["@mozilla.org/xre/app-info;1"].getService(a.nsIXULAppInfo).version;qa=function(a){b.compare(d,""+a)};return!0}(),Q;if(M){var ta=/Android\s+([0-9\.]+)/.exec(w);Q=ta?ta[1]:"0"}else Q="0";
|
|
9
|
-
var sa=Q,ua=E&&!(8<=Number(L)),va=E&&!(9<=Number(L));M&&P(2.3);M&&P(4);N&&P(6);function R(a,c){c=c.toLowerCase();if("style"==c)return wa(a.style.cssText);if(ua&&"value"==c&&T(a,"INPUT"))return a.value;if(va&&!0===a[c])return String(a.getAttribute(c));var b=a.getAttributeNode(c);return b&&b.specified?b.value:null}var xa=/[;]+(?=(?:(?:[^"]*"){2})*[^"]*$)(?=(?:(?:[^']*'){2})*[^']*$)(?=(?:[^()]*\([^()]*\))*[^()]*$)/;
|
|
10
|
-
function wa(a){var c=[];ca(a.split(xa),function(a){var d=a.indexOf(":");0<d&&(a=[a.slice(0,d),a.slice(d+1)],2==a.length&&c.push(a[0].toLowerCase(),":",a[1],";"))});c=c.join("");return c=";"==c.charAt(c.length-1)?c:c+";"}function U(a,c){var b;ua&&"value"==c&&T(a,"OPTION")&&null===R(a,"value")?(b=[],oa(a,b,!1),b=b.join("")):b=a[c];return b}function T(a,c){return!!a&&1==a.nodeType&&(!c||a.tagName.toUpperCase()==c)}
|
|
11
|
-
function ya(a){return T(a,"OPTION")?!0:T(a,"INPUT")?(a=a.type.toLowerCase(),"checkbox"==a||"radio"==a):!1};var za={"class":"className",readonly:"readOnly"},V="async autofocus autoplay checked compact complete controls declare defaultchecked defaultselected defer disabled draggable ended formnovalidate hidden indeterminate iscontenteditable ismap itemscope loop multiple muted nohref noresize noshade novalidate nowrap open paused pubdate readonly required reversed scoped seamless seeking selected spellcheck truespeed willvalidate".split(" ");function Aa(a,c){var b=null,d=c.toLowerCase();if("style"==d)return(b=a.style)&&!l(b)&&(b=b.cssText),b;if(("selected"==d||"checked"==d)&&ya(a)){if(!ya(a))throw new m(15,"Element is not selectable");var b="selected",f=a.type&&a.type.toLowerCase();if("checkbox"==f||"radio"==f)b="checked";return U(a,b)?"true":null}var h=T(a,"A");if(T(a,"IMG")&&"src"==d||h&&"href"==d)return(b=R(a,d))&&(b=U(a,d)),b;if("spellcheck"==d){b=R(a,d);if(null!==b){if("false"==b.toLowerCase())return"false";if("true"==b.toLowerCase())return"true"}return U(a,
|
|
12
|
-
d)+""}h=za[c]||c;a:if(l(V))d=l(d)&&1==d.length?V.indexOf(d,0):-1;else{for(var k=0;k<V.length;k++)if(k in V&&V[k]===d){d=k;break a}d=-1}if(0<=d)return(b=null!==R(a,c)||U(a,h))?"true":null;try{f=U(a,h)}catch(S){}(d=null==f)||(d=typeof f,d="object"==d&&null!=f||"function"==d);d?b=R(a,c):b=f;return null!=b?b.toString():null}var W=["_"],X=g;W[0]in X||!X.execScript||X.execScript("var "+W[0]);for(var Y;W.length&&(Y=W.shift());){var Z;if(Z=!W.length)Z=void 0!==Aa;Z?X[Y]=Aa:X[Y]?X=X[Y]:X=X[Y]={}};; return this._.apply(null,arguments);}.apply({navigator:typeof window!='undefined'?window.navigator:null,document:typeof window!='undefined'?window.document:null}, arguments);};
|
package/lib/events.js
DELETED
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
// Licensed to the Software Freedom Conservancy (SFC) under one
|
|
2
|
-
// or more contributor license agreements. See the NOTICE file
|
|
3
|
-
// distributed with this work for additional information
|
|
4
|
-
// regarding copyright ownership. The SFC licenses this file
|
|
5
|
-
// to you under the Apache License, Version 2.0 (the
|
|
6
|
-
// "License"); you may not use this file except in compliance
|
|
7
|
-
// with the License. You may obtain a copy of the License at
|
|
8
|
-
//
|
|
9
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
//
|
|
11
|
-
// Unless required by applicable law or agreed to in writing,
|
|
12
|
-
// software distributed under the License is distributed on an
|
|
13
|
-
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
14
|
-
// KIND, either express or implied. See the License for the
|
|
15
|
-
// specific language governing permissions and limitations
|
|
16
|
-
// under the License.
|
|
17
|
-
|
|
18
|
-
'use strict';
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Describes an event listener registered on an {@linkplain EventEmitter}.
|
|
22
|
-
*/
|
|
23
|
-
class Listener {
|
|
24
|
-
/**
|
|
25
|
-
* @param {!Function} fn The actual listener function.
|
|
26
|
-
* @param {(Object|undefined)} scope The object in whose scope to invoke the
|
|
27
|
-
* listener.
|
|
28
|
-
* @param {boolean} oneshot Whether this listener should only be used once.
|
|
29
|
-
*/
|
|
30
|
-
constructor(fn, scope, oneshot) {
|
|
31
|
-
this.fn = fn;
|
|
32
|
-
this.scope = scope;
|
|
33
|
-
this.oneshot = oneshot;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
/** @type {!WeakMap<!EventEmitter, !Map<string, !Set<!Listener>>>} */
|
|
39
|
-
const EVENTS = new WeakMap;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Object that can emit events for others to listen for.
|
|
44
|
-
*/
|
|
45
|
-
class EventEmitter {
|
|
46
|
-
/**
|
|
47
|
-
* Fires an event and calls all listeners.
|
|
48
|
-
* @param {string} type The type of event to emit.
|
|
49
|
-
* @param {...*} var_args Any arguments to pass to each listener.
|
|
50
|
-
*/
|
|
51
|
-
emit(type, var_args) {
|
|
52
|
-
let events = EVENTS.get(this);
|
|
53
|
-
if (!events) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
let args = Array.prototype.slice.call(arguments, 1);
|
|
58
|
-
|
|
59
|
-
let listeners = events.get(type);
|
|
60
|
-
if (listeners) {
|
|
61
|
-
for (let listener of listeners) {
|
|
62
|
-
listener.fn.apply(listener.scope, args);
|
|
63
|
-
if (listener.oneshot) {
|
|
64
|
-
listeners.delete(listener);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Returns a mutable list of listeners for a specific type of event.
|
|
72
|
-
* @param {string} type The type of event to retrieve the listeners for.
|
|
73
|
-
* @return {!Set<!Listener>} The registered listeners for the given event
|
|
74
|
-
* type.
|
|
75
|
-
*/
|
|
76
|
-
listeners(type) {
|
|
77
|
-
let events = EVENTS.get(this);
|
|
78
|
-
if (!events) {
|
|
79
|
-
events = new Map;
|
|
80
|
-
EVENTS.set(this, events);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
let listeners = events.get(type);
|
|
84
|
-
if (!listeners) {
|
|
85
|
-
listeners = new Set;
|
|
86
|
-
events.set(type, listeners);
|
|
87
|
-
}
|
|
88
|
-
return listeners;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Registers a listener.
|
|
93
|
-
* @param {string} type The type of event to listen for.
|
|
94
|
-
* @param {!Function} fn The function to invoke when the event is fired.
|
|
95
|
-
* @param {Object=} opt_self The object in whose scope to invoke the listener.
|
|
96
|
-
* @param {boolean=} opt_oneshot Whether the listener should b (e removed after
|
|
97
|
-
* the first event is fired.
|
|
98
|
-
* @return {!EventEmitter} A self reference.
|
|
99
|
-
* @private
|
|
100
|
-
*/
|
|
101
|
-
addListener_(type, fn, opt_self, opt_oneshot) {
|
|
102
|
-
let listeners = this.listeners(type);
|
|
103
|
-
for (let listener of listeners) {
|
|
104
|
-
if (listener.fn === fn) {
|
|
105
|
-
return this;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
listeners.add(new Listener(fn, opt_self || undefined, !!opt_oneshot));
|
|
109
|
-
return this;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Registers a listener.
|
|
114
|
-
* @param {string} type The type of event to listen for.
|
|
115
|
-
* @param {!Function} fn The function to invoke when the event is fired.
|
|
116
|
-
* @param {Object=} opt_self The object in whose scope to invoke the listener.
|
|
117
|
-
* @return {!EventEmitter} A self reference.
|
|
118
|
-
*/
|
|
119
|
-
addListener(type, fn, opt_self) {
|
|
120
|
-
return this.addListener_(type, fn, opt_self, false);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Registers a one-time listener which will be called only the first time an
|
|
125
|
-
* event is emitted, after which it will be removed.
|
|
126
|
-
* @param {string} type The type of event to listen for.
|
|
127
|
-
* @param {!Function} fn The function to invoke when the event is fired.
|
|
128
|
-
* @param {Object=} opt_self The object in whose scope to invoke the listener.
|
|
129
|
-
* @return {!EventEmitter} A self reference.
|
|
130
|
-
*/
|
|
131
|
-
once(type, fn, opt_self) {
|
|
132
|
-
return this.addListener_(type, fn, opt_self, true);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* An alias for {@link #addListener() addListener()}.
|
|
137
|
-
* @param {string} type The type of event to listen for.
|
|
138
|
-
* @param {!Function} fn The function to invoke when the event is fired.
|
|
139
|
-
* @param {Object=} opt_self The object in whose scope to invoke the listener.
|
|
140
|
-
* @return {!EventEmitter} A self reference.
|
|
141
|
-
*/
|
|
142
|
-
on(type, fn, opt_self) {
|
|
143
|
-
return this.addListener(type, fn, opt_self);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Removes a previously registered event listener.
|
|
148
|
-
* @param {string} type The type of event to unregister.
|
|
149
|
-
* @param {!Function} listenerFn The handler function to remove.
|
|
150
|
-
* @return {!EventEmitter} A self reference.
|
|
151
|
-
*/
|
|
152
|
-
removeListener(type, listenerFn) {
|
|
153
|
-
if (typeof type !== 'string' || typeof listenerFn !== 'function') {
|
|
154
|
-
throw TypeError('invalid args: expected (string, function), got ('
|
|
155
|
-
+ (typeof type) + ', ' + (typeof listenerFn) + ')');
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
let events = EVENTS.get(this);
|
|
159
|
-
if (!events) {
|
|
160
|
-
return this;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
let listeners = events.get(type);
|
|
164
|
-
if (!listeners) {
|
|
165
|
-
return this;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
let match;
|
|
169
|
-
for (let listener of listeners) {
|
|
170
|
-
if (listener.fn === listenerFn) {
|
|
171
|
-
match = listener;
|
|
172
|
-
break;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
if (match) {
|
|
176
|
-
listeners.delete(match);
|
|
177
|
-
if (!listeners.size) {
|
|
178
|
-
events.delete(type);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
return this;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Removes all listeners for a specific type of event. If no event is
|
|
186
|
-
* specified, all listeners across all types will be removed.
|
|
187
|
-
* @param {string=} opt_type The type of event to remove listeners from.
|
|
188
|
-
* @return {!EventEmitter} A self reference.
|
|
189
|
-
*/
|
|
190
|
-
removeAllListeners(opt_type) {
|
|
191
|
-
let events = EVENTS.get(this);
|
|
192
|
-
if (events) {
|
|
193
|
-
if (typeof opt_type === 'string') {
|
|
194
|
-
events.delete(opt_type);
|
|
195
|
-
} else {
|
|
196
|
-
EVENTS.delete(this);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
return this;
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
// PUBLIC API
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
module.exports = {
|
|
208
|
-
EventEmitter: EventEmitter,
|
|
209
|
-
Listener: Listener
|
|
210
|
-
};
|