Bug 1497264 - Remove AddonTargetActor and AddonConsoleActor;r=ochameau,yulia
authorJulian Descottes <jdescottes@mozilla.com>
Tue, 08 Jan 2019 18:17:17 +0000
changeset 512941 a894d406f4ae900c0dc0f199cfee12082a389def
parent 512940 0bacb9f000cc21c69c519c5d1ad78757230fa088
child 512942 033f84c32bce3df3cd0ffd487673463c09bda3cf
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau, yulia
bugs1497264
milestone66.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 1497264 - Remove AddonTargetActor and AddonConsoleActor;r=ochameau,yulia This should be rather safe. We can do more refactoring and renaming once LegacyExtension support is fully removed (ie Fx 65 hits release) Differential Revision: https://phabricator.services.mozilla.com/D15383
devtools/docs/backend/actor-hierarchy.md
devtools/server/actors/addon/console.js
devtools/server/actors/addon/moz.build
devtools/server/actors/targets/addon.js
devtools/server/actors/targets/moz.build
devtools/server/actors/thread.js
devtools/server/actors/webbrowser.js
devtools/shared/specs/addon/console.js
devtools/shared/specs/addon/moz.build
devtools/shared/specs/index.js
--- a/devtools/docs/backend/actor-hierarchy.md
+++ b/devtools/docs/backend/actor-hierarchy.md
@@ -90,20 +90,16 @@ RootActor (root.js)
    |   Returned by "getProcess" request without any argument.
    |
    |-- ContentProcessTargetActor (content-process.js)
    |   Targets all resources in a content process of Firefox (chrome sandboxes,
    |   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.
-   |
    \-- 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)
deleted file mode 100644
--- a/devtools/server/actors/addon/console.js
+++ /dev/null
@@ -1,95 +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";
-
-var { ConsoleAPIListener } = require("devtools/server/actors/webconsole/listeners/console-api");
-var { update } = require("devtools/shared/DevToolsUtils");
-
-loader.lazyRequireGetter(this, "WebConsoleActor", "devtools/server/actors/webconsole", true);
-
-const { extend } = require("devtools/shared/extend");
-const { ActorClassWithSpec, Actor } = require("devtools/shared/protocol");
-const { addonConsoleSpec } = require("devtools/shared/specs/addon/console");
-
-/**
- * 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 addonConsolePrototype = extend({}, WebConsoleActor.prototype);
-
-/**
- * The AddonConsoleActor implements capabilities needed for the add-on web
- * console feature.
- *
- * @constructor
- * @param object addon
- *        The add-on that this console watches.
- * @param object connection
- *        The connection to the client, DebuggerServerConnection.
- * @param object parentActor
- *        The parent AddonTargetActor actor.
- */
-addonConsolePrototype.initialize = function(addon, connection, parentActor) {
-  this.addon = addon;
-  Actor.prototype.initialize.call(this, connection);
-  WebConsoleActor.call(this, connection, parentActor);
-};
-
-update(addonConsolePrototype, {
-  /**
-   * The add-on that this console watches.
-   */
-  addon: null,
-
-  /**
-   * The main add-on JS global
-   */
-  get window() {
-    return this.parentActor.global;
-  },
-
-  /**
-   * Destroy the current AddonConsoleActor instance.
-   */
-  destroy() {
-    Actor.prototype.destroy.call(this);
-    WebConsoleActor.prototype.destroy.call(this);
-    this.addon = null;
-  },
-
-  /**
-   * Handler for the "startListeners" request.
-   *
-   * @param object request
-   *        The JSON request object received from the Web Console client.
-   * @return object
-   *         The response object which holds the startedListeners array.
-   */
-  startListeners: function ACAOnStartListeners(request) {
-    const startedListeners = [];
-
-    while (request.listeners.length > 0) {
-      const listener = request.listeners.shift();
-      switch (listener) {
-        case "ConsoleAPI":
-          if (!this.consoleAPIListener) {
-            this.consoleAPIListener =
-              new ConsoleAPIListener(null, this, { addonId: this.addon.id });
-            this.consoleAPIListener.init();
-          }
-          startedListeners.push(listener);
-          break;
-      }
-    }
-    return {
-      startedListeners: startedListeners,
-      nativeConsoleAPI: true,
-      traits: this.traits,
-    };
-  },
-});
-
-exports.AddonConsoleActor = ActorClassWithSpec(addonConsoleSpec, addonConsolePrototype);
--- a/devtools/server/actors/addon/moz.build
+++ b/devtools/server/actors/addon/moz.build
@@ -1,12 +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(
     'addons.js',
-    'console.js',
     'webextension-inspected-window.js',
     'webextension.js',
 )
