aboutsummaryrefslogtreecommitdiff
path: root/node_modules/selenium-webdriver/firefox
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-11-16 01:59:39 +0100
committerFlorian Dold <florian.dold@gmail.com>2016-11-16 02:00:31 +0100
commitbd65bb67e25a79b019d745b7262b2008ce2adb15 (patch)
tree89e1b032103a63737f1a703e6a943832ef261704 /node_modules/selenium-webdriver/firefox
parentf91466595b651721690133f58ab37f977539e95b (diff)
incrementally verify denoms
The denominations are not stored in a separate object store.
Diffstat (limited to 'node_modules/selenium-webdriver/firefox')
-rw-r--r--node_modules/selenium-webdriver/firefox/binary.js17
-rw-r--r--node_modules/selenium-webdriver/firefox/index.js103
-rw-r--r--node_modules/selenium-webdriver/firefox/profile.js27
3 files changed, 100 insertions, 47 deletions
diff --git a/node_modules/selenium-webdriver/firefox/binary.js b/node_modules/selenium-webdriver/firefox/binary.js
index f31440b4e..b997b480d 100644
--- a/node_modules/selenium-webdriver/firefox/binary.js
+++ b/node_modules/selenium-webdriver/firefox/binary.js
@@ -182,6 +182,15 @@ class Binary {
}
/**
+ * @return {(string|undefined)} The path to the Firefox executable to use, or
+ * `undefined` if WebDriver should attempt to locate Firefox automatically
+ * on the current system.
+ */
+ getExe() {
+ return this.exe_;
+ }
+
+ /**
* Add arguments to the command line used to start Firefox.
* @param {...(string|!Array.<string>)} var_args Either the arguments to add
* as varargs, or the arguments as an array.
@@ -197,6 +206,14 @@ class Binary {
}
/**
+ * @return {!Array<string>} The command line arguments to use when starting
+ * the browser.
+ */
+ getArguments() {
+ return this.args_;
+ }
+
+ /**
* Specifies whether to use Firefox Developer Edition instead of the normal
* stable channel. Setting this option has no effect if this instance was
* created with a path to a specific Firefox binary.
diff --git a/node_modules/selenium-webdriver/firefox/index.js b/node_modules/selenium-webdriver/firefox/index.js
index 0adc97093..4ea1702a9 100644
--- a/node_modules/selenium-webdriver/firefox/index.js
+++ b/node_modules/selenium-webdriver/firefox/index.js
@@ -440,7 +440,11 @@ class ServiceBuilder extends remote.DriverService.Builder {
/**
- * @typedef {{driver: !webdriver.WebDriver, onQuit: function()}}
+ * @typedef {{executor: !command.Executor,
+ * capabilities: (!capabilities.Capabilities|
+ * {desired: (capabilities.Capabilities|undefined),
+ * required: (capabilities.Capabilities|undefined)}),
+ * onQuit: function(this: void): ?}}
*/
var DriverSpec;
@@ -450,13 +454,37 @@ var DriverSpec;
* @param {!capabilities.Capabilities} caps
* @param {Profile} profile
* @param {Binary} binary
- * @param {(promise.ControlFlow|undefined)} flow
* @return {DriverSpec}
*/
-function createGeckoDriver(
- executor, caps, profile, binary, flow) {
+function createGeckoDriver(executor, caps, profile, binary) {
+ let firefoxOptions = {};
+ caps.set('moz:firefoxOptions', firefoxOptions);
+
+ if (binary) {
+ if (binary.getExe()) {
+ firefoxOptions['binary'] = binary.getExe();
+ }
+
+ let args = binary.getArguments();
+ if (args.length) {
+ firefoxOptions['args'] = args;
+ }
+ }
+
if (profile) {
- caps.set(Capability.PROFILE, profile.encode());
+ // If the user specified a template directory or any extensions to install,
+ // we need to encode the profile as a base64 string (which requires writing
+ // it to disk first). Otherwise, if the user just specified some custom
+ // preferences, we can send those directly.
+ if (profile.getTemplateDir() || profile.getExtensions().length) {
+ firefoxOptions['profile'] = profile.encode();
+
+ } else {
+ let prefs = profile.getPreferences();
+ if (Object.keys(prefs).length) {
+ firefoxOptions['prefs'] = prefs;
+ }
+ }
}
let sessionCaps = caps;
@@ -473,7 +501,7 @@ function createGeckoDriver(
sessionCaps = {required, desired: caps};
}
- /** @type {(command.Executor|undefined)} */
+ /** @type {!command.Executor} */
let cmdExecutor;
let onQuit = function() {};
@@ -493,12 +521,11 @@ function createGeckoDriver(
onQuit = () => service.kill();
}
- let driver =
- webdriver.WebDriver.createSession(
- /** @type {!http.Executor} */(cmdExecutor),
- sessionCaps,
- flow);
- return {driver, onQuit};
+ return {
+ executor: cmdExecutor,
+ capabilities: sessionCaps,
+ onQuit
+ };
}
@@ -506,7 +533,6 @@ function createGeckoDriver(
* @param {!capabilities.Capabilities} caps
* @param {Profile} profile
* @param {!Binary} binary
- * @param {(promise.ControlFlow|undefined)} flow
* @return {DriverSpec}
*/
function createLegacyDriver(caps, profile, binary, flow) {
@@ -529,18 +555,18 @@ function createLegacyDriver(caps, profile, binary, flow) {
return ready.then(() => serverUrl);
});
- let onQuit = function() {
- return command.then(command => {
- command.kill();
- return preparedProfile.then(io.rmDir)
- .then(() => command.result(),
- () => command.result());
- });
+ return {
+ executor: createExecutor(serverUrl),
+ capabilities: caps,
+ onQuit: function() {
+ return command.then(command => {
+ command.kill();
+ return preparedProfile.then(io.rmDir)
+ .then(() => command.result(),
+ () => command.result());
+ });
+ }
};
-
- let executor = createExecutor(serverUrl);
- let driver = webdriver.WebDriver.createSession(executor, caps, flow);
- return {driver, onQuit};
}
@@ -549,6 +575,8 @@ function createLegacyDriver(caps, profile, binary, flow) {
*/
class Driver extends webdriver.WebDriver {
/**
+ * Creates a new Firefox session.
+ *
* @param {(Options|capabilities.Capabilities|Object)=} opt_config The
* configuration options for this driver, specified as either an
* {@link Options} or {@link capabilities.Capabilities}, or as a raw hash
@@ -569,8 +597,9 @@ class Driver extends webdriver.WebDriver {
* schedule commands through. Defaults to the active flow object.
* @throws {Error} If a custom command executor is provided and the driver is
* configured to use the legacy FirefoxDriver from the Selenium project.
+ * @return {!Driver} A new driver instance.
*/
- constructor(opt_config, opt_executor, opt_flow) {
+ static createSession(opt_config, opt_executor, opt_flow) {
let caps;
if (opt_config instanceof Options) {
caps = opt_config.toCapabilities();
@@ -578,7 +607,6 @@ class Driver extends webdriver.WebDriver {
caps = new capabilities.Capabilities(opt_config);
}
- let hasBinary = caps.has(Capability.BINARY);
let binary = caps.get(Capability.BINARY) || new Binary();
caps.delete(Capability.BINARY);
if (typeof binary === 'string') {
@@ -591,8 +619,6 @@ class Driver extends webdriver.WebDriver {
caps.delete(Capability.PROFILE);
}
- let serverUrl, onQuit;
-
// Users must now explicitly disable marionette to use the legacy
// FirefoxDriver.
let noMarionette =
@@ -602,12 +628,7 @@ class Driver extends webdriver.WebDriver {
let spec;
if (useMarionette) {
- spec = createGeckoDriver(
- opt_executor,
- caps,
- profile,
- hasBinary ? binary : null,
- opt_flow);
+ spec = createGeckoDriver(opt_executor, caps, profile, binary);
} else {
if (opt_executor) {
throw Error('You may not use a custom command executor with the legacy'
@@ -616,14 +637,8 @@ class Driver extends webdriver.WebDriver {
spec = createLegacyDriver(caps, profile, binary, opt_flow);
}
- super(spec.driver.getSession(),
- spec.driver.getExecutor(),
- spec.driver.controlFlow());
-
- /** @override */
- this.quit = () => {
- return super.quit().finally(spec.onQuit);
- };
+ return /** @type {!Driver} */(webdriver.WebDriver.createSession(
+ spec.executor, spec.capabilities, opt_flow, this, spec.onQuit));
}
/**
@@ -637,7 +652,7 @@ class Driver extends webdriver.WebDriver {
/**
* Get the context that is currently in effect.
*
- * @return {!promise.Promise<Context>} Current context.
+ * @return {!promise.Thenable<Context>} Current context.
*/
getContext() {
return this.schedule(
@@ -657,7 +672,7 @@ class Driver extends webdriver.WebDriver {
*
* Use your powers wisely.
*
- * @param {!promise.Promise<void>} ctx The context to switch to.
+ * @param {!promise.Thenable<void>} ctx The context to switch to.
*/
setContext(ctx) {
return this.schedule(
diff --git a/node_modules/selenium-webdriver/firefox/profile.js b/node_modules/selenium-webdriver/firefox/profile.js
index b6b39086c..b7f6363f9 100644
--- a/node_modules/selenium-webdriver/firefox/profile.js
+++ b/node_modules/selenium-webdriver/firefox/profile.js
@@ -201,9 +201,6 @@ class Profile {
/** @private {!Object} */
this.preferences_ = {};
- Object.assign(this.preferences_, getDefaultPreferences()['mutable']);
- Object.assign(this.preferences_, getDefaultPreferences()['frozen']);
-
/** @private {boolean} */
this.nativeEventsEnabled_ = true;
@@ -218,6 +215,14 @@ class Profile {
}
/**
+ * @return {(string|undefined)} Path to an existing Firefox profile directory
+ * to use as a template when writing this Profile to disk.
+ */
+ getTemplateDir() {
+ return this.template_;
+ }
+
+ /**
* Registers an extension to be included with this profile.
* @param {string} extension Path to the extension to include, as either an
* unpacked extension directory or the path to a xpi file.
@@ -227,6 +232,13 @@ class Profile {
}
/**
+ * @return {!Array<string>} A list of extensions to install in this profile.
+ */
+ getExtensions() {
+ return this.extensions_;
+ }
+
+ /**
* Sets a desired preference for this profile.
* @param {string} key The preference key.
* @param {(string|number|boolean)} value The preference value.
@@ -255,6 +267,13 @@ class Profile {
}
/**
+ * @return {!Object} A copy of all currently configured preferences.
+ */
+ getPreferences() {
+ return Object.assign({}, this.preferences_);
+ }
+
+ /**
* Specifies which host the driver should listen for commands on. If not
* specified, the driver will default to "localhost". This option should be
* specified when "localhost" is not mapped to the loopback address
@@ -353,6 +372,8 @@ class Profile {
// Freeze preferences for async operations.
var prefs = {};
+ Object.assign(prefs, getDefaultPreferences()['mutable']);
+ Object.assign(prefs, getDefaultPreferences()['frozen']);
Object.assign(prefs, this.preferences_);
// Freeze extensions for async operations.