-
Notifications
You must be signed in to change notification settings - Fork 331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Adds binaryArgs to pass additional flags to Firefox binary #1563
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @denar90, thanks for opening this PR, the new feature propose sounds reasonable to me, but it looks that this PR needs some additional changes to be complete, e.g.:
-
we should add the new option to the
ExtensionRunnerParams
flow type definition in src/extension-runners/base.js -
make sure that the FirefoxAndroidExtensionRunner class is going to print a warning message if the new option is being specified while running the firefox-android target, as it would be unused in that case
-
expose the feature as a new optional CLI option for the web-ext run command, by adding its definition here
-
Add some additional test unit, to cover the changes and/or additions applied in this PR, e.g. the following unit test files are likely going to need some small additions (e.g. a new test case, or new assertions):
- tests/unit/test-cmd/test.run.js
- tests/unit/test-extension-runners/test.firefox-desktop.js
- tests/unit/test-extension-runners/test.firefox-android.js (it should be enough to test the new warning here)
Feel free to mention me in a comment if you need help (or if you have any doubts that I can help you with).
.gitignore
Outdated
@@ -1,5 +1,6 @@ | |||
# OSX | |||
.DS_Store | |||
.idea |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change seems unrelated.
@rpl thank you so much for the review 👍 Thanks :) |
@@ -290,6 +291,12 @@ export class FirefoxAndroidExtensionRunner { | |||
'Firefox for Android target does not support --start-url option.' | |||
); | |||
} | |||
|
|||
if (this.params.binaryArgs) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rpl I was thinking about smth like
const ignoredParams = {
profilePath: '--profile-path',
keepProfileChanges: '--keep-profile-changes',
browserConsole: '--browser-console',
preInstall: '--pre-install',
startUrl: '--start-url',
binaryArgs: '--binary-args',
};
const getIgnoredParamsWarningsMessage = (optionName) => {
return `Firefox for Android target does not support ${optionName} option`;
};
so function printIgnoredParamsWarnings
can be a bit cleaner
printIgnoredParamsWarnings() {
Object.entries(ignoredParams).forEach((ignoredParam) => {
if (this.params[ignoredParam]) {
log.warn(
getIgnoredParamsWarningsMessage(ignoredParams[ignoredParam])
);
}
});
}
Only thing I stuck is flow
with some errors, but I can dig in if you approve this approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I like the idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(let me know if you get stuck on issues with flow errors, I'll be happy to help you to figure out how to properly handle those)
btw, should I exclude |
yes please (I briefly looked to the diff and it seems that it is changing the exact versions into non exact versions, and so let's omit it from this PR, thanks for pointing it out!) |
@@ -261,6 +261,7 @@ export class FirefoxAndroidExtensionRunner { | |||
} | |||
|
|||
printIgnoredParamsWarnings() { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, let's remove this empty line.
} = this.params; | ||
|
||
const binaryArgs = []; | ||
|
||
if (browserConsole) { | ||
binaryArgs.push('-jsconsole'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uhm... I'm thinking that it may be better to append the additional arguments that the user may be passing to a web-ext run
command (instead of prepending them before the ones added internally by web-ext itself).
@Rob--W what do you think about it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appending rather than prepending sounds good to me.
src/program.js
Outdated
@@ -503,6 +503,12 @@ Example: $0 --help run. | |||
demandOption: false, | |||
type: 'boolean', | |||
}, | |||
'binary-args': { | |||
describe: 'Browser binary options. More at - ' + | |||
'https://developer.mozilla.org/en-US/docs/Mozilla/Command_Line_Options', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, let's indent this line as the other "multi-line" describe
values in this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wdyt about adding eslint ignore for this line? URL is too long and linter doesn't like it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@denar90 How about omitting the link and give it a more generic description? e.g. something like the following:
'binary-args': {
describe: "Additional command line options passed to the Browser binary',
...
}
In my opinion, it may be a reasonable choice, e.g. as part of #1392 we may use the --binary-args
also to pass additional CLI options to Chromium browsers.
Otherwise we may opt to include a shortened link instead (e.g. you can use https://mzl.la/2CEvSV5 which point to the above link).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about omitting the link and give it a more generic description?
SGTM 👍
@@ -202,6 +202,14 @@ describe('util/extension-runners/firefox-desktop', () => { | |||
]); | |||
}); | |||
|
|||
it('passes binaryArgs tp Firefox', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit, typo: tp -> to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops 😊
had to do force-push, hope it isn't a problem :) |
src/program.js
Outdated
@@ -503,6 +503,11 @@ Example: $0 --help run. | |||
demandOption: false, | |||
type: 'boolean', | |||
}, | |||
'binary-args': { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using binary-args
here implies that the command line becomes --binary-args
. That is a bit too long to my taste. Could you rename this to args
and add an alias: ['arg'],
I would also have liked the 'a'
shorthand, but unfortunately the letter is already taken by the --artifacts-dir
command.
} = this.params; | ||
|
||
const binaryArgs = []; | ||
|
||
if (browserConsole) { | ||
binaryArgs.push('-jsconsole'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appending rather than prepending sounds good to me.
}; | ||
|
||
const getIgnoredParamsWarningsMessage = (optionName) => { | ||
return `Firefox for Android target does not support ${optionName} option`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While you're at it, let's improve the English:
The Firefox for Android target does not support the ${optionName} option
or
The Firefox for Android target does not support ${optionName}
.
} = this.params; | ||
|
||
const binaryArgs = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this version of the PR the arguments are still prepended instead of appended. Restore the binaryArgs
variable and use binaryArgs.push(...args);
before passing it to firefoxApp.run
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, looks like I misunderstood you. Does it look fine now - 28cb262?
src/firefox/index.js
Outdated
@@ -88,7 +88,7 @@ export type FirefoxRunnerParams = {| | |||
'no-remote'?: boolean, | |||
'foreground'?: boolean, | |||
'listen': number, | |||
'binary-args'?: Array<string> | string, | |||
'args'?: Array<string> | string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You cannot simply rename binary-args
to args
here, because this is the API to an external library: https://github.com/mozilla-jetpack/node-fx-runner/blob/71e3848b6adac1054829391c826fd88cfb28f621/lib/run.js#L42-L48
Revert all changes in this file (and use binaryArgs
instead of args: binaryArgs
in the other file).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so just keep args only for cli? all other code will remain as is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. The external interface of web-ext run
will use args
, and binary-args
is only used internally, imposed by the contract of the fx-runner interface.
This reverts commit 14af123.
@@ -172,36 +172,44 @@ describe('util/extension-runners/firefox-desktop', () => { | |||
params.firefoxApp.run, | |||
sinon.match.any, | |||
sinon.match.has( | |||
'binaryArgs', | |||
sinon.match.array.deepEquals(expectedBinaryArgs) | |||
'args', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one should also be binaryArgs
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Thanks for taking the efforts to minimize the diff.
@denar90 Thanks! Looks great to me too, Let's merge it! |
Thanks, @denar90! Your contribution has been added to our contribution wiki. Would you be interested in creating an account on mozillians.org? I'd be happy to vouch for you! |
@rpl @Rob--W thank you for the review and your comments. Really aprriciate your effort 👍
@caitmuenster thanks 😄
Wow, I'll be more than happy to become part of the community 🙌 |
btw, about documentation for the new option, do you need some help with it to make release v3.1 faster? |
@denar90 The documentation that you added at The list of open tasks for 3.1.0 is at https://github.com/mozilla/web-ext/projects/3 |
Thanks, @denar90! You're vouched. Welcome onboard! 🎉 |
@Rob--W thank you for the info 👍 @caitmuenster thank you for vouching. I'm really honored 😊 |
@denar90 I use this to launch firefox with extension, but shows |
Hi,
Can we add one more option to run method?
Motivation: puppeteer/puppeteer#4162
Partly solves #1122
Example of usage
Thanks.