deleted file mode 100644
--- a/devtools/server/actors/targets/addon.js
+++ /dev/null
@@ -1,254 +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 legacy (non-WebExtension) add-on.
- *
- * See devtools/docs/backend/actor-hierarchy.md for more details.
- */
-
-var { Ci, Cu } = require("chrome");
-var Services = require("Services");
-var { ActorPool } = require("devtools/server/actors/common");
-var { TabSources } = require("devtools/server/actors/utils/TabSources");
-var makeDebugger = require("devtools/server/actors/utils/make-debugger");
-var DevToolsUtils = require("devtools/shared/DevToolsUtils");
-var { assert } = DevToolsUtils;
-
-loader.lazyRequireGetter(this, "AddonThreadActor", "devtools/server/actors/thread", true);
-loader.lazyRequireGetter(this, "unwrapDebuggerObjectGlobal", "devtools/server/actors/thread", true);
-loader.lazyRequireGetter(this, "AddonConsoleActor", "devtools/server/actors/addon/console", true);
-
-loader.lazyImporter(this, "AddonManager", "resource://gre/modules/AddonManager.jsm");
-
-function AddonTargetActor(connection, addon) {
-  this.conn = connection;
-  this._addon = addon;
-  this._contextPool = new ActorPool(this.conn);
-  this.conn.addActorPool(this._contextPool);
-  this.threadActor = null;
-  this._global = null;
-
-  this._shouldAddNewGlobalAsDebuggee = this._shouldAddNewGlobalAsDebuggee.bind(this);
-
-  this.makeDebugger = makeDebugger.bind(null, {
-    findDebuggees: this._findDebuggees.bind(this),
-    shouldAddNewGlobalAsDebuggee: this._shouldAddNewGlobalAsDebuggee,
-  });
-
-  AddonManager.addAddonListener(this);
-}
-exports.AddonTargetActor = AddonTargetActor;
-
-AddonTargetActor.prototype = {
-  actorPrefix: "addonTarget",
-
-  get exited() {
-    return !this._addon;
-  },
-
-  get addonId() {
-    return this._addon.id;
-  },
-
-  get url() {
-    return this._addon.sourceURI ? this._addon.sourceURI.spec : undefined;
-  },
-
-  get attached() {
-    return this.threadActor;
-  },
-
-  get global() {
-    return this._global;
-  },
-
-  get sources() {
-    if (!this._sources) {
-      assert(this.threadActor, "threadActor should exist when creating sources.");
-      this._sources = new TabSources(this.threadActor, this._allowSource);
-    }
-    return this._sources;
-  },
-
-  form: function BAAForm() {
-    assert(this.actorID, "addon should have an actorID.");
-    if (!this._consoleActor) {
-      this._consoleActor = new AddonConsoleActor(this._addon, this.conn, this);
-      this._contextPool.addActor(this._consoleActor);
-    }
-
-    return {
-      actor: this.actorID,
-      id: this.addonId,
-      name: this._addon.name,
-      url: this.url,
-      iconURL: this._addon.iconURL,
-      isSystem: this._addon.isSystem,
-      debuggable: this._addon.isDebuggable,
-      temporarilyInstalled: this._addon.temporarilyInstalled,
-      type: this._addon.type,
-      isWebExtension: this._addon.isWebExtension,
-      isAPIExtension: this._addon.isAPIExtension,
-      consoleActor: this._consoleActor.actorID,
-
-      traits: {
-        networkMonitor: false,
-      },
-    };
-  },
-
-  destroy() {
-    this.conn.removeActorPool(this._contextPool);
-    this._contextPool = null;
-    this._consoleActor = null;
-    this._addon = null;
-    this._global = null;
-    AddonManager.removeAddonListener(this);
-  },
-
-  setOptions: function BAASetOptions(options) {
-    if ("global" in options) {
-      this._global = options.global;
-    }
-  },
-
-  onInstalled: function BAAUpdateAddonWrapper(addon) {
-    if (addon.id != this._addon.id) {
-      return;
-    }
-
-    // Update the AddonManager's addon object on reload/update.
-    this._addon = addon;
-  },
-
-  onDisabled: function BAAOnDisabled(addon) {
-    if (addon != this._addon) {
-      return;
-    }
-
-    this._global = null;
-  },
-
-  onUninstalled: function BAAOnUninstalled(addon) {
-    if (addon != this._addon) {
-      return;
-    }
-
-    if (this.attached) {
-      this.onDetach();
-
-      // The AddonTargetActor is not a BrowsingContextTargetActor and it has to send
-      // "tabDetached" directly to close the devtools toolbox window.
-      this.conn.send({ from: this.actorID, type: "tabDetached" });
-    }
-
-    this.destroy();
-  },
-
-  onAttach: function BAAOnAttach() {
-    if (this.exited) {
-      return { type: "exited" };
-    }
-
-    if (!this.attached) {
-      this.threadActor = new AddonThreadActor(this.conn, this);
-      this._contextPool.addActor(this.threadActor);
-    }
-
-    return { type: "tabAttached", threadActor: this.threadActor.actorID };
-  },
-
-  onDetach: function BAAOnDetach() {
-    if (!this.attached) {
-      return { error: "wrongState" };
-    }
-
-    this._contextPool.removeActor(this.threadActor);
-
-    this.threadActor = null;
-    this._sources = null;
-
-    return { type: "detached" };
-  },
-
-  onReload: function BAAOnReload() {
-    return this._addon.reload()
-      .then(() => {
-        // send an empty response
-        return {};
-      });
-  },
-
-  // A no-op function to enable this actor to be handled as same as WebExtensionActor.
-  loadIconDataURL() {
-  },
-
-  preNest: function() {
-    for (const {windowUtils} of Services.wm.getEnumerator(null)) {
-      windowUtils.suppressEventHandling(true);
-      windowUtils.suspendTimeouts();
-    }
-  },
-
-  postNest: function() {
-    for (const {windowUtils} of Services.wm.getEnumerator(null)) {
-      windowUtils.resumeTimeouts();
-      windowUtils.suppressEventHandling(false);
-    }
-  },
-
-  /**
-   * Return true if the given global is associated with this addon and should be
-   * added as a debuggee, false otherwise.
-   */
-  _shouldAddNewGlobalAsDebuggee: function(givenGlobal) {
-    const global = unwrapDebuggerObjectGlobal(givenGlobal);
-    try {
-      // This will fail for non-Sandbox objects, hence the try-catch block.
-      const metadata = Cu.getSandboxMetadata(global);
-      if (metadata) {
-        return metadata.addonID === this.addonId;
-      }
-    } catch (e) {
-      // ignore
-    }
-
-    if (global instanceof Ci.nsIDOMWindow) {
-      return global.document.nodePrincipal.addonId == this.addonId;
-    }
-
-    return false;
-  },
-
-  /**
-   * Override the eligibility check for scripts and sources to make
-   * sure every script and source with a URL is stored when debugging
-   * add-ons.
-   */
-  _allowSource: function(source) {
-    // XPIProvider.jsm evals some code in every add-on's bootstrap.js. Hide it.
-    if (source.url === "resource://gre/modules/addons/XPIProvider.jsm") {
-      return false;
-    }
-
-    return true;
-  },
-
-  /**
-   * Yield the current set of globals associated with this addon that should be
-   * added as debuggees.
-   */
-  _findDebuggees: function(dbg) {
-    return dbg.findAllGlobals().filter(this._shouldAddNewGlobalAsDebuggee);
-  },
-};
-
-AddonTargetActor.prototype.requestTypes = {
-  "attach": AddonTargetActor.prototype.onAttach,
-  "detach": AddonTargetActor.prototype.onDetach,
-  "reload": AddonTargetActor.prototype.onReload,
-};
--- a/devtools/server/actors/targets/moz.build
+++ b/devtools/server/actors/targets/moz.build
@@ -1,16 +1,15 @@
 # -*- 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(
