Bug 1497226 - Rename WebExtensionActor/WebExtensionTargetActor/AddonTargetActor.id to addonId. r=jdescottes
authorAlexandre Poirot <poirot.alex@gmail.com>
Mon, 08 Oct 2018 20:34:45 +0000
changeset 496057 80a1352b7cd979a40dd722c78b16a41e14e0ae67
parent 496056 c35bab726b030312c53f48a654d5fcc2e1264ac2
child 496058 22aa7c97d46d178a324f8c0b5598cc5b3caca492
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes
bugs1497226
milestone64.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 1497226 - Rename WebExtensionActor/WebExtensionTargetActor/AddonTargetActor.id to addonId. r=jdescottes MozReview-Commit-ID: 1frhYk1M9sC Differential Revision: https://phabricator.services.mozilla.com/D8001
devtools/server/actors/addon/webextension.js
devtools/server/actors/targets/addon.js
devtools/server/actors/targets/webextension.js
devtools/server/main.js
--- a/devtools/server/actors/addon/webextension.js
+++ b/devtools/server/actors/addon/webextension.js
@@ -37,17 +37,17 @@ loader.lazyImporter(this, "ExtensionPare
  *        The connection to the client.
  * @param {AddonWrapper} addon
  *        The target addon.
  */
 const WebExtensionActor = protocol.ActorClassWithSpec(webExtensionSpec, {
   initialize(conn, addon) {
     this.conn = conn;
     this.addon = addon;
-    this.id = addon.id;
+    this.addonId = addon.id;
     this._childFormPromise = null;
 
     AddonManager.addAddonListener(this);
   },
 
   destroy() {
     AddonManager.removeAddonListener(this);
 
@@ -67,31 +67,31 @@ const WebExtensionActor = protocol.Actor
 
   reload() {
     return this.addon.reload().then(() => {
       return {};
     });
   },
 
   form() {
-    const policy = ExtensionParent.WebExtensionPolicy.getByID(this.id);
+    const policy = ExtensionParent.WebExtensionPolicy.getByID(this.addonId);
     return {
       actor: this.actorID,
-      id: this.id,
+      id: this.addonId,
       name: this.addon.name,
       url: this.addon.sourceURI ? this.addon.sourceURI.spec : undefined,
       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,
       manifestURL: policy && policy.getURL("manifest.json"),
-      warnings: ExtensionParent.DebugUtils.getExtensionManifestWarnings(this.id),
+      warnings: ExtensionParent.DebugUtils.getExtensionManifestWarnings(this.addonId),
     };
   },
 
   connect() {
     if (this._childFormPormise) {
       return this._childFormPromise;
     }
 
@@ -119,17 +119,17 @@ const WebExtensionActor = protocol.Actor
     // if the child actor exits.
     this._childFormPromise = null;
     delete this._destroyProxy;
   },
 
   // AddonManagerListener callbacks.
 
   onInstalled(addon) {
-    if (addon.id != this.id) {
+    if (addon.id != this.addonId) {
       return;
     }
 
     // Update the AddonManager's addon object on reload/update.
     this.addon = addon;
   },
 
   onUninstalled(addon) {
@@ -141,17 +141,17 @@ const WebExtensionActor = protocol.Actor
   },
 });
 
 exports.WebExtensionActor = WebExtensionActor;
 
 function WebExtensionTargetActorProxy(connection, parentActor) {
   this._conn = connection;
   this._parentActor = parentActor;
-  this.addonId = parentActor.id;
+  this.addonId = parentActor.addonId;
 
   this._onChildExit = this._onChildExit.bind(this);
 
   this._form = null;
   this._browser = null;
   this._childActorID = null;
 }
 
--- a/devtools/server/actors/targets/addon.js
+++ b/devtools/server/actors/targets/addon.js
@@ -45,17 +45,17 @@ exports.AddonTargetActor = AddonTargetAc
 
 AddonTargetActor.prototype = {
   actorPrefix: "addonTarget",
 
   get exited() {
     return !this._addon;
   },
 
-  get id() {
+  get addonId() {
     return this._addon.id;
   },
 
   get url() {
     return this._addon.sourceURI ? this._addon.sourceURI.spec : undefined;
   },
 
   get attached() {
@@ -78,17 +78,17 @@ AddonTargetActor.prototype = {
     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.id,
+      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,
@@ -203,24 +203,24 @@ AddonTargetActor.prototype = {
    * 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.id;
+        return metadata.addonID === this.addonId;
       }
     } catch (e) {
       // ignore
     }
 
     if (global instanceof Ci.nsIDOMWindow) {
-      return global.document.nodePrincipal.addonId == this.id;
+      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
--- a/devtools/server/actors/targets/webextension.js
+++ b/devtools/server/actors/targets/webextension.js
@@ -70,17 +70,17 @@ const webExtensionTargetPrototype = exte
  *        The chromeGlobal where this actor has been injected by the
  *        DebuggerServer.connectToFrame method.
  * @param {string} prefix
  *        the custom RDP prefix to use.
  * @param {string} addonId
  *        the addonId of the target WebExtension.
  */
 webExtensionTargetPrototype.initialize = function(conn, chromeGlobal, prefix, addonId) {
-  this.id = addonId;
+  this.addonId = addonId;
 
   // Try to discovery an existent extension page to attach (which will provide the initial
   // URL shown in the window tittle when the addon debugger is opened).
   let extensionWindow = this._searchForExtensionWindow();
   if (!extensionWindow) {
     this._createFallbackWindow();
     extensionWindow = this.fallbackWindow;
   }
@@ -106,17 +106,17 @@ webExtensionTargetPrototype.initialize =
   this._allowSource = this._allowSource.bind(this);
   this._onParentExit = this._onParentExit.bind(this);
 
   this._chromeGlobal.addMessageListener("debug:webext_parent_exit", this._onParentExit);
 
   // Set the consoleAPIListener filtering options
   // (retrieved and used in the related webconsole child actor).
   this.consoleAPIListenerOptions = {
-    addonId: this.id,
+    addonId: this.addonId,
   };
 
   this.aps = Cc["@mozilla.org/addons/policy-service;1"]
                .getService(Ci.nsIAddonPolicyService);
 
   // This creates a Debugger instance for debugging all the add-on globals.
   this.makeDebugger = makeDebugger.bind(null, {
     findDebuggees: dbg => {
@@ -142,17 +142,17 @@ webExtensionTargetPrototype.exit = funct
     chromeGlobal.removeMessageListener("debug:webext_parent_exit", this._onParentExit);
 
     chromeGlobal.sendAsyncMessage("debug:webext_child_exit", {
       actor: this.actorID
     });
   }
 
   this.addon = null;
-  this.id = null;
+  this.addonId = null;
 
   return ParentProcessTargetActor.prototype.exit.apply(this);
 };
 
 // Private helpers.
 
 webExtensionTargetPrototype._createFallbackWindow = function() {
   if (this.fallbackWindow) {
@@ -185,17 +185,17 @@ webExtensionTargetPrototype._destroyFall
 };
 
 // Discovery an extension page to use as a default target window.
 // NOTE: This currently fail to discovery an extension page running in a
 // windowless browser when running in non-oop mode, and the background page
 // is set later using _onNewExtensionWindow.
 webExtensionTargetPrototype._searchForExtensionWindow = function() {
   for (const window of Services.ww.getWindowEnumerator(null)) {
-    if (window.document.nodePrincipal.addonId == this.id) {
+    if (window.document.nodePrincipal.addonId == this.addonId) {
       return window;
     }
   }
 
   return undefined;
 };
 
 // Customized ParentProcessTargetActor/BrowsingContextTargetActor hooks.
@@ -225,17 +225,17 @@ webExtensionTargetPrototype._onNewExtens
   }
 };
 
 webExtensionTargetPrototype._attach = function() {
   // NOTE: we need to be sure that `this.window` can return a window before calling the
   // ParentProcessTargetActor.onAttach, or the BrowsingContextTargetActor will not be
   // subscribed to the child doc shell updates.
 
-  if (!this.window || this.window.document.nodePrincipal.addonId !== this.id) {
+  if (!this.window || this.window.document.nodePrincipal.addonId !== this.addonId) {
     // Discovery an existent extension page to attach.
     const extensionWindow = this._searchForExtensionWindow();
 
     if (!extensionWindow) {
       this._createFallbackWindow();
       this._setWindow(this.fallbackWindow);
     } else {
       this._setWindow(extensionWindow);
@@ -282,23 +282,23 @@ webExtensionTargetPrototype._docShellToW
 /**
  * Return an array of the json details related to an array/iterator of docShells.
  */
 webExtensionTargetPrototype._docShellsToWindows = function(docshells) {
   return ParentProcessTargetActor.prototype._docShellsToWindows.call(this, docshells)
                     .filter(windowDetails => {
                       // Filter the docShells based on the addon id of the window or
                       // its sameType top level frame.
-                      return windowDetails.addonID === this.id ||
-                             windowDetails.sameTypeRootAddonID === this.id;
+                      return windowDetails.addonID === this.addonId ||
+                             windowDetails.sameTypeRootAddonID === this.addonId;
                     });
 };
 
 webExtensionTargetPrototype.isExtensionWindow = function(window) {
-  return window.document.nodePrincipal.addonId == this.id;
+  return window.document.nodePrincipal.addonId == this.addonId;
 };
 
 webExtensionTargetPrototype.isExtensionWindowDescendent = function(window) {
   // Check if the source is coming from a descendant docShell of an extension window.
   const rootWin = window.docShell.sameTypeRootTreeItem.domWindow;
   return this.isExtensionWindow(rootWin);
 };
 
@@ -337,17 +337,17 @@ webExtensionTargetPrototype._allowSource
   // Filter out resource and chrome sources (which are related to the loaded internals).
   if (["resource", "chrome", "file"].includes(uri.scheme)) {
     return false;
   }
 
   try {
     const addonID = this.aps.extensionURIToAddonId(uri);
 
-    return addonID == this.id;
+    return addonID == this.addonId;
   } catch (err) {
     // extensionURIToAddonId raises an exception on non-extension URLs.
     return false;
   }
 };
 
 /**
  * Return true if the given global is associated with this addon and should be
@@ -380,17 +380,17 @@ webExtensionTargetPrototype._shouldAddNe
     return global.document.ownerGlobal &&
            this.isExtensionWindowDescendent(global.document.ownerGlobal);
   }
 
   try {
     // This will fail for non-Sandbox objects, hence the try-catch block.
     const metadata = Cu.getSandboxMetadata(global);
     if (metadata) {
-      return metadata.addonID === this.id;
+      return metadata.addonID === this.addonId;
     }
   } catch (e) {
     // Unable to retrieve the sandbox metadata.
   }
 
   return false;
 };
 
--- a/devtools/server/main.js
+++ b/devtools/server/main.js
@@ -1211,17 +1211,17 @@ DebuggerServerConnection.prototype = {
    */
   setAddonOptions(id, options) {
     const addonList = this.rootActor._parameters.addonList;
     if (!addonList) {
       return Promise.resolve();
     }
     return addonList.getList().then((addonTargetActors) => {
       for (const actor of addonTargetActors) {
-        if (actor.id != id) {
+        if (actor.addonId != id) {
           continue;
         }
         actor.setOptions(options);
         return;
       }
     });
   },