Skip to content

Commit 44114ee

Browse files
denar90rpl
authored andcommitted
feat: Adds binaryArgs to pass additional flags to Firefox binary (#1563)
1 parent 73df58a commit 44114ee

File tree

8 files changed

+54
-32
lines changed

8 files changed

+54
-32
lines changed

src/cmd/run.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export type CmdRunParams = {|
3636
sourceDir: string,
3737
startUrl?: Array<string>,
3838
target?: Array<string>,
39+
args?: Array<string>,
3940

4041
// Android CLI options.
4142
adbBin?: string,
@@ -77,6 +78,7 @@ export default async function run(
7778
adbPort,
7879
adbDevice,
7980
firefoxApk,
81+
args,
8082
}: CmdRunParams,
8183
{
8284
buildExtension = defaultBuildExtension,
@@ -107,6 +109,7 @@ export default async function run(
107109
extensions: [{sourceDir, manifestData}],
108110
keepProfileChanges,
109111
startUrl,
112+
args,
110113
desktopNotifications,
111114
};
112115

src/extension-runners/base.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export type ExtensionRunnerParams = {|
1616
profilePath?: string,
1717
keepProfileChanges: boolean,
1818
startUrl: ?string | ?Array<string>,
19+
args?: Array<string>,
1920

2021
// Common injected dependencies.
2122
desktopNotifications: typeof defaultDesktopNotifications,

src/extension-runners/firefox-android.js

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,19 @@ import type {
4242

4343
const log = createLogger(__filename);
4444

45+
const ignoredParams = {
46+
profilePath: '--profile-path',
47+
keepProfileChanges: '--keep-profile-changes',
48+
browserConsole: '--browser-console',
49+
preInstall: '--pre-install',
50+
startUrl: '--start-url',
51+
args: '--args',
52+
};
53+
54+
const getIgnoredParamsWarningsMessage = (optionName) => {
55+
return `The Firefox for Android target does not support ${optionName}`;
56+
};
57+
4558
export type FirefoxAndroidExtensionRunnerParams = {|
4659
...ExtensionRunnerParams,
4760

@@ -261,35 +274,13 @@ export class FirefoxAndroidExtensionRunner {
261274
}
262275

263276
printIgnoredParamsWarnings() {
264-
if (this.params.profilePath) {
265-
log.warn(
266-
'Firefox for Android target does not support custom profile paths.'
267-
);
268-
}
269-
270-
if (this.params.keepProfileChanges) {
271-
log.warn(
272-
'Firefox for Android target does not support --keep-profile-changes.'
273-
);
274-
}
275-
276-
if (this.params.browserConsole) {
277-
log.warn(
278-
'Firefox for Android target does not support --browser-console option.'
279-
);
280-
}
281-
282-
if (this.params.preInstall) {
283-
log.warn(
284-
'Firefox for Android target does not support --pre-install option.'
285-
);
286-
}
287-
288-
if (this.params.startUrl) {
289-
log.warn(
290-
'Firefox for Android target does not support --start-url option.'
291-
);
292-
}
277+
Object.keys(ignoredParams).forEach((ignoredParam) => {
278+
if (this.params[ignoredParam]) {
279+
log.warn(
280+
getIgnoredParamsWarningsMessage(ignoredParams[ignoredParam])
281+
);
282+
}
283+
});
293284
}
294285

295286
async adbDevicesDiscoveryAndSelect() {

src/extension-runners/firefox-desktop.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ export class FirefoxDesktopExtensionRunner {
217217
startUrl,
218218
firefoxApp,
219219
firefoxClient,
220+
args,
220221
} = this.params;
221222

222223
const binaryArgs = [];
@@ -231,6 +232,10 @@ export class FirefoxDesktopExtensionRunner {
231232
}
232233
}
233234

235+
if (args) {
236+
binaryArgs.push(...args);
237+
}
238+
234239
this.runningInfo = await firefoxApp.run(this.profile, {
235240
firefoxBinary, binaryArgs,
236241
});

src/program.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,12 @@ Example: $0 --help run.
503503
demandOption: false,
504504
type: 'boolean',
505505
},
506+
'args': {
507+
alias: ['arg'],
508+
describe: 'Additional CLI options passed to the Browser binary',
509+
demandOption: false,
510+
type: 'array',
511+
},
506512
// Firefox for Android CLI options.
507513
'adb-bin': {
508514
describe: 'Specify a custom path to the adb binary',

tests/unit/test-cmd/test.run.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ describe('run', () => {
106106
firefox: '/path/to/custom/bin/firefox',
107107
pref: {'my.custom.pref': 'value'},
108108
firefoxProfile: '/path/to/custom/profile',
109+
args: ['-headless=false'],
109110
};
110111

111112
await cmd.run(runOptions);
@@ -130,6 +131,7 @@ describe('run', () => {
130131
firefoxBinary: runnerParams.firefoxBinary,
131132
customPrefs: runnerParams.customPrefs,
132133
firefoxProfile: runnerParams.profilePath,
134+
args: runnerParams.args,
133135
}, expectedRunnerParams);
134136
assert.equal(runnerParams.extensions.length, 1);
135137
assert.equal(runnerParams.extensions[0].sourceDir, cmd.argv.sourceDir);

tests/unit/test-extension-runners/test.firefox-android.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ describe('util/extension-runners/firefox-android', () => {
845845
{
846846
params: {profilePath: '/fake/dir'},
847847
expectedMessage: (
848-
/Android target does not support custom profile paths/
848+
/Android target does not support --profile-path/
849849
),
850850
},
851851
{
@@ -863,13 +863,19 @@ describe('util/extension-runners/firefox-android', () => {
863863
{
864864
params: {preInstall: true},
865865
expectedMessage: (
866-
/Android target does not support --pre-install option/
866+
/Android target does not support --pre-install/
867867
),
868868
},
869869
{
870870
params: {startUrl: 'http://fake-start-url.org'},
871871
expectedMessage: (
872-
/Android target does not support --start-url option/
872+
/Android target does not support --start-url/
873+
),
874+
},
875+
{
876+
params: {args: ['-headless=false']},
877+
expectedMessage: (
878+
/Android target does not support --args/
873879
),
874880
},
875881
];

tests/unit/test-extension-runners/test.firefox-desktop.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,14 @@ describe('util/extension-runners/firefox-desktop', () => {
202202
]);
203203
});
204204

205+
it('passes binaryArgs to Firefox', async () => {
206+
await testBinaryArgs({
207+
args: ['-headless=true', '-jsconsole'],
208+
}, [
209+
'-headless=true', '-jsconsole',
210+
]);
211+
});
212+
205213
it('passes a custom Firefox profile when specified', async () => {
206214
const {params} = prepareExtensionRunnerParams({
207215
params: {

0 commit comments

Comments
 (0)