@@ -128,6 +128,7 @@ const zip = require('./io/zip')
128
128
const { Browser, Capabilities } = require ( './lib/capabilities' )
129
129
const { Zip } = require ( './io/zip' )
130
130
const { getPath } = require ( './common/driverFinder' )
131
+ const FIREFOX_CAPABILITY_KEY = 'moz:firefoxOptions'
131
132
132
133
/**
133
134
* Thrown when there an add-on is malformed.
@@ -263,10 +264,10 @@ class Options extends Capabilities {
263
264
* @private
264
265
*/
265
266
firefoxOptions_ ( ) {
266
- let options = this . get ( 'moz:firefoxOptions' )
267
+ let options = this . get ( FIREFOX_CAPABILITY_KEY )
267
268
if ( ! options ) {
268
269
options = { }
269
- this . set ( 'moz:firefoxOptions' , options )
270
+ this . set ( FIREFOX_CAPABILITY_KEY , options )
270
271
}
271
272
return options
272
273
}
@@ -580,6 +581,8 @@ class Driver extends webdriver.WebDriver {
580
581
let caps =
581
582
opt_config instanceof Capabilities ? opt_config : new Options ( opt_config )
582
583
584
+ let firefoxBrowserPath = null
585
+
583
586
let executor
584
587
let onQuit
585
588
@@ -588,19 +591,33 @@ class Driver extends webdriver.WebDriver {
588
591
configureExecutor ( executor )
589
592
} else if ( opt_executor instanceof remote . DriverService ) {
590
593
if ( ! opt_executor . getExecutable ( ) ) {
591
- opt_executor . setExecutable ( getPath ( opt_config ) )
594
+ const { driverPath, browserPath} = getPath ( caps )
595
+ opt_executor . setExecutable ( driverPath )
596
+ firefoxBrowserPath = browserPath
592
597
}
593
598
executor = createExecutor ( opt_executor . start ( ) )
594
599
onQuit = ( ) => opt_executor . kill ( )
595
600
} else {
596
601
let service = new ServiceBuilder ( ) . build ( )
597
602
if ( ! service . getExecutable ( ) ) {
598
- service . setExecutable ( getPath ( opt_config ) )
603
+ const { driverPath, browserPath} = getPath ( caps )
604
+ service . setExecutable ( driverPath )
605
+ firefoxBrowserPath = browserPath
599
606
}
600
607
executor = createExecutor ( service . start ( ) )
601
608
onQuit = ( ) => service . kill ( )
602
609
}
603
610
611
+ if ( firefoxBrowserPath ) {
612
+ const vendorOptions = caps . get ( FIREFOX_CAPABILITY_KEY )
613
+ if ( vendorOptions ) {
614
+ vendorOptions [ 'binary' ] = firefoxBrowserPath
615
+ caps . set ( FIREFOX_CAPABILITY_KEY , vendorOptions )
616
+ } else {
617
+ caps . set ( FIREFOX_CAPABILITY_KEY , { binary : firefoxBrowserPath } )
618
+ }
619
+ }
620
+
604
621
return /** @type {!Driver } */ ( super . createSession ( executor , caps , onQuit ) )
605
622
}
606
623
0 commit comments