From bd65bb67e25a79b019d745b7262b2008ce2adb15 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 16 Nov 2016 01:59:39 +0100 Subject: incrementally verify denoms The denominations are not stored in a separate object store. --- node_modules/selenium-webdriver/firefox/binary.js | 17 ++++ node_modules/selenium-webdriver/firefox/index.js | 103 ++++++++++++--------- node_modules/selenium-webdriver/firefox/profile.js | 27 +++++- 3 files changed, 100 insertions(+), 47 deletions(-) (limited to 'node_modules/selenium-webdriver/firefox') 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 @@ -181,6 +181,15 @@ class Binary { this.devEdition_ = false; } + /** + * @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.)} var_args Either the arguments to add @@ -196,6 +205,14 @@ class Binary { } } + /** + * @return {!Array} 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 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} Current context. + * @return {!promise.Thenable} Current context. */ getContext() { return this.schedule( @@ -657,7 +672,7 @@ class Driver extends webdriver.WebDriver { * * Use your powers wisely. * - * @param {!promise.Promise} ctx The context to switch to. + * @param {!promise.Thenable} 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; @@ -217,6 +214,14 @@ class Profile { this.extensions_ = []; } + /** + * @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 @@ -226,6 +231,13 @@ class Profile { this.extensions_.push(extension); } + /** + * @return {!Array} 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. @@ -254,6 +266,13 @@ class Profile { return this.preferences_[key]; } + /** + * @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 @@ -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. -- cgit v1.2.3