Bug 1692965 - [devtools] Remove the ChromeWindowTargetActor r=ochameau,devtools-backward-compat-reviewers

The ChromeWindowTargetActor was not exposed to end users and doesn't support descriptors which will make it a blocker for fission refactors.
So we remove it for now.

Differential Revision: https://phabricator.services.mozilla.com/D105452
This commit is contained in:
Julian Descottes 2021-02-18 11:10:13 +00:00
Родитель 934a949ab6
Коммит 352bff0a66
12 изменённых файлов: 2 добавлений и 235 удалений

Просмотреть файл

@ -133,23 +133,6 @@ async function _targetFromURL(client, id, type, chrome) {
}
throw ex;
}
} else if (type == "window") {
// Fetch target for a remote window actor
DevToolsServer.allowChromeProcess = true;
try {
id = parseInt(id, 10);
if (isNaN(id)) {
throw new Error("targetFromURL, window requires id parameter");
}
front = await client.mainRoot.getWindow({
outerWindowID: id,
});
} catch (ex) {
if (ex.error == "notFound") {
throw new Error(`targetFromURL, window with id '${id}' doesn't exist`);
}
throw ex;
}
} else {
throw new Error(`targetFromURL, unsupported type '${type}' parameter`);
}

Просмотреть файл

@ -37,18 +37,8 @@ add_task(async function() {
is(e.message, "targetFromURL, unsupported type 'x' parameter");
}
info("Test browser window");
let windowId = window.docShell.outerWindowID;
target = await targetFromURL(
new URL("http://foo?type=window&id=" + windowId)
);
is(target.url, window.location.href);
is(target.isLocalTab, false);
is(target.chrome, true);
is(target.isBrowsingContext, true);
await target.client.close();
info("Test tab");
let windowId = window.docShell.outerWindowID;
windowId = browser.outerWindowID;
target = await targetFromURL(new URL("http://foo?type=tab&id=" + windowId));
assertTarget(target, TEST_URI);

Просмотреть файл

@ -299,7 +299,6 @@ function TargetMixin(parentClass) {
this.isAddon ||
this.isContentProcess ||
this.isParentProcess ||
this.isWindowTarget ||
this._forceChrome
);
}
@ -380,14 +379,6 @@ function TargetMixin(parentClass) {
);
}
get isWindowTarget() {
return !!(
this.targetForm &&
this.targetForm.actor &&
this.targetForm.actor.match(/conn\d+\.chromeWindowTarget\d+/)
);
}
get isMultiProcess() {
return !this.window;
}

Просмотреть файл

@ -76,12 +76,6 @@ RootActor (root.js)
| Returned by "listWorkers" request to a ContentProcessTargetActor to get
| workers for the chrome of the child process.
|
|-- ChromeWindowTargetActor (chrome-window.js)
| Targets a single window, such as a browser window in Firefox, but it can
| be used to reach any window in the parent process.
| Extends the abstract class BrowsingContextTargetActor.
| Returned by "getWindow" request to the root actor.
|
|-- ParentProcessTargetActor (parent-process.js)
| Targets all resources in the parent process of Firefox (chrome documents,
| JSMs, JS XPCOM, etc.).

Просмотреть файл

