* Overrides the parent build() method to let Firefox pick the websocket port * when not connecting to an existing instance and no port was supplied. * * @return {!DriverService} A new driver service instance.
()
| 420 | * @return {!DriverService} A new driver service instance. |
| 421 | */ |
| 422 | build() { |
| 423 | let port = this.options_.port || findFreePort() |
| 424 | let argsPromise = Promise.all([port, Promise.all(this.options_.args)]).then(([port, userArgs]) => { |
| 425 | // Start with the default --port argument. |
| 426 | let args = userArgs.concat(`--port=${port}`) |
| 427 | const skipWebSocketPort = userArgs.some( |
| 428 | (arg) => arg === '--connect-existing' || (typeof arg === 'string' && arg.startsWith('--websocket-port')), |
| 429 | ) |
| 430 | if (!skipWebSocketPort) { |
| 431 | args.push('--websocket-port=0') |
| 432 | } |
| 433 | return args |
| 434 | }) |
| 435 | |
| 436 | let options = Object.assign({}, this.options_, { args: argsPromise, port }) |
| 437 | return new remote.DriverService(this.exe_, options) |
| 438 | } |
| 439 | } |
| 440 | |
| 441 | /** |
nothing calls this directly
no test coverage detected