Bug 1172897 - Rename ContentActor to FrameTargetActor. r=ochameau
authorJ. Ryan Stinnett <jryans@gmail.com>
Wed, 30 May 2018 14:09:45 -0500
changeset 478570 90a8e47ce3041d9fdb403d202820ee237f361ab0
parent 478569 b4918c8b1dd9499b095e1e0a69b6da33a370ab66
child 478571 c774c6844a03428e876909df19d013305e0291fb
push id1757
push userffxbld-merge
push dateFri, 24 Aug 2018 17:02:43 +0000
treeherdermozilla-release@736023aebdb1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1172897
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1172897 - Rename ContentActor to FrameTargetActor. r=ochameau MozReview-Commit-ID: 3Rgvftpea8g
devtools/docs/backend/actor-hierarchy.md
devtools/server/actors/content.js
devtools/server/actors/highlighters.js
devtools/server/actors/moz.build
devtools/server/actors/targets/browsing-context.js
devtools/server/actors/targets/frame.js
devtools/server/actors/targets/moz.build
devtools/server/actors/webbrowser.js
devtools/server/main.js
devtools/server/startup/frame.js
devtools/shared/specs/index.js
devtools/shared/specs/targets/browsing-context.js
devtools/shared/specs/targets/frame.js
devtools/shared/specs/targets/moz.build
--- a/devtools/docs/backend/actor-hierarchy.md
+++ b/devtools/docs/backend/actor-hierarchy.md
@@ -20,17 +20,17 @@ RootActor: First one, automatically inst
    |   PreferenceActor (for Firefox prefs)
    |
    \-- Target actors:
        Actors that represent the main "thing" being targeted by a given toolbox,
        such as a tab, frame, worker, add-on, etc. and track its lifetime.
        Generally, there is a target actor for each thing you can point a
        toolbox at.
        Examples include:
-       ContentActor (for a frame, such as a tab)
+       FrameTargetActor (for a frame, such as a tab)
        WorkerActor (for various kind of workers)
        |
        \-- Tab-scoped actors:
            Actors exposing one particular feature set. They are children of a
            given target actor and the data they return is filtered to reflect
            the target.
            These actors are registered with `tab: true` in
            devtools/server/main.js.
@@ -49,25 +49,25 @@ All other actors have an `actorID` which
 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 ContentActor, which is loaded via the tab's message
+   |   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.
    |   Returned by "listTabs" or "getTab" requests.
    |   |
-   |   \-- ContentActor (content.js)
-   |       The "real" actor for a tab, which runs in whichever process holds the
-   |       content.  BrowserTabActor communicates with this via the tab's
-   |       message manager.
+   |   \-- 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.
    |       Extends the abstract class BrowsingContextTargetActor.
    |       Returned by "connect" on BrowserTabActor.
    |
    |-- 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
@@ -151,18 +151,18 @@ expose many other attributes and events:
 See BrowsingContextTargetActor documentation for more details.
 
 ## Tab-scoped actors
 
 Each of these actors focuses on providing one particular feature set. They are
 children of a given target actor.
 
 The data they return is filtered to reflect the target. For example, the
-InspectorActor that you fetch from a ContentActor gives you information about
-the markup and styles for only that frame.
+InspectorActor that you fetch from a FrameTargetActor gives you information
+about the markup and styles for only that frame.
 
 These actors may extend this hierarchy by having their own children, like
 LongStringActor, WalkerActor, etc.
 
 To improve performance, tab-scoped actors are created lazily. The target actor
 lists the actor ID for each one, but the actor modules aren't actually loaded
 and instantiated at that point. Once the first request for a given tab-scoped
 actor is received by the server, that specific actor is instantiated just in
