2014-02-03 06:43:28 -08:00
|
|
|
/* 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/. */
|
2013-07-24 08:28:32 -07:00
|
|
|
|
2014-02-03 06:43:28 -08:00
|
|
|
"use strict";
|
2013-07-24 08:28:32 -07:00
|
|
|
|
2014-03-10 09:38:29 -07:00
|
|
|
let chromeGlobal = this;
|
|
|
|
|
2014-02-03 06:43:28 -08:00
|
|
|
// Encapsulate in its own scope to allows loading this frame script
|
|
|
|
// more than once.
|
|
|
|
(function () {
|
2014-03-04 06:38:05 -08:00
|
|
|
let { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
|
|
|
|
const DevToolsUtils = devtools.require("devtools/toolkit/DevToolsUtils.js");
|
2014-02-03 06:43:28 -08:00
|
|
|
const {DebuggerServer, ActorPool} = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
|
2013-07-24 08:28:32 -07:00
|
|
|
|
2014-02-03 06:43:28 -08:00
|
|
|
if (!DebuggerServer.initialized) {
|
|
|
|
DebuggerServer.init();
|
|
|
|
}
|
2013-07-24 08:28:32 -07:00
|
|
|
|
2014-02-03 06:43:28 -08:00
|
|
|
// In case of apps being loaded in parent process, DebuggerServer is already
|
|
|
|
// initialized, but child specific actors are not registered.
|
|
|
|
// Otherwise, for apps in child process, we need to load actors the first
|
|
|
|
// time we load child.js
|
|
|
|
DebuggerServer.addChildActors();
|
2013-07-24 08:28:32 -07:00
|
|
|
|
2014-02-03 06:43:28 -08:00
|
|
|
let onConnect = DevToolsUtils.makeInfallible(function (msg) {
|
|
|
|
removeMessageListener("debug:connect", onConnect);
|
2013-07-24 08:28:32 -07:00
|
|
|
|
2014-02-03 06:43:28 -08:00
|
|
|
let mm = msg.target;
|
2013-07-24 08:28:32 -07:00
|
|
|
|
2014-03-10 09:38:12 -07:00
|
|
|
let conn = DebuggerServer.connectToParent(msg.data.prefix, mm);
|
2013-07-24 08:28:32 -07:00
|
|
|
|
2014-03-10 09:38:29 -07:00
|
|
|
let actor = new DebuggerServer.ContentActor(conn, chromeGlobal);
|
2014-02-03 06:43:28 -08:00
|
|
|
let actorPool = new ActorPool(conn);
|
|
|
|
actorPool.addActor(actor);
|
|
|
|
conn.addActorPool(actorPool);
|
|
|
|
|
2014-03-10 09:38:12 -07:00
|
|
|
sendAsyncMessage("debug:actor", {actor: actor.grip()});
|
2014-02-03 06:43:28 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
addMessageListener("debug:connect", onConnect);
|
|
|
|
})();
|