Bug 1491764 - Update debugRemoteAddon to accept addonID as parameter;r=ladybenko
authorJulian Descottes <jdescottes@mozilla.com>
Wed, 03 Oct 2018 08:48:55 +0000
changeset 487951 3e260539c399797e74ab7bebdad9cf62207a5e23
parent 487950 bf098432003adaa3862f8271de486ee3bdbd8362
child 487952 594454d6b1cce40d69e021d5cf6e5aada279a38d
push id246
push userfmarier@mozilla.com
push dateSat, 13 Oct 2018 00:15:40 +0000
reviewersladybenko
bugs1491764
milestone64.0a1
Bug 1491764 - Update debugRemoteAddon to accept addonID as parameter;r=ladybenko The call to getAddonForm has been inline in debugRemoteAddon. Differential Revision: https://phabricator.services.mozilla.com/D7307
devtools/client/aboutdebugging-new/src/actions/debug-targets.js
devtools/client/aboutdebugging-new/src/modules/extensions-helper.js
devtools/client/aboutdebugging/components/addons/Target.js
--- a/devtools/client/aboutdebugging-new/src/actions/debug-targets.js
+++ b/devtools/client/aboutdebugging-new/src/actions/debug-targets.js
@@ -5,17 +5,16 @@
 "use strict";
 
 const { AddonManager } = require("resource://gre/modules/AddonManager.jsm");
 const { gDevToolsBrowser } = require("devtools/client/framework/devtools-browser");
 
 const {
   debugLocalAddon,
   debugRemoteAddon,
-  getAddonForm,
   openTemporaryExtension,
   uninstallAddon,
 } = require("../modules/extensions-helper");
 
 const {
   getCurrentClient,
   getCurrentRuntime
 } = require("../modules/runtimes-state-helper");
@@ -49,18 +48,17 @@ function inspectDebugTarget(type, id) {
                       `&host=${host}&port=${port}`);
         } else if (runtimeType === RUNTIMES.THIS_FIREFOX) {
           window.open(`about:devtools-toolbox?type=tab&id=${id}`);
         }
         break;
       }
       case DEBUG_TARGETS.EXTENSION: {
         if (runtimeType === RUNTIMES.NETWORK) {
-          const addonForm = await getAddonForm(id, client);
-          debugRemoteAddon(addonForm, client);
+          await debugRemoteAddon(id, client);
         } else if (runtimeType === RUNTIMES.THIS_FIREFOX) {
           debugLocalAddon(id);
         }
         break;
       }
       case DEBUG_TARGETS.WORKER: {
         // Open worker toolbox in new window.
         gDevToolsBrowser.openWorkerToolbox(client, id);
--- a/devtools/client/aboutdebugging-new/src/modules/extensions-helper.js
+++ b/devtools/client/aboutdebugging-new/src/modules/extensions-helper.js
@@ -42,22 +42,25 @@ exports.debugLocalAddon = async function
       browserToolboxProcess = null;
     }
   });
 };
 
 /**
  * Start debugging an addon in a remote instance of Firefox.
  *
- * @param {Object} addonForm
- *        Necessary to create an addon debugging target.
+ * @param {String} id
+ *        The addon id to debug.
  * @param {DebuggerClient} client
  *        Required for remote debugging.
  */
-exports.debugRemoteAddon = async function(addonForm, client) {
+exports.debugRemoteAddon = async function(id, client) {
+  const { addons } = await client.listAddons();
+  const addonForm = addons.find(addon => addon.id === id);
+
   // Close previous addon debugging toolbox.
   closeToolbox();
 
   const options = {
     form: addonForm,
     chrome: true,
     client,
   };
@@ -66,21 +69,16 @@ exports.debugRemoteAddon = async functio
 
   const hostType = Toolbox.HostType.WINDOW;
   remoteAddonToolbox = await gDevTools.showToolbox(target, null, hostType);
   remoteAddonToolbox.once("destroy", () => {
     remoteAddonToolbox = null;
   });
 };
 
-exports.getAddonForm = async function(addonID, client) {
-  const { addons } = await client.listAddons();
-  return addons.find(addon => addon.id === addonID);
-};
-
 /**
  * Uninstall the addon with the provided id.
  * Resolves when the addon shutdown has completed.
  */
 exports.uninstallAddon = async function(addonID) {
   const addon = await AddonManager.getAddonByID(addonID);
   return addon && addon.uninstall();
 };
--- a/devtools/client/aboutdebugging/components/addons/Target.js
+++ b/devtools/client/aboutdebugging/components/addons/Target.js
@@ -175,17 +175,17 @@ class AddonTarget extends Component {
     this.uninstall = this.uninstall.bind(this);
     this.reload = this.reload.bind(this);
   }
 
   debug() {
     const { client, connect, target } = this.props;
 
     if (connect.type === "REMOTE") {
-      debugRemoteAddon(target.form, client);
+      debugRemoteAddon(target.addonID, client);
     } else if (connect.type === "LOCAL") {
       debugLocalAddon(target.addonID);
     }
   }
 
   uninstall() {
     const { target } = this.props;
     uninstallAddon(target.addonID);