2019-02-17 19:41:44 +03:00
|
|
|
|
Usage
|
|
|
|
|
=====
|
|
|
|
|
|
2020-09-22 18:46:35 +03:00
|
|
|
|
When using the CDP-based remote agent in Firefox, there are
|
2019-02-17 19:41:44 +03:00
|
|
|
|
three different programs/components running simultaneously:
|
|
|
|
|
|
|
|
|
|
* the __client__, being the out-of-process script or library
|
|
|
|
|
(such as Puppeteer) or web inspector frontend you use to control
|
|
|
|
|
and retrieve information out of Firefox;
|
|
|
|
|
|
|
|
|
|
* the __agent__ that the client connects to which is an HTTPD living
|
|
|
|
|
inside Firefox, facilitating communication between clients
|
|
|
|
|
and targets;
|
|
|
|
|
|
|
|
|
|
* and the __target__, which is the web document being debugging.
|
|
|
|
|
|
2019-12-02 18:39:51 +03:00
|
|
|
|
The remote agent ships in [Firefox Nightly] only.
|
2019-02-17 19:41:44 +03:00
|
|
|
|
|
2019-04-25 14:01:12 +03:00
|
|
|
|
To check if your Firefox binary has the remote agent enabled, you
|
|
|
|
|
can look in its help message for this:
|
2019-02-17 19:41:44 +03:00
|
|
|
|
|
|
|
|
|
% ./firefox -h
|
|
|
|
|
…
|
2020-10-07 16:50:57 +03:00
|
|
|
|
--remote-debugging-port [<port>] Start the Firefox remote agent, which is
|
2019-02-17 19:41:44 +03:00
|
|
|
|
a low-level debugging interface based on the CDP protocol.
|
|
|
|
|
Defaults to listen on localhost:9222.
|
|
|
|
|
…
|
|
|
|
|
|
2019-12-02 18:39:51 +03:00
|
|
|
|
When used, the remote agent will start an HTTP server and print a
|
|
|
|
|
message on stderr with the location of the main target’s WebSocket
|
|
|
|
|
listener:
|
|
|
|
|
|
2020-10-07 16:50:57 +03:00
|
|
|
|
% firefox --remote-debugging-port
|
2019-12-02 18:39:51 +03:00
|
|
|
|
DevTools listening on ws://localhost:9222/devtools/browser/7b4e84a4-597f-4839-ac6d-c9e86d16fb83
|
|
|
|
|
|
2020-10-07 16:50:57 +03:00
|
|
|
|
`--remote-debugging-port` takes an optional port as input:
|
2019-02-17 19:41:44 +03:00
|
|
|
|
|
2020-10-07 16:50:57 +03:00
|
|
|
|
[<port>]
|
2019-02-17 19:41:44 +03:00
|
|
|
|
|
|
|
|
|
You can use this to instruct the remote agent to bind to a particular
|
2020-10-07 16:50:57 +03:00
|
|
|
|
port on your system. port is optional,
|
|
|
|
|
which means `firefox --remote-debugging-port` will bind the HTTPD to
|
2019-02-17 19:41:44 +03:00
|
|
|
|
the default `localhost:9222`.
|
|
|
|
|
|
2020-10-07 16:50:57 +03:00
|
|
|
|
If port has been specified the default port will be overridden:
|
2019-02-17 19:41:44 +03:00
|
|
|
|
|
2020-10-07 16:50:57 +03:00
|
|
|
|
% firefox --remote-debugging-port 9989
|
|
|
|
|
DevTools listening on ws://localhost:9989/devtools/browser/b49481af-8ad3-9b4d-b1bf-bb0cdb9a0620
|
2019-02-17 19:41:44 +03:00
|
|
|
|
|
2020-10-07 16:50:57 +03:00
|
|
|
|
When you ask the remote agent to listen on port 0,
|
|
|
|
|
the system will atomically allocate an arbitrary free port:
|
2019-02-17 19:41:44 +03:00
|
|
|
|
|
2020-10-07 16:50:57 +03:00
|
|
|
|
% firefox --remote-debugging-port 0
|
|
|
|
|
DevTools listening on ws://localhost:59982/devtools/browser/a12b22a9-1b8b-954a-b81f-bd31552d3f1c
|
2019-02-17 19:41:44 +03:00
|
|
|
|
|
2019-03-11 16:14:19 +03:00
|
|
|
|
Allocating an atomic port can be useful if you want to avoid race
|
|
|
|
|
conditions. The atomically allocated port will be somewhere in the
|
|
|
|
|
ephemeral port range, which varies depending on your system and
|
|
|
|
|
system configuration, but is always guaranteed to be free thus
|
|
|
|
|
eliminating the risk of binding to a port that is already in use.
|
2019-02-17 19:41:44 +03:00
|
|
|
|
|
2019-04-25 14:01:12 +03:00
|
|
|
|
[Firefox Nightly]: https://www.mozilla.org/en-GB/firefox/channel/desktop/#nightly
|