зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1364075 - remove DevTools dependency in ContentProcessSingleton;r=ochameau
MozReview-Commit-ID: 38XKKM37jC5 --HG-- extra : rebase_source : 65b3aced59a7f5ceca35b2941c1ab1c80ac89b2b
This commit is contained in:
Родитель
c1ee57eb54
Коммит
9bedf05e44
|
@ -857,6 +857,9 @@ var gDevToolsBrowser = exports.gDevToolsBrowser = {
|
|||
gDevToolsBrowser._forgetBrowserWindow(win);
|
||||
}
|
||||
|
||||
// Remove scripts loaded in content process to support the Browser Content Toolbox.
|
||||
DebuggerServer.removeContentServerScript();
|
||||
|
||||
gDevTools.destroy({ shuttingDown });
|
||||
},
|
||||
};
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/* global addMessageListener, removeMessageListener */
|
||||
|
||||
"use strict";
|
||||
|
||||
const { utils: Cu } = Components;
|
||||
const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
|
||||
|
||||
function onInit(message) {
|
||||
// Only reply if we are in a real content process
|
||||
if (Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT) {
|
||||
let {init} = Cu.import("resource://devtools/server/content-server.jsm", {});
|
||||
init(message);
|
||||
}
|
||||
}
|
||||
|
||||
function onClose() {
|
||||
removeMessageListener("debug:init-content-server", onInit);
|
||||
removeMessageListener("debug:close-content-server", onClose);
|
||||
}
|
||||
|
||||
addMessageListener("debug:init-content-server", onInit);
|
||||
addMessageListener("debug:close-content-server", onClose);
|
|
@ -69,6 +69,9 @@ if (isWorker) {
|
|||
Services.prefs.getBoolPref(VERBOSE_PREF);
|
||||
}
|
||||
|
||||
const CONTENT_PROCESS_DBG_SERVER_SCRIPT =
|
||||
"resource://devtools/server/content-process-debugger-server.js";
|
||||
|
||||
function loadSubScript(url) {
|
||||
try {
|
||||
let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
||||
|
@ -149,6 +152,8 @@ function ModuleAPI() {
|
|||
var DebuggerServer = {
|
||||
_listeners: [],
|
||||
_initialized: false,
|
||||
// Flag to check if the content process debugger server script was already loaded.
|
||||
_contentProcessScriptLoaded: false,
|
||||
// Map of global actor names to actor constructors provided by extensions.
|
||||
globalActorFactories: {},
|
||||
// Map of tab actor names to actor constructors provided by extensions.
|
||||
|
@ -755,7 +760,16 @@ var DebuggerServer = {
|
|||
deferred.resolve(actor);
|
||||
});
|
||||
|
||||
mm.sendAsyncMessage("DevTools:InitDebuggerServer", {
|
||||
// Load the content process debugger server script only once.
|
||||
if (!this._contentProcessScriptLoaded) {
|
||||
// Load the process script that will receive the debug:init-content-server message
|
||||
Services.ppmm.loadProcessScript(CONTENT_PROCESS_DBG_SERVER_SCRIPT, true);
|
||||
this._contentProcessScriptLoaded = true;
|
||||
}
|
||||
|
||||
// Send a message to the content process debugger server script to forward it the
|
||||
// prefix.
|
||||
mm.sendAsyncMessage("debug:init-content-server", {
|
||||
prefix: prefix
|
||||
});
|
||||
|
||||
|
@ -1368,6 +1382,20 @@ var DebuggerServer = {
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Called when DevTools are unloaded to remove the contend process server script for the
|
||||
* list of scripts loaded for each new content process. Will also remove message
|
||||
* listeners from already loaded scripts.
|
||||
*/
|
||||
removeContentServerScript() {
|
||||
Services.ppmm.removeDelayedProcessScript(CONTENT_PROCESS_DBG_SERVER_SCRIPT);
|
||||
try {
|
||||
Services.ppmm.broadcastAsyncMessage("debug:close-content-server");
|
||||
} catch (e) {
|
||||
// Nothing to do
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* ⚠ TESTING ONLY! ⚠ Searches all active connections for an actor matching an ID.
|
||||
* This is helpful for some tests which depend on reaching into the server to check some
|
||||
|
|
|
@ -18,6 +18,7 @@ XPCSHELL_TESTS_MANIFESTS += ['tests/unit/xpcshell.ini']
|
|||
|
||||
DevToolsModules(
|
||||
'child.js',
|
||||
'content-process-debugger-server.js',
|
||||
'content-server.jsm',
|
||||
'css-logic.js',
|
||||
'event-parsers.js',
|
||||
|
|
|
@ -49,7 +49,6 @@ ContentProcessSingleton.prototype = {
|
|||
case "app-startup": {
|
||||
Services.obs.addObserver(this, "console-api-log-event");
|
||||
Services.obs.addObserver(this, "xpcom-shutdown");
|
||||
cpmm.addMessageListener("DevTools:InitDebuggerServer", this);
|
||||
TelemetryController.observe(null, topic, null);
|
||||
break;
|
||||
}
|
||||
|
@ -103,19 +102,9 @@ ContentProcessSingleton.prototype = {
|
|||
case "xpcom-shutdown":
|
||||
Services.obs.removeObserver(this, "console-api-log-event");
|
||||
Services.obs.removeObserver(this, "xpcom-shutdown");
|
||||
cpmm.removeMessageListener("DevTools:InitDebuggerServer", this);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
receiveMessage(message) {
|
||||
// load devtools component on-demand
|
||||
// Only reply if we are in a real content process
|
||||
if (Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_CONTENT) {
|
||||
let {init} = Cu.import("resource://devtools/server/content-server.jsm", {});
|
||||
init(message);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([ContentProcessSingleton]);
|
||||
|
|
Загрузка…
Ссылка в новой задаче