diff --git a/src/cmd/run.js b/src/cmd/run.js index 7cf88bc902..7d45fb1a30 100644 --- a/src/cmd/run.js +++ b/src/cmd/run.js @@ -36,6 +36,7 @@ export type CmdRunParams = {| sourceDir: string, startUrl?: Array, target?: Array, + args?: Array, // Android CLI options. adbBin?: string, @@ -77,6 +78,7 @@ export default async function run( adbPort, adbDevice, firefoxApk, + args, }: CmdRunParams, { buildExtension = defaultBuildExtension, @@ -107,6 +109,7 @@ export default async function run( extensions: [{sourceDir, manifestData}], keepProfileChanges, startUrl, + args, desktopNotifications, }; diff --git a/src/extension-runners/base.js b/src/extension-runners/base.js index f987966c79..6961a8c88e 100644 --- a/src/extension-runners/base.js +++ b/src/extension-runners/base.js @@ -16,6 +16,7 @@ export type ExtensionRunnerParams = {| profilePath?: string, keepProfileChanges: boolean, startUrl: ?string | ?Array, + args?: Array, // Common injected dependencies. desktopNotifications: typeof defaultDesktopNotifications, diff --git a/src/extension-runners/firefox-android.js b/src/extension-runners/firefox-android.js index 2e5e6bd310..5eb35deea6 100644 --- a/src/extension-runners/firefox-android.js +++ b/src/extension-runners/firefox-android.js @@ -42,6 +42,19 @@ import type { const log = createLogger(__filename); +const ignoredParams = { + profilePath: '--profile-path', + keepProfileChanges: '--keep-profile-changes', + browserConsole: '--browser-console', + preInstall: '--pre-install', + startUrl: '--start-url', + args: '--args', +}; + +const getIgnoredParamsWarningsMessage = (optionName) => { + return `The Firefox for Android target does not support ${optionName}`; +}; + export type FirefoxAndroidExtensionRunnerParams = {| ...ExtensionRunnerParams, @@ -261,35 +274,13 @@ export class FirefoxAndroidExtensionRunner { } printIgnoredParamsWarnings() { - if (this.params.profilePath) { - log.warn( - 'Firefox for Android target does not support custom profile paths.' - ); - } - - if (this.params.keepProfileChanges) { - log.warn( - 'Firefox for Android target does not support --keep-profile-changes.' - ); - } - - if (this.params.browserConsole) { - log.warn( - 'Firefox for Android target does not support --browser-console option.' - ); - } - - if (this.params.preInstall) { - log.warn( - 'Firefox for Android target does not support --pre-install option.' - ); - } - - if (this.params.startUrl) { - log.warn( - 'Firefox for Android target does not support --start-url option.' - ); - } + Object.keys(ignoredParams).forEach((ignoredParam) => { + if (this.params[ignoredParam]) { + log.warn( + getIgnoredParamsWarningsMessage(ignoredParams[ignoredParam]) + ); + } + }); } async adbDevicesDiscoveryAndSelect() { diff --git a/src/extension-runners/firefox-desktop.js b/src/extension-runners/firefox-desktop.js index 555db6977a..a71515bdc0 100644 --- a/src/extension-runners/firefox-desktop.js +++ b/src/extension-runners/firefox-desktop.js @@ -217,6 +217,7 @@ export class FirefoxDesktopExtensionRunner { startUrl, firefoxApp, firefoxClient, + args, } = this.params; const binaryArgs = []; @@ -231,6 +232,10 @@ export class FirefoxDesktopExtensionRunner { } } + if (args) { + binaryArgs.push(...args); + } + this.runningInfo = await firefoxApp.run(this.profile, { firefoxBinary, binaryArgs, }); diff --git a/src/program.js b/src/program.js index 4c3dd906d7..9c79517555 100644 --- a/src/program.js +++ b/src/program.js @@ -503,6 +503,12 @@ Example: $0 --help run. demandOption: false, type: 'boolean', }, + 'args': { + alias: ['arg'], + describe: 'Additional CLI options passed to the Browser binary', + demandOption: false, + type: 'array', + }, // Firefox for Android CLI options. 'adb-bin': { describe: 'Specify a custom path to the adb binary', diff --git a/tests/unit/test-cmd/test.run.js b/tests/unit/test-cmd/test.run.js index 0b89fd3164..82c907deb9 100644 --- a/tests/unit/test-cmd/test.run.js +++ b/tests/unit/test-cmd/test.run.js @@ -106,6 +106,7 @@ describe('run', () => { firefox: '/path/to/custom/bin/firefox', pref: {'my.custom.pref': 'value'}, firefoxProfile: '/path/to/custom/profile', + args: ['-headless=false'], }; await cmd.run(runOptions); @@ -130,6 +131,7 @@ describe('run', () => { firefoxBinary: runnerParams.firefoxBinary, customPrefs: runnerParams.customPrefs, firefoxProfile: runnerParams.profilePath, + args: runnerParams.args, }, expectedRunnerParams); assert.equal(runnerParams.extensions.length, 1); assert.equal(runnerParams.extensions[0].sourceDir, cmd.argv.sourceDir); diff --git a/tests/unit/test-extension-runners/test.firefox-android.js b/tests/unit/test-extension-runners/test.firefox-android.js index 7715ea6cbc..f8d93a6a21 100644 --- a/tests/unit/test-extension-runners/test.firefox-android.js +++ b/tests/unit/test-extension-runners/test.firefox-android.js @@ -845,7 +845,7 @@ describe('util/extension-runners/firefox-android', () => { { params: {profilePath: '/fake/dir'}, expectedMessage: ( - /Android target does not support custom profile paths/ + /Android target does not support --profile-path/ ), }, { @@ -863,13 +863,19 @@ describe('util/extension-runners/firefox-android', () => { { params: {preInstall: true}, expectedMessage: ( - /Android target does not support --pre-install option/ + /Android target does not support --pre-install/ ), }, { params: {startUrl: 'http://fake-start-url.org'}, expectedMessage: ( - /Android target does not support --start-url option/ + /Android target does not support --start-url/ + ), + }, + { + params: {args: ['-headless=false']}, + expectedMessage: ( + /Android target does not support --args/ ), }, ]; diff --git a/tests/unit/test-extension-runners/test.firefox-desktop.js b/tests/unit/test-extension-runners/test.firefox-desktop.js index 6ead2b19a9..640700cd25 100644 --- a/tests/unit/test-extension-runners/test.firefox-desktop.js +++ b/tests/unit/test-extension-runners/test.firefox-desktop.js @@ -202,6 +202,14 @@ describe('util/extension-runners/firefox-desktop', () => { ]); }); + it('passes binaryArgs to Firefox', async () => { + await testBinaryArgs({ + args: ['-headless=true', '-jsconsole'], + }, [ + '-headless=true', '-jsconsole', + ]); + }); + it('passes a custom Firefox profile when specified', async () => { const {params} = prepareExtensionRunnerParams({ params: {