--- a/devtools/server/actors/highlighters.js
+++ b/devtools/server/actors/highlighters.js
@@ -652,18 +652,18 @@ HighlighterEnvironment.prototype = {
   },
 
   /**
    * Get the right target for listening to events on the page.
    * - If the environment was initialized from a BrowsingContextTargetActor
    *   *and* if we're in the Browser Toolbox (to inspect Firefox Desktop): the
    *   targetActor is the RootActor, in which case, the window property can be
    *   used to listen to events.
-   * - With Firefox Desktop, the targetActor is a ContentActor, and we use the
-   *   chromeEventHandler which gives us a target we can use to listen to
+   * - With Firefox Desktop, the targetActor is a FrameTargetActor, and we use
+   *   the chromeEventHandler which gives us a target we can use to listen to
    *   events, even from nested iframes.
    * - If the environment was initialized from a window, we also use the
    *   chromeEventHandler.
    */
   get pageListenerTarget() {
     if (this._targetActor && this._targetActor.isRootActor) {
       return this.window;
     }
--- a/devtools/server/actors/moz.build
+++ b/devtools/server/actors/moz.build
@@ -27,17 +27,16 @@ DevToolsModules(
     'animation.js',
     'array-buffer.js',
     'breakpoint.js',
     'call-watcher.js',
     'canvas.js',
     'child-process.js',
     'chrome.js',
     'common.js',
-    'content.js',
     'css-properties.js',
     'csscoverage.js',
     'device.js',
     'emulation.js',
     'environment.js',
     'errordocs.js',
     'frame.js',
     'framerate.js',
--- 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 ContentActor, ChromeActor, and WindowActor.
+ * This class is extended by FrameTargetActor, ChromeActor, and WindowActor.
  *
  * 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.
  */
 
@@ -200,17 +200,17 @@ const browsingContextTargetPrototype = {
    * Note that *all* these events are dispatched in the following order
    * when we switch the context of the actor to a given iframe:
    *  - will-navigate
    *  - window-destroyed
    *  - changed-toplevel-document
    *  - window-ready
    *  - navigate
    *
-   * This class is subclassed by ContentActor and others.
+   * This class is subclassed by FrameTargetActor and others.
    * Subclasses are expected to implement a getter for the docShell property.
    *
    * @param connection DebuggerServerConnection
    *        The conection to the client.
    */
   initialize: function(connection) {
     Actor.prototype.initialize.call(this, connection);
 
rename from devtools/server/actors/content.js
rename to devtools/server/actors/targets/frame.js
--- a/devtools/server/actors/content.js
+++ b/devtools/server/actors/targets/frame.js
@@ -1,74 +1,73 @@
 /* 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 frame / docShell in the content process (where the actual
+ * content lives).
+ *
+ * This actor extends BrowsingContextTargetActor.
+ *
+ * See devtools/docs/backend/actor-hierarchy.md for more details.
+ */
+
 var { Cr } = require("chrome");
 var {
   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 { frameTargetSpec } = require("devtools/shared/specs/targets/frame");
 
 /**
- * Target actor for documents living in a child process.
- *
- * Depends on BrowsingContextTargetActor, defined in browsing-context.js.
+ * 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 frameTargetPrototype = extend({}, browsingContextTargetPrototype);
 
 /**
- * Creates a target actor for handling requests to the single tab, like
- * attaching and detaching. ContentActor respects the actor factories
- * registered with DebuggerServer.addTabActor.
+ * Target actor for a frame / docShell in the content process.
  *
  * @param connection DebuggerServerConnection
  *        The conection to the client.
  * @param chromeGlobal
  *        The content script global holding |content| and |docShell| properties for a tab.
  * @param prefix
  *        the prefix used in protocol to create IDs for each actor.
  *        Used as ID identifying this particular target actor from the parent process.
  */
-
-/**
- * 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 contentPrototype = extend({}, browsingContextTargetPrototype);
-
-contentPrototype.initialize = function(connection, chromeGlobal) {
+frameTargetPrototype.initialize = function(connection, chromeGlobal) {
   this._chromeGlobal = chromeGlobal;
   BrowsingContextTargetActor.prototype.initialize.call(this, connection, chromeGlobal);
   this.traits.reconfigure = false;
   this._sendForm = this._sendForm.bind(this);
   this._chromeGlobal.addMessageListener("debug:form", this._sendForm);
 
   Object.defineProperty(this, "docShell", {
     value: this._chromeGlobal.docShell,
     configurable: true
   });
 };
 
-Object.defineProperty(contentPrototype, "title", {
+Object.defineProperty(frameTargetPrototype, "title", {
   get: function() {
     return this.window.document.title;
   },
   enumerable: true,
   configurable: true
 });
 
-contentPrototype.exit = function() {
+frameTargetPrototype.exit = function() {
   if (this._sendForm) {
     try {
       this._chromeGlobal.removeMessageListener("debug:form", this._sendForm);
     } catch (e) {
       if (e.result != Cr.NS_ERROR_NULL_POINTER) {
         throw e;
       }
       // In some cases, especially when using messageManagers in non-e10s mode, we reach
@@ -82,13 +81,13 @@ contentPrototype.exit = function() {
 
   this._chromeGlobal = null;
 };
 
 /**
  * On navigation events, our URL and/or title may change, so we update our
  * counterpart in the parent process that participates in the tab list.
  */
-contentPrototype._sendForm = function() {
+frameTargetPrototype._sendForm = function() {
   this._chromeGlobal.sendAsyncMessage("debug:form", this.form());
 };
 
-exports.ContentActor = ActorClassWithSpec(browsingContextTargetSpec, contentPrototype);
+exports.FrameTargetActor = ActorClassWithSpec(frameTargetSpec, frameTargetPrototype);
--- a/devtools/server/actors/targets/moz.build
+++ b/devtools/server/actors/targets/moz.build
@@ -1,9 +1,10 @@
 # -*- 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.js',
 )
--- a/devtools/server/actors/webbrowser.js
+++ b/devtools/server/actors/webbrowser.js
@@ -685,19 +685,19 @@ DevToolsUtils.makeInfallible(function(wi
       }
     }
   }, "BrowserTabList.prototype.onCloseWindow's delayed body"));
 }, "BrowserTabList.prototype.onCloseWindow");
 
 exports.BrowserTabList = BrowserTabList;
 
 /**
- * Creates a tab actor for handling requests to a single browser frame.
+ * Creates a target actor 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 ContentActor in a remote browser process.
+ * 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 = {}) {
@@ -767,17 +767,17 @@ BrowserTabActor.prototype = {
     // so only request form update if some code is still listening on the other
     // side.
     if (this.exited) {
       return this.connect();
     }
 
     const form = await new Promise(resolve => {
       const onFormUpdate = msg => {
-        // There may be more than just one content.js (ContentActor) up and running
+        // There may be more than one FrameTargetActor up and running
         if (this._form.actor != msg.json.actor) {
           return;
         }
         this._mm.removeMessageListener("debug:form", onFormUpdate);
 
         resolve(msg.json);
       };
 
--- a/devtools/server/main.js
+++ b/devtools/server/main.js
@@ -142,17 +142,17 @@ var DebuggerServer = {
 
   /**
    * Allow debugging chrome of (parent or child) processes.
    */
   allowChromeProcess: false,
 
   /**
    * We run a special server in child process whose main actor is an instance
-   * of ContentActor, but that isn't a root actor. Instead there is no root
+   * of FrameTargetActor, but that isn't a root actor. Instead there is no root
    * actor registered on DebuggerServer.
    */
   get rootlessServer() {
     return !this.isModuleRegistered("devtools/server/actors/webbrowser");
   },
 
   /**
    * Initialize the debugger server.
@@ -1122,17 +1122,17 @@ var DebuggerServer = {
           }
         } else {
           // Otherwise, the frame has been closed before the actor
           // had a chance to be created, so we are not able to create
           // the actor.
           resolve(null);
         }
         if (actor) {
-          // The ContentActor within the child process doesn't necessary
+          // The FrameTargetActor within the child process doesn't necessary
           // have time to uninitialize itself when the frame is closed/killed.
           // So ensure telling the client that the related actor is detached.
           connection.send({ from: actor.actor, type: "tabDetached" });
           actor = null;
         }
 
         if (onDestroy) {
           onDestroy(mm);
--- a/devtools/server/startup/frame.js
+++ b/devtools/server/startup/frame.js
@@ -20,17 +20,17 @@ try {
     const { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
 
     const DevToolsUtils = require("devtools/shared/DevToolsUtils");
     const { dumpn } = DevToolsUtils;
     const { DebuggerServer, ActorPool } = require("devtools/server/main");
 
     DebuggerServer.init();
     // We want a special server without any root actor and only tab actors.
-    // We are going to spawn a ContentActor instance in the next few lines,
+    // We are going to spawn a FrameTargetActor instance in the next few lines,
     // it is going to act like a root actor without being one.
     DebuggerServer.registerActors({ tab: true });
 
     const connections = new Map();
 
     const onConnect = DevToolsUtils.makeInfallible(function(msg) {
       removeMessageListener("debug:connect", onConnect);
 
@@ -51,18 +51,18 @@ try {
         connections.set(prefix, conn);
 
         let actor;
 
         if (addonId) {
           const { WebExtensionChildActor } = require("devtools/server/actors/webextension");
           actor = new WebExtensionChildActor(conn, chromeGlobal, prefix, addonId);
         } else {
-          const { ContentActor } = require("devtools/server/actors/content");
-          actor = new ContentActor(conn, chromeGlobal);
+          const { FrameTargetActor } = require("devtools/server/actors/targets/frame");
+          actor = new FrameTargetActor(conn, chromeGlobal);
         }
 
         const actorPool = new ActorPool(conn);
         actorPool.addActor(actor);
         conn.addActorPool(actorPool);
 
         sendAsyncMessage("debug:actor", {actor: actor.form(), prefix: prefix});
       });
--- 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: ["frameTarget"],
+    spec: "devtools/shared/specs/targets/frame",
+    front: null,
+  },
+  {
     types: ["timeline"],
     spec: "devtools/shared/specs/timeline",
     front: "devtools/shared/fronts/timeline",
   },
   {
     types: ["audionode", "webaudio"],
     spec: "devtools/shared/specs/webaudio",
     front: "devtools/shared/fronts/webaudio",
--- a/devtools/shared/specs/targets/browsing-context.js
+++ b/devtools/shared/specs/targets/browsing-context.js
@@ -1,14 +1,14 @@
 /* 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 {types, generateActorSpec, RetVal, Option} = require("devtools/shared/protocol");
+const { types, generateActorSpec, RetVal, Option } = require("devtools/shared/protocol");
 
 types.addDictType("browsingContextTarget.attach", {
   type: "string",
   threadActor: "number",
   cacheDisabled: "boolean",
   javascriptEnabled: "boolean",
   traits: "json"
 });
@@ -44,17 +44,17 @@ types.addDictType("browsingContextTarget
 
 types.addDictType("browsingContextTarget.reconfigure", {
   javascriptEnabled: "nullable:boolean",
   cacheDisabled: "nullable:boolean",
   serviceWorkersTestingEnabled: "nullable:boolean",
   performReload: "nullable:boolean"
 });
 
-const browsingContextTargetSpec = generateActorSpec({
+const browsingContextTargetSpecPrototype = {
   typeName: "browsingContextTarget",
 
   methods: {
     attach: {
       request: {},
       response: RetVal("browsingContextTarget.attach")
     },
     detach: {
@@ -104,12 +104,15 @@ const browsingContextTargetSpec = genera
     logInPage: {
       request: {
         text: Option(0, "string"),
         category: Option(0, "string"),
         flags: Option(0, "string")
       },
       response: {}
     }
-  }
-});
+  },
+};
 
+const browsingContextTargetSpec = generateActorSpec(browsingContextTargetSpecPrototype);
+
+exports.browsingContextTargetSpecPrototype = browsingContextTargetSpecPrototype;
 exports.browsingContextTargetSpec = browsingContextTargetSpec;
new file mode 100644
--- /dev/null
+++ b/devtools/shared/specs/targets/frame.js
@@ -0,0 +1,15 @@
+/* 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");
+
+// Bug 1467560: Update `generateActorSpec` support extension more naturally
+const frameTargetSpec = generateActorSpec(extend(browsingContextTargetSpecPrototype, {
+  typeName: "frameTarget",
+}));
+
+exports.frameTargetSpec = frameTargetSpec;
--- a/devtools/shared/specs/targets/moz.build
+++ b/devtools/shared/specs/targets/moz.build
@@ -1,9 +1,10 @@
 # -*- 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.js',
 )