Command line arguments handled in "command-line-startup" have unexpected side effects
Categories
(Toolkit :: Startup and Profile System, defect)
Tracking
()
People
(Reporter: jdescottes, Unassigned)
References
Details
In the RemoteAgent & Marionette components, we are handling command line arguments by observing "command-line-startup" instead of implementing the handle
method of the nsICommandLineHandler interface.
This is done because handle
is triggered too late in some scenarios for automation (eg safe mode).
The arguments are read using cmdLine.handleFlag. However they still exhibit side effects which seem usually only applied to unhandled arguments.
For instance, if you execute:
> ./mach run --marionette --remote-debugging-port=1234
the browser will open on https://0.0.4.210/
. If you change the value of "remote-debugging-port" this URL will change.
I am not sure what is responsible of this behavior, but what I can say is that this is exactly the same behavior as if we used two random arguments:
> ./mach run --test1 --test2=1234
Technically, only the first argument needs to be "unhandled" for this behavior to be triggered.
In order to workaround this, implementing handle
to simply consume the arguments from the command line seems to work. See the patch at https://phabricator.services.mozilla.com/D121768?id=467856
But it would be great if we didn't have to do that. Again handle
happens too late so we can't really use it and we end up just consuming the arguments to avoid the side effect described here, without doing anything meaningful with them.
We are using the same API in the "command-line-startup" observer as in "handle" so it seems strange that it doesn't have the same effect.
Note, this happens for me on macos, haven't checked other operating systems.
Reporter | ||
Updated•3 years ago
|
Comment 1•3 years ago
|
||
Seems that we re-initialize the command line after that notification on macOS for some reason: https://searchfox.org/mozilla-central/rev/00977c4e37865a92f1c15572ae4aea90e934b25b/toolkit/xre/nsAppRunner.cpp#5169
Reporter | ||
Comment 2•3 years ago
|
||
(In reply to Dave Townsend [:mossop] from comment #1)
Seems that we re-initialize the command line after that notification on macOS for some reason: https://searchfox.org/mozilla-central/rev/00977c4e37865a92f1c15572ae4aea90e934b25b/toolkit/xre/nsAppRunner.cpp#5169
Thanks for the input, just checked on Windows and I don't reproduce the issue. I'll mark this as macos only.
Updated•3 years ago
|
Description
•