Bug 1416105 - devtools/server/child.js should call DebuggerServer.addBrowserActorsadd when initializes a DebuggerServer running in the main process.
When web-ext (the nodejs CLI tool which is often used to develop a WebExtension)
starts Firefox with the --start-debugger-server CLI parameter,
devtools/shims/devtools-startup.js creates a DebuggerServer instance in an
isolated separate module loader, marked invisible to the debugger so that
we can use it to debug the regular DebuggerServer instance (loaded internally
when the user is going to open one of the developer tools for the first time).
Right after this "debugger invisible" DebuggerServer instance is started,
web-ext connects to the debugger server and interacts with the RDP actors
(e.g. to list the addons actors, install the extensions temporarily, reload
the extensions etc.), and as a side-effect of connecting to the WebExtensions
RDP actor, the "devtools/server/child.js" module is going to be loaded,
and it will be loaded in the main process if the webextensions are not
configured to run in a separate extension child process
(on the contrary it would be loaded in a child process when the
the extensions are running in oop mode).
If the regular developer tools have been already opened by the user (e.g.
when --jsconsole has been passed to the Firefox command line, which
is what happens when web-ext is executed with the --bc command line option),
the DebuggerServer is initialized and the browser actors added to it,
on the contrary when the "devtools/server/child.js" module initializes
the DebuggerServer module for the first time, it doesn't add the browser actors
to it and so the DebuggerServer instance is going initialized but it will be
missing the createRootActor attribute (which is expected if the DebuggerServer
instance is initialized in a child process, but it is unexpected when the DebuggerServer
instance is the one that serves the main process).
MozReview-Commit-ID: GE51X14HfHJ
--- a/devtools/client/webconsole/hudservice.js
+++ b/devtools/client/webconsole/hudservice.js
@@ -185,18 +185,23 @@ HUD_SERVICE.prototype =
this._browserConsoleDefer = defer();
function connect()
{
let deferred = defer();
if (!DebuggerServer.initialized) {
DebuggerServer.init();
- DebuggerServer.addBrowserActors();
}
+
+ // Ensure that the root actor and the tab actors have been registered on the DebuggerServer,
+ // so that the Browser Console can retrieve the console actors.
+ // (See Bug 1416105 for rationale).
+ DebuggerServer.registerActors({ root: true, browser: false, tab: true });
+
DebuggerServer.allowChromeProcess = true;
let client = new DebuggerClient(DebuggerServer.connectPipe());
return client.connect()
.then(() => client.getProcess())
.then(aResponse => {
// Use a TabActor in order to ensure calling `attach` to the ChromeActor
return { form: aResponse.form, client, chrome: true, isTabActor: true };