Skip to content

Commit

Permalink
[js] removing native support for the legacy firefox driver
Browse files Browse the repository at this point in the history
  • Loading branch information
jleyba committed Jul 3, 2017
1 parent 6e656b9 commit 3bc0c2b
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 235 deletions.
1 change: 0 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,6 @@ namespace :node do
" --resource=LICENSE:/LICENSE" <<
" --resource=NOTICE:/NOTICE" <<
" --resource=javascript/firefox-driver/webdriver.json:firefox/webdriver.json" <<
" --resource=build/javascript/firefox-driver/webdriver.xpi:firefox/webdriver.xpi" <<
" --resource=common/src/web/:test/data/" <<
" --exclude_resource=common/src/web/Bin" <<
" --exclude_resource=.gitignore" <<
Expand Down
15 changes: 15 additions & 0 deletions javascript/node/selenium-webdriver/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
## v.next

### Notice

Native support for Firefox 45 (ESR) has been removed. Users will have to connect
to a remote Selenium server that supports Firefox 45.

### Changes

* Removed native support for Firefox 46 and older.
- The `SELENIUM_MARIONETTE` enviornment variable no longer has an effect.
- `selenium-webdriver/firefox.Capability.MARIONETTE` is deprecated.
- `selenium-webdriver/firefox.Options#useGeckoDriver()` is deprecated and now a no-op.


## v3.4.0

### Notice
Expand Down
5 changes: 1 addition & 4 deletions javascript/node/selenium-webdriver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,13 @@ be placed on your system [PATH]. Apple's safaridriver is shipped with
Safari 10 for OS X El Capitan and macOS Sierra. You will need to enable Remote
Automation in the Develop menu of Safari 10 before testing.

> **NOTE:** Mozilla's [geckodriver] is only required for Firefox 47+.
> Everything you need for Firefox 38-46 is included with this package.

| Browser | Component |
| ----------------- | ---------------------------------- |
| Chrome | [chromedriver(.exe)][chrome] |
| Internet Explorer | [IEDriverServer.exe][release] |
| Edge | [MicrosoftWebDriver.msi][edge] |
| Firefox 47+ | [geckodriver(.exe)][geckodriver] |
| Firefox | [geckodriver(.exe)][geckodriver] |
| PhantomJS | [phantomjs(.exe)][phantomjs] |
| Opera | [operadriver(.exe)][opera] |
| Safari | [safaridriver] |
Expand Down
106 changes: 5 additions & 101 deletions javascript/node/selenium-webdriver/firefox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,6 @@
* .setFirefoxOptions(options)
* .build();
*
* __Testing Older Versions of Firefox__
*
* To test versions of Firefox prior to Firefox 47, you must disable the use of
* the geckodriver using the {@link Options} class.
*
* let options = new firefox.Options().useGeckoDriver(false);
*
* Alternatively, you may disable the geckodriver at runtime by setting the
* environment variable `SELENIUM_MARIONETTE=false`.
*
* [geckodriver release]: https://github.com/mozilla/geckodriver/releases/
* [PATH]: http://en.wikipedia.org/wiki/PATH_%28variable%29
*/
Expand Down Expand Up @@ -163,8 +153,8 @@ const Capability = {
BINARY: 'firefox_binary',

/**
* Specifies whether to use Mozilla's Marionette, or the legacy FirefoxDriver
* from the Selenium project. Defaults to false.
* @deprecated This will be removed in a future release. There is no
* replacement.
*/
MARIONETTE: 'marionette',

Expand Down Expand Up @@ -193,9 +183,6 @@ class Options {

/** @private {?capabilities.ProxyConfig} */
this.proxy_ = null;

/** @private {boolean} */
this.marionette_ = true;
}

/**
Expand Down Expand Up @@ -259,14 +246,10 @@ class Options {
}

/**
* Sets whether to use Mozilla's geckodriver to drive the browser. This option
* is enabled by default and required for Firefox 47+.
*
* @param {boolean} enable Whether to enable the geckodriver.
* @see https://github.com/mozilla/geckodriver
* @deprecated This method has been deprecated and will be removed in the next
* release. It is a no-op.
*/
useGeckoDriver(enable) {
this.marionette_ = enable;
return this;
}

Expand All @@ -289,7 +272,6 @@ class Options {
if (this.profile_) {
caps.set(Capability.PROFILE, this.profile_);
}
caps.set(Capability.MARIONETTE, this.marionette_);
return caps;
}
}
Expand Down Expand Up @@ -332,26 +314,6 @@ function findGeckoDriver() {
}


