Skip to content

Commit 431070e

Browse files
andreasttjleyba
authored andcommitted
nodejs: enable use of firefox profiles for marionette (#2406)
1 parent 6b8f3ff commit 431070e

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

javascript/node/selenium-webdriver/firefox/index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,12 @@ class Driver extends webdriver.WebDriver {
354354
binary = new Binary(binary);
355355
}
356356

357+
let profile = new Profile();
358+
if (caps.has(Capability.PROFILE)) {
359+
profile = caps.get(Capability.PROFILE);
360+
caps.delete(Capability.PROFILE);
361+
}
362+
357363
let serverUrl, onQuit;
358364

359365
// Users must now explicitly disable marionette to use the legacy
@@ -367,14 +373,9 @@ class Driver extends webdriver.WebDriver {
367373
let service = createGeckoDriverService(binary);
368374
serverUrl = service.start();
369375
onQuit = () => service.kill();
376+
caps.set(Capability.PROFILE, profile.encode());
370377

371378
} else {
372-
let profile = new Profile;
373-
if (caps.has(Capability.PROFILE)) {
374-
profile = caps.get(Capability.PROFILE);
375-
caps.delete(Capability.PROFILE);
376-
}
377-
378379
let freePort = portprober.findFreePort();
379380
let preparedProfile =
380381
freePort.then(port => prepareProfile(profile, port));

javascript/node/selenium-webdriver/firefox/profile.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ function decode(data) {
188188

189189
/**
190190
* Models a Firefox profile directory for use with the FirefoxDriver. The
191-
* {@code Profile} directory uses an in-memory model until {@link #writeToDisk}
192-
* is called.
191+
* {@code Profile} directory uses an in-memory model until
192+
* {@link #writeToDisk} or {@link #encode} is called.
193193
*/
194194
class Profile {
195195
/**
@@ -366,8 +366,12 @@ class Profile {
366366
}
367367

368368
/**
369-
* Encodes this profile as a zipped, base64 encoded directory.
370-
* @return {!Promise<string>} A promise for the encoded profile.
369+
* Write profile to disk, compress its containing directory, and return
370+
* it as a Base64 encoded string.
371+
*
372+
* @return {!Promise<string>} A promise for the encoded profile as
373+
* Base64 string.
374+
*
371375
*/
372376
encode() {
373377
return this.writeToDisk(true).then(function(dir) {

0 commit comments

Comments
 (0)