Bug 1621713 - Don't create extra ActorPools in devtools/server. r=jdescottes.

Remove pools and make target actors manage themselves.
devtools/server/tests/browser/browser_navigateEvents.js was modified
since the targetActor can't be retrieved with `searchAllConnectionsForActor`
anymore.

Differential Revision: https://phabricator.services.mozilla.com/D67510
This commit is contained in:
Nicolas Chevobbe 2020-06-24 07:38:09 +00:00
parent 1b52f1f63a
commit a67f596fa2
4 changed files with 12 additions and 42 deletions

View File

@ -249,7 +249,7 @@ class DevToolsFrameChild extends JSWindowActorChild {
const { DevToolsServer } = this.loader.require(
"devtools/server/devtools-server"
);
const { ActorPool } = this.loader.require("devtools/server/actors/common");
const { FrameTargetActor } = this.loader.require(
"devtools/server/actors/targets/frame"
);
@ -272,11 +272,7 @@ class DevToolsFrameChild extends JSWindowActorChild {
followWindowGlobalLifeCycle: true,
doNotFireFrameUpdates: true,
});
// Add the newly created actor to the connection pool.
const actorPool = new ActorPool(connection, "frame-child");
actorPool.addActor(targetActor);
connection.addActorPool(actorPool);
targetActor.manage(targetActor);
return { connection, targetActor };
}

View File

@ -79,11 +79,8 @@ function init(msg) {
const { ContentProcessTargetActor } = loader.require(
"devtools/server/actors/targets/content-process"
);
const { ActorPool } = loader.require("devtools/server/actors/common");
const actor = new ContentProcessTargetActor(conn);
const actorPool = new ActorPool(conn, "content-process");
actorPool.addActor(actor);
conn.addActorPool(actorPool);
actor.manage(actor);
const response = { actor: actor.form() };
mm.sendAsyncMessage("debug:content-process-actor", response);

View File

@ -42,7 +42,6 @@ try {
const DevToolsUtils = require("devtools/shared/DevToolsUtils");
const { dumpn } = DevToolsUtils;
const { DevToolsServer } = require("devtools/server/devtools-server");
const { ActorPool } = require("devtools/server/actors/common");
DevToolsServer.init();
// We want a special server without any root actor and only target-scoped actors.
@ -84,10 +83,7 @@ try {
// message manager.
actor = new FrameTargetActor(conn, docShell);
}
const actorPool = new ActorPool(conn, "frame-script");
actorPool.addActor(actor);
conn.addActorPool(actorPool);
actor.manage(actor);
sendAsyncMessage("debug:actor", { actor: actor.form(), prefix: prefix });
});

View File

@ -71,11 +71,6 @@ function assertEvent(event, data) {
"navigate",
"Then once the second doc is loaded, we get the navigate event"
);
is(
data.readyState,
"complete",
"navigate is emitted only once the document is fully loaded"
);
break;
case 9:
is(event, "tabNavigated", "Finally, the receive the client event");
@ -121,10 +116,17 @@ function onMessage({ data }) {
async function connectAndAttachTab(tab) {
const target = await TargetFactory.forTab(tab);
await target.attach();
const actorID = target.targetForm.actor;
const actorID = target.actorID;
target.on("tabNavigated", function(packet) {
assertEvent("tabNavigated", packet);
});
// In order to listen to internal will-navigate/navigate events
target.on("will-navigate", function(data) {
assertEvent("will-navigate", {
newURI: data.url,
});
});
target.on("navigate", () => assertEvent("navigate"));
return { target, actorID };
}
@ -145,27 +147,6 @@ add_task(async function() {
const tab = gBrowser.getTabForBrowser(browser);
const { target, actorID } = await connectAndAttachTab(tab);
await ContentTask.spawn(browser, [actorID], async function(actorId) {
const { require } = ChromeUtils.import(
"resource://devtools/shared/Loader.jsm"
);
const { DevToolsServer } = require("devtools/server/devtools-server");
const EventEmitter = require("devtools/shared/event-emitter");
// !Hack! Retrieve a server side object, the FrameTargetActor instance
const targetActor = DevToolsServer.searchAllConnectionsForActor(actorId);
// In order to listen to internal will-navigate/navigate events
EventEmitter.on(targetActor, "will-navigate", function(data) {
sendSyncMessage("devtools-test:event", {
event: "will-navigate",
data: { newURI: data.newURI },
});
});
EventEmitter.on(targetActor, "navigate", function(data) {
sendSyncMessage("devtools-test:event", {
event: "navigate",
data: { readyState: content.document.readyState },
});
});
// Forward DOMContentLoaded and load events
addEventListener(
"DOMContentLoaded",