Skip to content

Commit bdeac8e

Browse files
[js] Finalise JS Binding support for WebDriver Bidi in Firefox
This requires Firefox 87 and Geckodriver 0.29 to be able to work
1 parent 10b1603 commit bdeac8e

File tree

8 files changed

+201
-113
lines changed

8 files changed

+201
-113
lines changed

.bazelrc

+2
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,5 @@ build --test_env=SELENIUM_BROWSER
4040
build --test_env=TRAVIS
4141

4242
test --test_timeout=1800
43+
44+
test:node_debug --test_output=streamed --test_strategy=exclusive --test_timeout=9999 --nocache_test_results

javascript/node/selenium-webdriver/BUILD.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pkg_npm(
3737
],
3838
)
3939

40-
TEST_FILES = glob(["test/**/*_test.js"])
40+
TEST_FILES = ["test/**/*_test.js"]
4141

4242
TEST_DATA = SRC_FILES + glob(
4343
[

javascript/node/selenium-webdriver/chromium.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ class Options extends Capabilities {
565565
return extension.toString('base64')
566566
}
567567
return io
568-
.read(/** @type {string} */ (extension))
568+
.read(/** @type {string} */(extension))
569569
.then((buffer) => buffer.toString('base64'))
570570
})
571571
}
@@ -618,7 +618,7 @@ class Driver extends webdriver.WebDriver {
618618
* implementation.
619619
* @override
620620
*/
621-
setFileDetector() {}
621+
setFileDetector() { }
622622

623623
/**
624624
* Schedules a command to launch Chrome App with given ID.
@@ -820,10 +820,6 @@ class Driver extends webdriver.WebDriver {
820820
'Driver.stopCasting(' + deviceName + ')'
821821
)
822822
}
823-
824-
getRandomNumber(min, max) {
825-
return Math.floor(Math.random() * (max - min + 1) + min)
826-
}
827823
}
828824

829825
// PUBLIC API

javascript/node/selenium-webdriver/firefox.js

+9-41
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ async function buildProfile(template, extensions) {
223223
dir = await io.tmpDir()
224224
if (template) {
225225
await io.copyDir(
226-
/** @type {string} */ (template),
226+
/** @type {string} */(template),
227227
dir,
228228
/(parent\.lock|lock|\.parentlock)/
229229
)
@@ -433,11 +433,11 @@ function findGeckoDriver() {
433433
if (!exe) {
434434
throw Error(
435435
'The ' +
436-
GECKO_DRIVER_EXE +
437-
' executable could not be found on the current ' +
438-
'PATH. Please download the latest version from ' +
439-
'https://github.com/mozilla/geckodriver/releases/ ' +
440-
'and ensure it can be found on your PATH.'
436+
GECKO_DRIVER_EXE +
437+
' executable could not be found on the current ' +
438+
'PATH. Please download the latest version from ' +
439+
'https://github.com/mozilla/geckodriver/releases/ ' +
440+
'and ensure it can be found on your PATH.'
441441
)
442442
}
443443
return exe
@@ -458,8 +458,8 @@ function findInProgramFiles(file) {
458458
return exists
459459
? files[0]
460460
: io.exists(files[1]).then(function (exists) {
461-
return exists ? files[1] : null
462-
})
461+
return exists ? files[1] : null
462+
})
463463
})
464464
}
465465

@@ -593,7 +593,7 @@ class Driver extends webdriver.WebDriver {
593593
* implementation.
594594
* @override
595595
*/
596-
setFileDetector() {}
596+
setFileDetector() { }
597597

598598
/**
599599
* Get the context that is currently in effect.
@@ -667,38 +667,6 @@ class Driver extends webdriver.WebDriver {
667667
)
668668
)
669669
}
670-
671-
/**
672-
* Creates a new WebSocket connection.
673-
* @return {!Promise<resolved>} A new CDP instance.
674-
*/
675-
async createCDPConnection(target) {
676-
const caps = await this.getCapabilities()
677-
const seOptions = caps['map_'].get('se:options') || new Map()
678-
const vendorInfo =
679-
caps['map_'].get('moz:debuggerAddress') ||
680-
new Map()
681-
const debuggerUrl = seOptions['cdp'] || vendorInfo['debuggerAddress']
682-
this._wsUrl = await this.getWsUrl(debuggerUrl, target)
683-
684-
return new Promise((resolve, reject) => {
685-
try {
686-
this._wsConnection = new WebSocket(this._wsUrl)
687-
} catch (err) {
688-
reject(err)
689-
return
690-
}
691-
692-
this._wsConnection.on('open', () => {
693-
this._cdpConnection = new cdp.CdpConnection(this._wsConnection)
694-
resolve(this._cdpConnection)
695-
})
696-
697-
this._wsConnection.on('error', (error) => {
698-
reject(error)
699-
})
700-
})
701-
}
702670
}
703671

704672
/**

javascript/node/selenium-webdriver/lib/capabilities.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const Platform = {
8484
*
8585
* @record
8686
*/
87-
function Timeouts() {}
87+
function Timeouts() { }
8888

8989
/**
9090
* Defines when, in milliseconds, to interrupt a script that is being
@@ -264,7 +264,7 @@ class Capabilities {
264264
* @return {!Capabilities} A basic set of capabilities for Firefox.
265265
*/
266266
static firefox() {
267-
return new Capabilities().setBrowserName(Browser.FIREFOX)
267+
return new Capabilities().setBrowserName(Browser.FIREFOX).set("moz:debuggerAddress", true)
268268
}
269269

270270
/**

0 commit comments

Comments
 (0)