@ -19,12 +19,6 @@ const { DevToolsServer } = require("devtools/server/devtools-server");
const protocol = require("devtools/shared/protocol");
const { rootSpec } = require("devtools/shared/specs/root");
loader.lazyRequireGetter(
this,
"ChromeWindowTargetActor",
"devtools/server/actors/targets/chrome-window",
true
);
loader.lazyRequireGetter(
this,
"ProcessDescriptorActor",
@ -197,9 +191,6 @@ exports.RootActor = protocol.ActorClassWithSpec(rootSpec, {
if (this._globalActorPool) {
this._globalActorPool.destroy();
}
if (this._chromeWindowActorPool) {
this._chromeWindowActorPool.destroy();
}
if (this._addonTargetActorPool) {
this._addonTargetActorPool.destroy();
}
@ -217,7 +208,6 @@ exports.RootActor = protocol.ActorClassWithSpec(rootSpec, {
this.conn = null;
this._tabDescriptorActorPool = null;
this._globalActorPool = null;
this._chromeWindowActorPool = null;
this._parameters = null;
},
@ -314,34 +304,6 @@ exports.RootActor = protocol.ActorClassWithSpec(rootSpec, {
return descriptorActor;
},
getWindow: function({ outerWindowID }) {
if (!DevToolsServer.allowChromeProcess) {
throw {
error: "forbidden",
message: "You are not allowed to debug windows.",
};
}
const window = Services.wm.getOuterWindowWithId(outerWindowID);
if (!window) {
throw {
error: "notFound",
message: `No window found with outerWindowID ${outerWindowID}`,
};
}
if (!this._chromeWindowActorPool) {
this._chromeWindowActorPool = new Pool(this.conn, "chrome-window");
}
const actor = new ChromeWindowTargetActor(this.conn, window, {
isTopLevelTarget: true,
});
actor.parentID = this.actorID;
this._chromeWindowActorPool.manage(actor);
return actor;
},
onTabListChanged: function() {
this.conn.send({ from: this.actorID, type: "tabListChanged" });
/* It's a one-shot notification; no need to watch any more. */

Просмотреть файл

@ -14,8 +14,7 @@
* BrowsingContextTargetActor is an abstract class used by target actors that hold
* documents, such as frames, chrome windows, etc.
*
* This class is extended by FrameTargetActor, ParentProcessTargetActor, and
* ChromeWindowTargetActor.
* This class is extended by FrameTargetActor, ParentProcessTargetActor.
*
* See devtools/docs/backend/actor-hierarchy.md for more details.
*

Просмотреть файл

@ -1,118 +0,0 @@
/* 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/. */
"use strict";
/*
* Target actor for a single chrome window, like a browser window.
*
* This actor extends BrowsingContextTargetActor.
*
* See devtools/docs/backend/actor-hierarchy.md for more details.
*/
const { Ci } = require("chrome");
const Services = require("Services");
const {
BrowsingContextTargetActor,
browsingContextTargetPrototype,
} = require("devtools/server/actors/targets/browsing-context");
const { extend } = require("devtools/shared/extend");
const {
chromeWindowTargetSpec,
} = require("devtools/shared/specs/targets/chrome-window");
const Targets = require("devtools/server/actors/targets/index");
const TargetActorMixin = require("devtools/server/actors/targets/target-actor-mixin");
/**
* Protocol.js expects only the prototype object, and does not maintain the
* prototype chain when it constructs the ActorClass. For this reason we are using
* `extend` to maintain the properties of BrowsingContextTargetActor.prototype
*/
const chromeWindowTargetPrototype = extend({}, browsingContextTargetPrototype);
/**
* Creates a ChromeWindowTargetActor for debugging a single window, like a browser window
* in Firefox, but it can be used to reach any window in the process.
*
* Currently this is parent process only because the root actor's `onGetWindow` doesn't
* try to cross process boundaries. This actor technically would work for both chrome and
* content windows, but it can't reach (most) content windows since it's parent process
* only. Since these restrictions mean that chrome windows are the main use case for
* this at the moment, it's named to match.
*
* Most of the implementation is inherited from BrowsingContextTargetActor.
* ChromeWindowTargetActor exposes all target-scoped actors via its form() request, like
* BrowsingContextTargetActor.
*
* You can request a specific window's actor via RootActor.getWindow().
*
* @param connection DevToolsServerConnection
* The connection to the client.
* @param window DOMWindow
* The window.
* @param {Object} options
* - isTopLevelTarget: {Boolean} flag to indicate if this is the top
* level target of the DevTools session
*/
chromeWindowTargetPrototype.initialize = function(
connection,
window,
{ isTopLevelTarget }
) {
BrowsingContextTargetActor.prototype.initialize.call(this, connection, {
docShell: window.docShell,
isTopLevelTarget,
});
};
// Bug 1266561: This setting is mysteriously named, we should split up the
// functionality that is triggered by it.
chromeWindowTargetPrototype.isRootActor = true;
chromeWindowTargetPrototype.observe = function(subject, topic, data) {
BrowsingContextTargetActor.prototype.observe.call(this, subject, topic, data);
if (!this.attached) {
return;
}
if (topic == "chrome-webnavigation-destroy") {
this._onDocShellDestroy(subject);
}
};
chromeWindowTargetPrototype._attach = function() {
if (this.attached) {
return false;
}
BrowsingContextTargetActor.prototype._attach.call(this);
// Listen for chrome docshells in addition to content docshells
if (this.docShell.itemType == Ci.nsIDocShellTreeItem.typeChrome) {
Services.obs.addObserver(this, "chrome-webnavigation-destroy");
}
return true;
};
chromeWindowTargetPrototype._detach = function() {
if (!this.attached) {
return false;
}
if (this.docShell.itemType == Ci.nsIDocShellTreeItem.typeChrome) {
Services.obs.removeObserver(this, "chrome-webnavigation-destroy");
}
BrowsingContextTargetActor.prototype._detach.call(this);
return true;
};
exports.ChromeWindowTargetActor = TargetActorMixin(
Targets.TYPES.FRAME,
chromeWindowTargetSpec,
chromeWindowTargetPrototype
);

Просмотреть файл

@ -6,7 +6,6 @@
DevToolsModules(
"browsing-context.js",
"chrome-window.js",
"content-process.js",
"frame.js",
"index.js",

Просмотреть файл

@ -293,11 +293,6 @@ const Types = (exports.__TypesForTests = [
spec: "devtools/shared/specs/targets/browsing-context",
front: "devtools/client/fronts/targets/browsing-context",
},
{
types: ["chromeWindowTarget"],
spec: "devtools/shared/specs/targets/chrome-window",
front: null,
},
{
types: ["contentProcessTarget"],
spec: "devtools/shared/specs/targets/content-process",

Просмотреть файл

@ -44,15 +44,6 @@ const rootSpecPrototype = {
},
},
getWindow: {
request: {
outerWindowID: Option(0, "number"),
},
response: {
window: RetVal("browsingContextTarget"),
},
},
listAddons: {
request: {
iconDataURL: Option(0, "boolean"),

Просмотреть файл

@ -1,18 +0,0 @@
/* 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/. */
"use strict";
const { generateActorSpec } = require("devtools/shared/protocol");
const { extend } = require("devtools/shared/extend");
const {
browsingContextTargetSpecPrototype,
} = require("devtools/shared/specs/targets/browsing-context");
const chromeWindowTargetSpec = generateActorSpec(
extend(browsingContextTargetSpecPrototype, {
typeName: "chromeWindowTarget",
})
);
exports.chromeWindowTargetSpec = chromeWindowTargetSpec;

Просмотреть файл

@ -6,7 +6,6 @@
DevToolsModules(
"browsing-context.js",
"chrome-window.js",
"content-process.js",
"frame.js",
"parent-process.js",