-    'addon.js',
     'browsing-context.js',
     'chrome-window.js',
     'content-process.js',
     'frame-proxy.js',
     'frame.js',
     'parent-process.js',
     'webextension.js',
     'worker.js',
--- a/devtools/server/actors/thread.js
+++ b/devtools/server/actors/thread.js
@@ -2057,44 +2057,16 @@ Object.assign(ChromeDebuggerActor.protot
   constructor: ChromeDebuggerActor,
 
   // A constant prefix that will be used to form the actor ID by the server.
   actorPrefix: "chromeDebugger",
 });
 
 exports.ChromeDebuggerActor = ChromeDebuggerActor;
 
-/**
- * Creates an actor for handling add-on debugging. AddonThreadActor is
- * a thin wrapper over ThreadActor.
- *
- * @param connection object
- *        The DebuggerServerConnection with which this AddonThreadActor
- *        is associated. (Currently unused, but required to make this
- *        constructor usable with addGlobalActor.)
- *
- * @param parent object
- *        This actor's parent actor. See ThreadActor for a list of expected
- *        properties.
- */
-function AddonThreadActor(connection, parent) {
-  ThreadActor.prototype.initialize.call(this, parent);
-}
-
-AddonThreadActor.prototype = Object.create(ThreadActor.prototype);
-
-Object.assign(AddonThreadActor.prototype, {
-  constructor: AddonThreadActor,
-
-  // A constant prefix that will be used to form the actor ID by the server.
-  actorPrefix: "addonThread",
-});
-
-exports.AddonThreadActor = AddonThreadActor;
-
 // Utility functions.
 
 /**
  * Report the given error in the error console and to stdout.
  *
  * @param Error error
  *        The error object you wish to report.
  * @param String prefix
--- a/devtools/server/actors/webbrowser.js
+++ b/devtools/server/actors/webbrowser.js
@@ -9,17 +9,16 @@
 var { Ci } = require("chrome");
 var Services = require("Services");
 var { DebuggerServer } = require("devtools/server/main");
 var { ActorRegistry } = require("devtools/server/actors/utils/actor-registry");
 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, "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");
 loader.lazyImporter(this, "AppConstants", "resource://gre/modules/AppConstants.jsm");
 
 /**
@@ -725,22 +724,17 @@ function BrowserAddonList(connection) {
   this._onListChanged = null;
 }
 
 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 WebExtensionActor(this._connection, addon);
-      } else {
-        actor = new AddonTargetActor(this._connection, addon);
-      }
-
+      actor = new WebExtensionActor(this._connection, addon);
       this._actorByAddonId.set(addon.id, actor);
     }
   }
 
   return Array.from(this._actorByAddonId, ([_, actor]) => actor);
 };
 
 Object.defineProperty(BrowserAddonList.prototype, "onListChanged", {
deleted file mode 100644
--- a/devtools/shared/specs/addon/console.js
+++ /dev/null
@@ -1,14 +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 { webconsoleSpecPrototype } = require("devtools/shared/specs/webconsole");
-
-const addonConsoleSpec = generateActorSpec(extend(webconsoleSpecPrototype, {
-  typeName: "addonConsole",
-}));
-
-exports.addonConsoleSpec = addonConsoleSpec;
--- a/devtools/shared/specs/addon/moz.build
+++ b/devtools/shared/specs/addon/moz.build
@@ -1,12 +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(
     'addons.js',
-    'console.js',
     'webextension-inspected-window.js',
     'webextension.js',
 )
--- a/devtools/shared/specs/index.js
+++ b/devtools/shared/specs/index.js
@@ -23,21 +23,16 @@ const Types = exports.__TypesForTests = 
     front: "devtools/shared/fronts/actor-registry",
   },
   {
     types: ["addons"],
     spec: "devtools/shared/specs/addon/addons",
     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",