Bug 1466733 - Rename WebExtension parent actors. r=ochameau
MozReview-Commit-ID: 6utlvMrDIBT
--- a/devtools/client/framework/target.js
+++ b/devtools/client/framework/target.js
@@ -416,17 +416,17 @@ TabTarget.prototype = {
// Enable being able to get child process actors
DebuggerServer.allowChromeProcess = true;
this._client = new DebuggerClient(DebuggerServer.connectPipe());
// A local TabTarget will never perform chrome debugging.
this._chrome = false;
} else if (this._form.isWebExtension &&
this.client.mainRoot.traits.webExtensionAddonConnect) {
- // The addonTargetActor form is related to a WebExtensionParentActor instance,
+ // The addonTargetActor form is related to a WebExtensionActor instance,
// which isn't a target actor on its own, it is an actor living in the parent
// process with access to the addon metadata, it can control the addon (e.g.
// reloading it) and listen to the AddonManager events related to the lifecycle of
// the addon (e.g. when the addon is disabled or uninstalled).
// To retrieve the target actor instance, we call its "connect" method, (which
// fetches the target actor form from a WebExtensionTargetActor instance).
const {form} = await this._client.request({
to: this._form.actor, type: "connect",
--- a/devtools/docs/backend/actor-hierarchy.md
+++ b/devtools/docs/backend/actor-hierarchy.md
@@ -60,17 +60,17 @@ RootActor (root.js)
| 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. FrameTargetActorProxy
| communicates with this via the frame's message manager.
| Extends the abstract class BrowsingContextTargetActor.
- | Returned by "connect" on FrameTargetActorProxy.
+ | Returned by "connect" server method on FrameTargetActorProxy.
|
|-- WorkerTargetActor (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 FrameTargetActorProxy to get
| workers for a specific frame.
| Returned by "listWorkers" request to a ContentProcessTargetActor to get
@@ -94,20 +94,30 @@ RootActor (root.js)
| frame scripts, documents, etc.)
| Returned by "getProcess" request with a id argument, matching the
| targeted process.
|
|-- AddonTargetActor (addon.js)
| Targets a legacy (non-WebExtension) add-on.
| Returned by "listAddons" request.
|
- \-- WebExtensionTargetActor (webextension.js)
- Targets a WebExtension add-on.
- Extends ParentProcessTargetActor.
+ \-- WebExtensionActor (addon/webextension.js)
+ Represents a WebExtension add-on in the parent process. This gives some
+ metadata about the add-on and watches for uninstall events. This uses a
+ proxy to access the actual WebExtension in the WebExtension process via
+ the message manager.
Returned by "listAddons" request.
+ |
+ \-- WebExtensionTargetActor (targets/webextension.js)
+ Targets a WebExtension add-on. This runs in the WebExtension process.
+ The client issues an additional "connect" request to
+ WebExtensionActor to get this actor, which is different from the
+ approach used for frame target actors.
+ Extends ParentProcessTargetActor.
+ Returned by "connect" request to WebExtensionActor.
```
## Target Actors
Those are the actors exposed by the root actors which are meant to track the
lifetime of a given target: tab, process, add-on, or worker. It also allows to
fetch the tab-scoped actors connected to this target, which are actors like
console, inspector, thread (for debugger), style inspector, etc.
--- a/devtools/server/actors/addon/moz.build
+++ b/devtools/server/actors/addon/moz.build
@@ -3,10 +3,10 @@
# 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(
'addons.js',
'console.js',
'webextension-inspected-window.js',
- 'webextension-parent.js',
+ 'webextension.js',
)
rename from devtools/server/actors/addon/webextension-parent.js
rename to devtools/server/actors/addon/webextension.js
--- a/devtools/server/actors/addon/webextension-parent.js
+++ b/devtools/server/actors/addon/webextension.js
@@ -1,59 +1,67 @@
/* 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";
+/*
+ * Represents a WebExtension add-on in the parent process. This gives some metadata about
+ * the add-on and watches for uninstall events. This uses a proxy to access the
+ * WebExtension in the WebExtension process via the message manager.
+ *
+ * See devtools/docs/backend/actor-hierarchy.md for more details.
+ */
+
const {DebuggerServer} = require("devtools/server/main");
const protocol = require("devtools/shared/protocol");
-const {webExtensionSpec} = require("devtools/shared/specs/addon/webextension-parent");
+const {webExtensionSpec} = require("devtools/shared/specs/addon/webextension");
loader.lazyImporter(this, "AddonManager", "resource://gre/modules/AddonManager.jsm");
loader.lazyImporter(this, "ExtensionParent", "resource://gre/modules/ExtensionParent.jsm");
/**
* Creates the actor that represents the addon in the parent process, which connects
- * itself to a WebExtensionTargetActor counterpart which is created in the
- * extension process (or in the main process if the WebExtensions OOP mode is disabled).
+ * itself to a WebExtensionTargetActor counterpart which is created in the extension
+ * process (or in the main process if the WebExtensions OOP mode is disabled).
*
- * The WebExtensionParentActor subscribes itself as an AddonListener on the AddonManager
+ * The WebExtensionActor subscribes itself as an AddonListener on the AddonManager
* and forwards this events to child actor (e.g. on addon reload or when the addon is
* uninstalled completely) and connects to the child extension process using a `browser`
* element provided by the extension internals (it is not related to any single extension,
* but it will be created automatically to the currently selected "WebExtensions OOP mode"
* and it persist across the extension reloads (it is destroyed once the actor exits).
* WebExtensionActor is a child of RootActor, it can be retrieved via
* RootActor.listAddons request.
*
* @param {DebuggerServerConnection} conn
* The connection to the client.
* @param {AddonWrapper} addon
* The target addon.
*/
-const WebExtensionParentActor = protocol.ActorClassWithSpec(webExtensionSpec, {
+const WebExtensionActor = protocol.ActorClassWithSpec(webExtensionSpec, {
initialize(conn, addon) {
this.conn = conn;
this.addon = addon;
this.id = addon.id;
this._childFormPromise = null;
AddonManager.addAddonListener(this);
},
destroy() {
AddonManager.removeAddonListener(this);
this.addon = null;
this._childFormPromise = null;
- if (this._destroyProxyChildActor) {
- this._destroyProxyChildActor();
- delete this._destroyProxyChildActor;
+ if (this._destroyProxy) {
+ this._destroyProxy();
+ delete this._destroyProxy;
}
},
setOptions() {
// NOTE: not used anymore for webextensions, still used in the legacy addons,
// addon manager is currently going to call it automatically on every addon.
},
@@ -81,40 +89,40 @@ const WebExtensionParentActor = protocol
};
},
connect() {
if (this._childFormPormise) {
return this._childFormPromise;
}
- const proxy = new ProxyChildActor(this.conn, this);
+ const proxy = new WebExtensionTargetActorProxy(this.conn, this);
this._childFormPromise = proxy.connect().then(form => {
// Merge into the child actor form, some addon metadata
// (e.g. the addon name shown in the addon debugger window title).
return Object.assign(form, {
id: this.addon.id,
name: this.addon.name,
iconURL: this.addon.iconURL,
// Set the isOOP attribute on the connected child actor form.
isOOP: proxy.isOOP,
});
});
- this._destroyProxyChildActor = () => proxy.destroy();
+ this._destroyProxy = () => proxy.destroy();
return this._childFormPromise;
},
- // ProxyChildActor callbacks.
+ // WebExtensionTargetActorProxy callbacks.
- onProxyChildActorDestroy() {
+ onProxyDestroy() {
// Invalidate the cached child actor and form Promise
// if the child actor exits.
this._childFormPromise = null;
- delete this._destroyProxyChildActor;
+ delete this._destroyProxy;
},
// AddonManagerListener callbacks.
onInstalled(addon) {
if (addon.id != this.id) {
return;
}
@@ -127,31 +135,31 @@ const WebExtensionParentActor = protocol
if (addon != this.addon) {
return;
}
this.destroy();
},
});
-exports.WebExtensionParentActor = WebExtensionParentActor;
+exports.WebExtensionActor = WebExtensionActor;
-function ProxyChildActor(connection, parentActor) {
+function WebExtensionTargetActorProxy(connection, parentActor) {
this._conn = connection;
this._parentActor = parentActor;
this.addonId = parentActor.id;
this._onChildExit = this._onChildExit.bind(this);
this._form = null;
this._browser = null;
this._childActorID = null;
}
-ProxyChildActor.prototype = {
+WebExtensionTargetActorProxy.prototype = {
/**
* Connect the webextension child actor.
*/
async connect() {
if (this._browser) {
throw new Error("This actor is already connected to the extension process");
}
@@ -189,17 +197,17 @@ ProxyChildActor.prototype = {
this._mm.sendAsyncMessage("debug:webext_parent_exit", {
actor: this._childActorID,
});
ExtensionParent.DebugUtils.releaseExtensionProcessBrowser(this);
}
if (this._parentActor) {
- this._parentActor.onProxyChildActorDestroy();
+ this._parentActor.onProxyDestroy();
}
this._parentActor = null;
this._browser = null;
this._childActorID = null;
this._form = null;
},
--- a/devtools/server/actors/targets/webextension.js
+++ b/devtools/server/actors/targets/webextension.js
@@ -36,17 +36,17 @@ const FALLBACK_DOC_MESSAGE = "Your addon
const webExtensionTargetPrototype = extend({}, parentProcessTargetPrototype);
/**
* Creates a target actor for debugging all the contexts associated to a target
* WebExtensions add-on running in a child extension process. Most of the implementation
* is inherited from ParentProcessTargetActor (which inherits most of its implementation
* from BrowsingContextTargetActor).
*
- * WebExtensionTargetActor is created by a WebExtensionParentActor counterpart, when its
+ * WebExtensionTargetActor is created by a WebExtensionActor counterpart, when its
* parent actor's `connect` method has been called (on the listAddons RDP package),
* it runs in the same process that the extension is running into (which can be the main
* process if the extension is running in non-oop mode, or the child extension process
* if the extension is running in oop-mode).
*
* A WebExtensionTargetActor contains all tab actors, like a regular
* ParentProcessTargetActor or BrowsingContextTargetActor.
*
--- a/devtools/server/actors/webbrowser.js
+++ b/devtools/server/actors/webbrowser.js
@@ -9,17 +9,17 @@
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, "FrameTargetActorProxy", "devtools/server/actors/targets/frame-proxy", true);
loader.lazyRequireGetter(this, "AddonTargetActor", "devtools/server/actors/targets/addon", true);
-loader.lazyRequireGetter(this, "WebExtensionParentActor", "devtools/server/actors/addon/webextension-parent", true);
+loader.lazyRequireGetter(this, "WebExtensionActor", "devtools/server/actors/addon/webextension", true);
loader.lazyRequireGetter(this, "WorkerTargetActorList", "devtools/server/actors/worker/worker-list", true);
loader.lazyRequireGetter(this, "ServiceWorkerRegistrationActorList", "devtools/server/actors/worker/worker-list", true);
loader.lazyRequireGetter(this, "ProcessActorList", "devtools/server/actors/process", true);
loader.lazyImporter(this, "AddonManager", "resource://gre/modules/AddonManager.jsm");
/**
* Browser-specific actors.
*/
@@ -694,17 +694,17 @@ function BrowserAddonList(connection) {
}
BrowserAddonList.prototype.getList = async function() {
const addons = await AddonManager.getAllAddons();
for (const addon of addons) {
let actor = this._actorByAddonId.get(addon.id);
if (!actor) {
if (addon.isWebExtension) {
- actor = new WebExtensionParentActor(this._connection, addon);
+ actor = new WebExtensionActor(this._connection, addon);
} else {
actor = new AddonTargetActor(this._connection, addon);
}
this._actorByAddonId.set(addon.id, actor);
}
}
--- a/devtools/shared/specs/addon/moz.build
+++ b/devtools/shared/specs/addon/moz.build
@@ -3,10 +3,10 @@
# 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(
'addons.js',
'console.js',
'webextension-inspected-window.js',
- 'webextension-parent.js',
+ 'webextension.js',
)
rename from devtools/shared/specs/addon/webextension-parent.js
rename to devtools/shared/specs/addon/webextension.js
--- a/devtools/shared/specs/addon/webextension-parent.js
+++ b/devtools/shared/specs/addon/webextension.js
@@ -1,17 +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 {RetVal, generateActorSpec} = require("devtools/shared/protocol");
const webExtensionSpec = generateActorSpec({
- typeName: "webExtensionAddon",
+ typeName: "webExtension",
methods: {
reload: {
request: { },
response: { addon: RetVal("json") },
},
connect: {
--- a/devtools/shared/specs/index.js
+++ b/devtools/shared/specs/index.js
@@ -28,26 +28,26 @@ const Types = exports.__TypesForTests =
front: "devtools/shared/fronts/addon/addons",
},
{
types: ["addonConsole"],
spec: "devtools/shared/specs/addon/console",
front: null,
},
{
+ types: ["webExtension"],
+ spec: "devtools/shared/specs/addon/webextension",
+ front: null,
+ },
+ {
types: ["webExtensionInspectedWindow"],
spec: "devtools/shared/specs/addon/webextension-inspected-window",
front: "devtools/shared/fronts/addon/webextension-inspected-window",
},
{
- types: ["webExtensionAddon"],
- spec: "devtools/shared/specs/addon/webextension-parent",
- front: null,
- },
- {
types: ["animationplayer", "animations"],
spec: "devtools/shared/specs/animation",
front: "devtools/shared/fronts/animation",
},
/* breakpoint has old fashion client and no front */
{
types: ["breakpoint"],
spec: "devtools/shared/specs/breakpoint",