Bug 1172897 - Rename WindowActor to ChromeWindowTargetActor. r=ochameau
MozReview-Commit-ID: 8ZcDQTHEUkO
--- a/devtools/docs/backend/actor-hierarchy.md
+++ b/devtools/docs/backend/actor-hierarchy.md
@@ -71,17 +71,17 @@ RootActor (root.js)
| Targets a worker (applies to various kinds like web worker, service
| worker, etc.).
| Returned by "listWorkers" request to the root actor to get all workers.
| Returned by "listWorkers" request to a FrameTargetActorProxy to get
| workers for a specific frame.
| Returned by "listWorkers" request to a ChildProcessActor to get workers
| for the chrome of the child process.
|
- |-- WindowActor (window.js)
+ |-- 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.
|
|-- ChromeActor (chrome.js)
| Targets all resources in the parent process of firefox
| (chrome documents, JSM, JS XPCOM, etc.).
--- a/devtools/server/actors/moz.build
+++ b/devtools/server/actors/moz.build
@@ -67,17 +67,16 @@ DevToolsModules(
'timeline.js',
'webaudio.js',
'webbrowser.js',
'webconsole.js',
'webextension-inspected-window.js',
'webextension-parent.js',
'webextension.js',
'webgl.js',
- 'window.js',
)
with Files('animation.js'):
BUG_COMPONENT = ('Firefox', 'Developer Tools: Animation Inspector')
with Files('breakpoint.js'):
BUG_COMPONENT = ('Firefox', 'Developer Tools: Debugger')
--- a/devtools/server/actors/root.js
+++ b/devtools/server/actors/root.js
@@ -6,18 +6,18 @@
"use strict";
const { Cu } = require("chrome");
const Services = require("Services");
const { ActorPool, appendExtraActors, createExtraActors } = require("devtools/server/actors/common");
const { DebuggerServer } = require("devtools/server/main");
-loader.lazyRequireGetter(this, "WindowActor",
- "devtools/server/actors/window", true);
+loader.lazyRequireGetter(this, "ChromeWindowTargetActor",
+ "devtools/server/actors/targets/chrome-window", true);
/* Root actor for the remote debugging protocol. */
/**
* Create a remote debugging protocol root actor.
*
* @param connection
* The DebuggerServerConnection whose root actor we are constructing.
@@ -146,17 +146,17 @@ RootActor.prototype = {
memoryActorAllocations: true,
// Added in Firefox 40. Indicates that the backend supports registering custom
// commands through the WebConsoleCommands API.
webConsoleCommands: true,
// Whether root actor exposes chrome target actors and access to any window.
// If allowChromeProcess is true, you can:
// * get a ChromeActor instance to debug chrome and any non-content
// resource via getProcess requests
- // * get a WindowActor instance to debug windows which could be chrome,
+ // * get a ChromeWindowTargetActor instance to debug windows which could be chrome,
// like browser windows via getWindow requests
// If allowChromeProcess is defined, but not true, it means that root actor
// no longer expose chrome target actors, but also that the above requests are
// forbidden for security reasons.
get allowChromeProcess() {
return DebuggerServer.allowChromeProcess;
},
// Whether or not `getProfile()` supports specifying a `startTime`
@@ -216,17 +216,17 @@ RootActor.prototype = {
}
if (typeof this._parameters.onShutdown === "function") {
this._parameters.onShutdown();
}
this._extraActors = null;
this.conn = null;
this._tabActorPool = null;
this._globalActorPool = null;
- this._windowActorPool = null;
+ this._chromeWindowActorPool = null;
this._parameters = null;
this._chromeActor = null;
this._processActors.clear();
},
/**
* Gets the "root" form, which lists all the global actors that affect the entire
* browser. This can replace usages of `listTabs` that only wanted the global actors
@@ -359,24 +359,24 @@ RootActor.prototype = {
if (!window) {
return {
from: this.actorID,
error: "notFound",
message: `No window found with outerWindowID ${outerWindowID}`,
};
}
- if (!this._windowActorPool) {
- this._windowActorPool = new ActorPool(this.conn);
- this.conn.addActorPool(this._windowActorPool);
+ if (!this._chromeWindowActorPool) {
+ this._chromeWindowActorPool = new ActorPool(this.conn);
+ this.conn.addActorPool(this._chromeWindowActorPool);
}
- const actor = new WindowActor(this.conn, window);
+ const actor = new ChromeWindowTargetActor(this.conn, window);
actor.parentID = this.actorID;
- this._windowActorPool.addActor(actor);
+ this._chromeWindowActorPool.addActor(actor);
return {
from: this.actorID,
window: actor.form(),
};
},
onTabListChanged: function() {
--- a/devtools/server/actors/targets/browsing-context.js
+++ b/devtools/server/actors/targets/browsing-context.js
@@ -5,17 +5,17 @@
"use strict";
/* global XPCNativeWrapper */
/*
* BrowsingContextTargetActor is an abstract class used by target actors that hold
* documents, such as frames, chrome windows, etc.
*
- * This class is extended by FrameTargetActor, ChromeActor, and WindowActor.
+ * This class is extended by FrameTargetActor, ChromeActor, and ChromeWindowTargetActor.
*
* See devtools/docs/backend/actor-hierarchy.md for more details.
*
* For performance matters, this file should only be loaded in the targeted context's
* process. For example, it shouldn't be evaluated in the parent process until we try to
* debug a document living in the parent process.
*/
rename from devtools/server/actors/window.js
rename to devtools/server/actors/targets/chrome-window.js
--- a/devtools/server/actors/window.js
+++ b/devtools/server/actors/targets/chrome-window.js
@@ -1,95 +1,109 @@
/* 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 { ActorClassWithSpec } = require("devtools/shared/protocol");
-const { browsingContextTargetSpec } = require("devtools/shared/specs/targets/browsing-context");
+const { chromeWindowTargetSpec } = require("devtools/shared/specs/targets/chrome-window");
+
+/**
+ * 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 WindowActor 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.) Both chrome and content windows are supported.
+ * 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.
*
- * Most of the implementation is inherited from BrowsingContextTargetActor. WindowActor
- * exposes all tab actors via its form() request, like BrowsingContextTargetActor.
+ * 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 tab actors via its form() request, like
+ * BrowsingContextTargetActor.
*
* You can request a specific window's actor via RootActor.getWindow().
*
- * Caveat: 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
- *
* @param connection DebuggerServerConnection
* The connection to the client.
* @param window DOMWindow
* The window.
*/
-
-const windowPrototype = extend({}, browsingContextTargetPrototype);
-
-windowPrototype.initialize = function(connection, window) {
+chromeWindowTargetPrototype.initialize = function(connection, window) {
BrowsingContextTargetActor.prototype.initialize.call(this, connection);
const docShell = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDocShell);
Object.defineProperty(this, "docShell", {
value: docShell,
configurable: true
});
};
// Bug 1266561: This setting is mysteriously named, we should split up the
// functionality that is triggered by it.
-windowPrototype.isRootActor = true;
+chromeWindowTargetPrototype.isRootActor = true;
-windowPrototype.observe = function(subject, topic, data) {
+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);
}
};
-windowPrototype._attach = function() {
+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;
};
-windowPrototype._detach = function() {
+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.WindowActor = ActorClassWithSpec(browsingContextTargetSpec, windowPrototype);
+exports.ChromeWindowTargetActor =
+ ActorClassWithSpec(chromeWindowTargetSpec, chromeWindowTargetPrototype);
--- a/devtools/server/actors/targets/moz.build
+++ b/devtools/server/actors/targets/moz.build
@@ -1,12 +1,13 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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/.
DevToolsModules(
'browsing-context.js',
+ 'chrome-window.js',
'frame-proxy.js',
'frame.js',
'worker.js',
)
--- a/devtools/shared/client/root-client.js
+++ b/devtools/shared/client/root-client.js
@@ -236,17 +236,17 @@ RootClient.prototype = {
throw new Error("Unsupported argument given to getTab request");
}
}
return this.request(packet);
},
/**
- * Fetch the WindowActor for a specific window, like a browser window in
+ * Fetch the ChromeWindowTargetActor for a specific window, like a browser window in
* Firefox, but it can be used to reach any window in the process.
*
* @param number outerWindowID
* The outerWindowID of the top level window you are looking for.
*/
getWindow: function({ outerWindowID }) {
if (!outerWindowID) {
throw new Error("Must specify outerWindowID");
--- a/devtools/shared/specs/index.js
+++ b/devtools/shared/specs/index.js
@@ -215,16 +215,21 @@ const Types = exports.__TypesForTests =
front: null,
},
{
types: ["browsingContextTarget"],
spec: "devtools/shared/specs/targets/browsing-context",
front: null,
},
{
+ types: ["chromeWindowTarget"],
+ spec: "devtools/shared/specs/targets/chrome-window",
+ front: null,
+ },
+ {
types: ["frameTarget"],
spec: "devtools/shared/specs/targets/frame",
front: null,
},
{
types: ["workerTarget"],
spec: "devtools/shared/specs/targets/worker",
front: null,
new file mode 100644
--- /dev/null
+++ b/devtools/shared/specs/targets/chrome-window.js
@@ -0,0 +1,17 @@
+/* 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;
--- a/devtools/shared/specs/targets/moz.build
+++ b/devtools/shared/specs/targets/moz.build
@@ -1,11 +1,12 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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/.
DevToolsModules(
'browsing-context.js',
+ 'chrome-window.js',
'frame.js',
'worker.js',
)