/**
* @param {(Profile|string)} profile The profile to prepare.
* @param {number} port The port the FirefoxDriver should listen on.
* @return {!Promise<string>} a promise for the path to the profile directory.
*/
function prepareProfile(profile, port) {
if (typeof profile === 'string') {
return decodeProfile(/** @type {string} */(profile)).then(dir => {
profile = new Profile(dir);
profile.setPreference('webdriver_firefox_port', port);
return profile.writeToDisk();
});
}

profile = profile || new Profile;
profile.setPreference('webdriver_firefox_port', port);
return profile.writeToDisk();
}


function normalizeProxyConfiguration(config) {
if ('manual' === config.proxyType) {
if (config.ftpProxy && !config.ftpProxyPort) {
Expand Down Expand Up @@ -556,47 +518,6 @@ function createGeckoDriver(executor, caps, profile, binary) {
}


/**
* @param {!capabilities.Capabilities} caps
* @param {Profile} profile
* @param {!Binary} binary
* @return {DriverSpec}
*/
function createLegacyDriver(caps, profile, binary, flow) {
profile = profile || new Profile;

let freePort = portprober.findFreePort();
let preparedProfile =
freePort.then(port => prepareProfile(profile, port));
let command = preparedProfile.then(dir => binary.launch(dir));

let serverUrl = command.then(() => freePort)
.then(function(/** number */port) {
let serverUrl = url.format({
protocol: 'http',
hostname: net.getLoopbackAddress(),
port: port + '',
pathname: '/hub'
});
let ready = httpUtil.waitForServer(serverUrl, 45 * 1000);
return ready.then(() => serverUrl);
});

return {
executor: createExecutor(serverUrl),
capabilities: caps,
onQuit: function() {
return command.then(command => {
command.kill();
return preparedProfile.then(io.rmDir)
.then(() => command.result(),
() => command.result());
});
}
};
}


/**
* A WebDriver client for Firefox.
*/
Expand Down Expand Up @@ -646,24 +567,7 @@ class Driver extends webdriver.WebDriver {
caps.delete(Capability.PROFILE);
}

// Users must now explicitly disable marionette to use the legacy
// FirefoxDriver.
let noMarionette =
caps.get(Capability.MARIONETTE) === false
|| /^0|false$/i.test(process.env['SELENIUM_MARIONETTE']);
let useMarionette = !noMarionette;

let spec;
if (useMarionette) {
spec = createGeckoDriver(opt_executor, caps, profile, binary);
} else {
if (opt_executor) {
throw Error('You may not use a custom command executor with the legacy'
+ ' FirefoxDriver');
}
spec = createLegacyDriver(caps, profile, binary, opt_flow);
}

let spec = createGeckoDriver(opt_executor, caps, profile, binary);
return /** @type {!Driver} */(webdriver.WebDriver.createSession(
spec.executor, spec.capabilities, opt_flow, this, spec.onQuit));
}
Expand Down
33 changes: 5 additions & 28 deletions javascript/node/selenium-webdriver/firefox/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,6 @@ const WEBDRIVER_PREFERENCES_PATH = isDevMode
? path.join(__dirname, '../../../firefox-driver/webdriver.json')
: path.join(__dirname, '../lib/firefox/webdriver.json');

/** @const */
const WEBDRIVER_EXTENSION_PATH = isDevMode
? path.join(__dirname,
'../../../../build/javascript/firefox-driver/webdriver.xpi')
: path.join(__dirname, '../lib/firefox/webdriver.xpi');

/** @const */
const WEBDRIVER_EXTENSION_NAME = 'fxdriver@googlecode.com';



/** @type {Object} */
var defaultPreferences = null;

Expand Down Expand Up @@ -130,13 +119,10 @@ function writeUserPrefs(prefs, dir) {
* @param {!Array.<string>} extensions The extensions to install, as a
* path to an unpacked extension directory or a path to a xpi file.
* @param {string} dir The profile directory to install to.
* @param {boolean=} opt_excludeWebDriverExt Whether to skip installation of
* the default WebDriver extension.
* @return {!Promise<string>} A promise for the main profile directory
* once all extensions have been installed.
*/
function installExtensions(extensions, dir, opt_excludeWebDriverExt) {
var hasWebDriver = !!opt_excludeWebDriverExt;
function installExtensions(extensions, dir) {
var next = 0;
var extensionDir = path.join(dir, 'extensions');

Expand All @@ -145,19 +131,14 @@ function installExtensions(extensions, dir, opt_excludeWebDriverExt) {

function installNext() {
if (next >= extensions.length) {
if (hasWebDriver) {
fulfill(dir);
} else {
install(WEBDRIVER_EXTENSION_PATH);
}
fulfill(dir);
} else {
install(extensions[next++]);
}
}

function install(ext) {
extension.install(ext, extensionDir).then(function(id) {
hasWebDriver = hasWebDriver || (id === WEBDRIVER_EXTENSION_NAME);
installNext();
}, reject);
}
Expand Down Expand Up @@ -353,14 +334,10 @@ class Profile {

/**
* Writes this profile to disk.
* @param {boolean=} opt_excludeWebDriverExt Whether to exclude the WebDriver
* extension from the generated profile. Used to reduce the size of an
* {@link #encode() encoded profile} since the server will always install
* the extension itself.
* @return {!Promise<string>} A promise for the path to the new profile
* directory.
*/
writeToDisk(opt_excludeWebDriverExt) {
writeToDisk() {
var profileDir = io.tmpDir();
if (this.template_) {
profileDir = profileDir.then(function(dir) {
Expand All @@ -382,7 +359,7 @@ class Profile {
return profileDir.then(function(dir) {
return writeUserPrefs(prefs, dir);
}).then(function(dir) {
return installExtensions(extensions, dir, !!opt_excludeWebDriverExt);
return installExtensions(extensions, dir);
});
}

Expand All @@ -395,7 +372,7 @@ class Profile {
*
*/
encode() {
return this.writeToDisk(true).then(function(dir) {
return this.writeToDisk().then(function(dir) {
var zip = new AdmZip();
zip.addLocalFolder(dir, '');
// Stored compression, see https://en.wikipedia.org/wiki/Zip_(file_format)
Expand Down
35 changes: 1 addition & 34 deletions javascript/node/selenium-webdriver/lib/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ var build = require('./build'),
fileserver = require('./fileserver');


const LEGACY_FIREFOX = 'legacy-' + webdriver.Browser.FIREFOX;


/**
* Browsers with native support.
* @type {!Array.<webdriver.Browser>}
Expand All @@ -42,7 +39,6 @@ var NATIVE_BROWSERS = [
webdriver.Browser.CHROME,
webdriver.Browser.EDGE,
webdriver.Browser.FIREFOX,
LEGACY_FIREFOX,
webdriver.Browser.IE,
webdriver.Browser.OPERA,
webdriver.Browser.PHANTOM_JS,
Expand All @@ -54,7 +50,6 @@ var noBuild = /^1|true$/i.test(process.env['SELENIUM_NO_BUILD']);
var serverJar = process.env['SELENIUM_SERVER_JAR'];
var remoteUrl = process.env['SELENIUM_REMOTE_URL'];
var useLoopback = process.env['SELENIUM_USE_LOOP_BACK'] == '1';
var noMarionette = /^0|false$/i.test(process.env['SELENIUM_GECKODRIVER']);
var startServer = !!serverJar && !remoteUrl;
var nativeRun = !serverJar && !remoteUrl;

Expand All @@ -76,9 +71,6 @@ var browsersToTest = (function() {
if (parts[0] === 'edge') {
parts[0] = webdriver.Browser.EDGE;
}
if (noMarionette && parts[0] === webdriver.Browser.FIREFOX) {
parts[0] = LEGACY_FIREFOX;
}
return parts.join(':');
});

Expand All @@ -88,10 +80,6 @@ var browsersToTest = (function() {
parts[0] = webdriver.Browser.IE;
}

if (parts[0] === LEGACY_FIREFOX) {
return;
}

if (NATIVE_BROWSERS.indexOf(parts[0]) == -1 && !permitRemoteBrowsers) {
throw Error('Browser ' + parts[0] + ' requires a WebDriver server and ' +
'neither the SELENIUM_REMOTE_URL nor the SELENIUM_SERVER_JAR ' +
Expand Down Expand Up @@ -157,10 +145,6 @@ function TestEnvironment(browserName, server) {
return server || remoteUrl;
};

this.isMarionette = function() {
return !noMarionette;
};

this.browsers = function(var_args) {
var browsersToIgnore = Array.prototype.slice.apply(arguments, [0]);
return browsers(browserName, browsersToIgnore);
Expand All @@ -171,15 +155,7 @@ function TestEnvironment(browserName, server) {
var realBuild = builder.build;

builder.build = function() {
var parts = browserName.split(/:/, 3);

if (parts[0] === LEGACY_FIREFOX) {
var options = builder.getFirefoxOptions() || new firefox.Options();
options.useGeckoDriver(false);
builder.setFirefoxOptions(options);

parts[0] = webdriver.Browser.FIREFOX;
}
let parts = browserName.split(/:/, 3);

builder.forBrowser(parts[0], parts[1], parts[2]);
if (server) {
Expand Down Expand Up @@ -244,15 +220,6 @@ function suite(fn, opt_options) {
browsers.forEach(function(browser) {
describe('[' + browser + ']', function() {

if (isDevMode && nativeRun) {
if (browser === LEGACY_FIREFOX) {
before(function() {
return build.of('//javascript/firefox-driver:webdriver')
.onlyOnce().go();
});
}
}

var serverToUse = null;

if (!!serverJar && !remoteUrl) {
Expand Down
Loading

0 comments on commit 3bc0c2b

Please sign in to comment.