Bug 1172897 - Rename BrowserTabActor to FrameTargetActorProxy. r=ochameau
MozReview-Commit-ID: 4Lho3CLV1t8
--- a/devtools/docs/backend/actor-hierarchy.md
+++ b/devtools/docs/backend/actor-hierarchy.md
@@ -47,36 +47,37 @@ The root actor is special. It is automat
It has a special `actorID` which is unique and is "root".
All other actors have an `actorID` which is computed dynamically,
so that you need to ask an existing actor to create an Actor
and returns its `actorID`. That's the main role of RootActor.
```
RootActor (root.js)
|
- |-- BrowserTabActor (webbrowser.js)
- | Targets tabs living in the parent or child process. Note that this is
- | just a proxy for FrameTargetActor, which is loaded via the tab's message
- | manager as a frame script in the process containing the tab. This proxy
- | via message manager is always used, even when e10s is disabled.
+ |-- FrameTargetActorProxy (frame-proxy.js)
+ | Targets frames (such as a tab) living in the parent or child process.
+ | Note that this is just a proxy for FrameTargetActor, which is loaded via
+ | the frame's message manager as a frame script in the process containing
+ | the frame content. This proxy via message manager is always used, even
+ | when the content happens to be in the same process.
| Returned by "listTabs" or "getTab" requests.
| |
| \-- FrameTargetActor (frame.js)
| The "real" target actor for a frame (such as a tab) which runs in
- | whichever process holds the content. BrowserTabActor communicates
- | with this via the frame's message manager.
+ | whichever process holds the content. FrameTargetActorProxy
+ | communicates with this via the frame's message manager.
| Extends the abstract class BrowsingContextTargetActor.
- | Returned by "connect" on BrowserTabActor.
+ | Returned by "connect" on FrameTargetActorProxy.
|
|-- WorkerActor (worker.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 BrowserTabActor to get workers for
- | a specific tab.
+ | 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)
| 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.
--- a/devtools/server/actors/common.js
+++ b/devtools/server/actors/common.js
@@ -100,18 +100,18 @@ ObservedActorFactory.prototype.createAct
// actor. Reusing the existing actor ID will make sure ActorPool.addActor
// does the right thing.
instance.actorID = this.actorID;
this.registeredPool.addActor(instance);
return instance;
};
exports.ObservedActorFactory = ObservedActorFactory;
-/**
- * Methods shared between RootActor and BrowserTabActor.
+/*
+ * Methods shared between RootActor and BrowsingContextTargetActor.
*/
/**
* Populate |this._extraActors| as specified by |factories|, reusing whatever
* actors are already there. Add all actors in the final extra actors table to
* |pool|.
*
* The root actor and the target actor use this to instantiate actors that other
@@ -120,18 +120,18 @@ exports.ObservedActorFactory = ObservedA
*
* @param factories
* An object whose own property names are the names of properties to add to
* some reply packet (say, a target actor grip or the "listTabs" response
* form), and whose own property values are actor constructor functions, as
* documented for addTabActor and addGlobalActor.
*
* @param this
- * The BrowserRootActor or BrowserTabActor with which the new actors will
- * be associated. It should support whatever API the |factories|
+ * The RootActor or BrowsingContextTargetActor with which the new actors
+ * will be associated. It should support whatever API the |factories|
* constructor functions might be interested in, as it is passed to them.
* For the sake of CommonCreateExtraActors itself, it should have at least
* the following properties:
*
* - _extraActors
* An object whose own property names are factory table (and packet)
* property names, and whose values are no-argument actor constructors,
* of the sort that one can add to an ActorPool.
@@ -168,17 +168,17 @@ exports.createExtraActors = function cre
* to CommonCreateExtraActors, to |object|.
*
* @param object
* The object to which the extra actors should be added, under the
* property names given in the |factories| table passed to
* CommonCreateExtraActors.
*
* @param this
- * The BrowserRootActor or BrowserTabActor whose |_extraActors| table we
+ * The RootActor or BrowsingContextTargetActor whose |_extraActors| table we
* should use; see above.
*/
exports.appendExtraActors = function appendExtraActors(object) {
for (const name in this._extraActors) {
const actor = this._extraActors[name];
object[name] = actor.actorID;
}
};
--- a/devtools/server/actors/moz.build
+++ b/devtools/server/actors/moz.build
@@ -22,17 +22,16 @@ DevToolsModules(
'actor-registry.js',
'addon-console.js',
'addon.js',
'addons.js',
'animation-type-longhand.js',
'animation.js',
'array-buffer.js',
'breakpoint.js',
- 'browser-tab.js',
'call-watcher.js',
'canvas.js',
'child-process.js',
'chrome.js',
'common.js',
'css-properties.js',
'csscoverage.js',
'device.js',
rename from devtools/server/actors/browser-tab.js
rename to devtools/server/actors/targets/frame-proxy.js
--- a/devtools/server/actors/browser-tab.js
+++ b/devtools/server/actors/targets/frame-proxy.js
@@ -1,44 +1,52 @@
/* 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 proxy that represents a frame / docShell in the parent process. It
+ * launches a FrameTargetActor in the content process to do the real work and tunnels the
+ * data.
+ *
+ * See devtools/docs/backend/actor-hierarchy.md for more details.
+ */
+
const { DebuggerServer } = require("devtools/server/main");
loader.lazyImporter(this, "PlacesUtils", "resource://gre/modules/PlacesUtils.jsm");
/**
- * Creates a target actor for handling requests to a single browser frame.
+ * Creates a target actor proxy for handling requests to a single browser frame.
* Both <xul:browser> and <iframe mozbrowser> are supported.
* This actor is a shim that connects to a FrameTargetActor in a remote browser process.
* All RDP packets get forwarded using the message manager.
*
* @param connection The main RDP connection.
* @param browser <xul:browser> or <iframe mozbrowser> element to connect to.
* @param options
* - {Boolean} favicons: true if the form should include the favicon for the tab.
*/
-function BrowserTabActor(connection, browser, options = {}) {
+function FrameTargetActorProxy(connection, browser, options = {}) {
this._conn = connection;
this._browser = browser;
this._form = null;
this.exited = false;
this.options = options;
}
-BrowserTabActor.prototype = {
+FrameTargetActorProxy.prototype = {
async connect() {
const onDestroy = () => {
if (this._deferredUpdate) {
// Reject the update promise if the tab was destroyed while requesting an update
this._deferredUpdate.reject({
error: "tabDestroyed",
- message: "Tab destroyed while performing a BrowserTabActor update"
+ message: "Tab destroyed while performing a FrameTargetActorProxy update"
});
}
this.exit();
};
const connect = DebuggerServer.connectToFrame(this._conn, this._browser, onDestroy);
const form = await connect;
this._form = form;
@@ -70,20 +78,20 @@ BrowserTabActor.prototype = {
} catch (e) {
// Favicon unavailable for this url.
return null;
}
},
/**
* @param {Object} options
- * See BrowserTabActor constructor.
+ * See FrameTargetActorProxy constructor.
*/
async update(options = {}) {
- // Update the BrowserTabActor options.
+ // Update the FrameTargetActorProxy options.
this.options = options;
// If the child happens to be crashed/close/detach, it won't have _form set,
// so only request form update if some code is still listening on the other
// side.
if (this.exited) {
return this.connect();
}
@@ -167,9 +175,9 @@ BrowserTabActor.prototype = {
exit() {
this._browser = null;
this._form = null;
this.exited = true;
},
};
-exports.BrowserTabActor = BrowserTabActor;
+exports.FrameTargetActorProxy = FrameTargetActorProxy;
--- a/devtools/server/actors/targets/moz.build
+++ b/devtools/server/actors/targets/moz.build
@@ -1,10 +1,11 @@
# -*- 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',
+ 'frame-proxy.js',
'frame.js',
)
--- a/devtools/server/actors/webbrowser.js
+++ b/devtools/server/actors/webbrowser.js
@@ -7,17 +7,17 @@
"use strict";
var { Ci } = require("chrome");
var Services = require("Services");
var { DebuggerServer } = require("devtools/server/main");
var DevToolsUtils = require("devtools/shared/DevToolsUtils");
loader.lazyRequireGetter(this, "RootActor", "devtools/server/actors/root", true);
-loader.lazyRequireGetter(this, "BrowserTabActor", "devtools/server/actors/browser-tab", true);
+loader.lazyRequireGetter(this, "FrameTargetActorProxy", "devtools/server/actors/targets/frame-proxy", true);
loader.lazyRequireGetter(this, "BrowserAddonActor", "devtools/server/actors/addon", true);
loader.lazyRequireGetter(this, "WebExtensionParentActor", "devtools/server/actors/webextension-parent", true);
loader.lazyRequireGetter(this, "WorkerActorList", "devtools/server/actors/worker-list", true);
loader.lazyRequireGetter(this, "ServiceWorkerRegistrationActorList", "devtools/server/actors/worker-list", true);
loader.lazyRequireGetter(this, "ProcessActorList", "devtools/server/actors/process", true);
loader.lazyImporter(this, "AddonManager", "resource://gre/modules/AddonManager.jsm");
/**
@@ -79,21 +79,21 @@ function createRootActor(connection) {
new ServiceWorkerRegistrationActorList(connection),
processList: new ProcessActorList(),
globalActorFactories: DebuggerServer.globalActorFactories,
onShutdown: sendShutdownEvent
});
}
/**
- * A live list of BrowserTabActors representing the current browser tabs,
+ * A live list of FrameTargetActorProxys representing the current browser tabs,
* to be provided to the root actor to answer 'listTabs' requests.
*
* This object also takes care of listening for TabClose events and
- * onCloseWindow notifications, and exiting the BrowserTabActors concerned.
+ * onCloseWindow notifications, and exiting the target actors concerned.
*
* (See the documentation for RootActor for the definition of the "live
* list" interface.)
*
* @param connection DebuggerServerConnection
* The connection in which this list's tab actors may participate.
*
* Some notes:
@@ -225,19 +225,17 @@ BrowserTabList.prototype._getSelectedBro
/**
* Produces an iterable (in this case a generator) to enumerate all available
* browser tabs.
*/
BrowserTabList.prototype._getBrowsers = function* () {
// Iterate over all navigator:browser XUL windows.
for (const win of allAppShellDOMWindows(DebuggerServer.chromeWindowType)) {
// For each tab in this XUL window, ensure that we have an actor for
- // it, reusing existing actors where possible. We actually iterate
- // over 'browser' XUL elements, and BrowserTabActor uses
- // browser.contentWindow as the debuggee global.
+ // it, reusing existing actors where possible.
for (const browser of this._getChildren(win)) {
yield browser;
}
}
};
BrowserTabList.prototype._getChildren = function(window) {
if (!window.gBrowser) {
@@ -304,27 +302,27 @@ BrowserTabList.prototype.getList = funct
return Promise.all(actorPromises).then(values => {
// Filter out null values if we received a tabDestroyed error.
return values.filter(value => value != null);
});
};
/**
- * @param browserActorOptions see options argument of BrowserTabActor constructor.
+ * @param browserActorOptions see options argument of FrameTargetActorProxy constructor.
*/
BrowserTabList.prototype._getActorForBrowser = function(browser, browserActorOptions) {
// Do we have an existing actor for this browser? If not, create one.
let actor = this._actorByBrowser.get(browser);
if (actor) {
this._foundCount++;
return actor.update(browserActorOptions);
}
- actor = new BrowserTabActor(this._connection, browser, browserActorOptions);
+ actor = new FrameTargetActorProxy(this._connection, browser, browserActorOptions);
this._actorByBrowser.set(browser, actor);
this._checkListening();
return actor.connect();
};
BrowserTabList.prototype.getTab = function({ outerWindowID, tabId }) {
if (typeof outerWindowID == "number") {
// First look for in-process frames with this ID
@@ -414,17 +412,17 @@ BrowserTabList.prototype._notifyListChan
/**
* Exit |actor|, belonging to |browser|, and notify the onListChanged
* handle if needed.
*/
BrowserTabList.prototype._handleActorClose = function(actor, browser) {
if (this._testing) {
if (this._actorByBrowser.get(browser) !== actor) {
- throw new Error("BrowserTabActor not stored in map under given browser");
+ throw new Error("FrameTargetActorProxy not stored in map under given browser");
}
if (actor.browser !== browser) {
throw new Error("actor's browser and map key don't match");
}
}
this._actorByBrowser.delete(browser);
actor.exit();
--- a/devtools/server/tests/browser/browser_navigateEvents.js
+++ b/devtools/server/tests/browser/browser_navigateEvents.js
@@ -126,17 +126,17 @@ add_task(async function() {
browser.messageManager.addMessageListener("devtools-test:event", onMessage);
const { client, actorID } = await connectAndAttachTab();
await ContentTask.spawn(browser, [actorID], async function(actorId) {
const { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
const { DebuggerServer } = require("devtools/server/main");
const EventEmitter = require("devtools/shared/event-emitter");
- // !Hack! Retrieve a server side object, the BrowserTabActor instance
+ // !Hack! Retrieve a server side object, the FrameTargetActor instance
const targetActor = DebuggerServer.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 }
});
});