@@ -128,6 +128,7 @@ const zip = require('./io/zip')
128128const { Browser, Capabilities } = require ( './lib/capabilities' )
129129const { Zip } = require ( './io/zip' )
130130const { getPath } = require ( './common/driverFinder' )
131+ const FIREFOX_CAPABILITY_KEY = 'moz:firefoxOptions'
131132
132133/**
133134 * Thrown when there an add-on is malformed.
@@ -263,10 +264,10 @@ class Options extends Capabilities {
263264 * @private
264265 */
265266 firefoxOptions_ ( ) {
266- let options = this . get ( 'moz:firefoxOptions' )
267+ let options = this . get ( FIREFOX_CAPABILITY_KEY )
267268 if ( ! options ) {
268269 options = { }
269- this . set ( 'moz:firefoxOptions' , options )
270+ this . set ( FIREFOX_CAPABILITY_KEY , options )
270271 }
271272 return options
272273 }
@@ -580,6 +581,8 @@ class Driver extends webdriver.WebDriver {
580581 let caps =
581582 opt_config instanceof Capabilities ? opt_config : new Options ( opt_config )
582583
584+ let firefoxBrowserPath = null
585+
583586 let executor
584587 let onQuit
585588
@@ -588,19 +591,33 @@ class Driver extends webdriver.WebDriver {
588591 configureExecutor ( executor )
589592 } else if ( opt_executor instanceof remote . DriverService ) {
590593 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
592597 }
593598 executor = createExecutor ( opt_executor . start ( ) )
594599 onQuit = ( ) => opt_executor . kill ( )
595600 } else {
596601 let service = new ServiceBuilder ( ) . build ( )
597602 if ( ! service . getExecutable ( ) ) {
598- service . setExecutable ( getPath ( opt_config ) )
603+ const { driverPath, browserPath} = getPath ( caps )
604+ service . setExecutable ( driverPath )
605+ firefoxBrowserPath = browserPath
599606 }
600607 executor = createExecutor ( service . start ( ) )
601608 onQuit = ( ) => service . kill ( )
602609 }
603610
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+
604621 return /** @type {!Driver } */ ( super . createSession ( executor , caps , onQuit ) )
605622 }
606623
0 commit comments