Bug 1506546 - Refactor listAddons call sites. r=yulia
☠☠ backed out by c19baae766e9 ☠ ☠
authorAlexandre Poirot <poirot.alex@gmail.com>
Tue, 27 Nov 2018 11:23:22 +0000
changeset 504670 7d8e650e25c2fc0070c7ca5e4a9d851b561d9734
parent 504669 a293a37483b91f1040015918719a3092dc9be2da
child 504671 00fe26234b3da593bda143f9f7836b94c33f128e
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersyulia
bugs1506546
milestone65.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 1506546 - Refactor listAddons call sites. r=yulia Adapt to the new returned value of listAddons and also always call it from RootFront instead of DebuggerClient. Fix the spec in order to expose reload on the front (it was a miss from a previous patch). MozReview-Commit-ID: AQ5EOQEqnxX Depends on D12575 Differential Revision: https://phabricator.services.mozilla.com/D12576
devtools/client/framework/connect/connect.js
devtools/server/tests/unit/test_addon_events.js
devtools/server/tests/unit/test_addons_actor.js
devtools/shared/client/debugger-client.js
--- a/devtools/client/framework/connect/connect.js
+++ b/devtools/client/framework/connect/connect.js
@@ -75,20 +75,17 @@ var submit = async function() {
 /**
  * Connection is ready. List actors and build buttons.
  */
 var onConnectionReady = async function([aType, aTraits]) {
   clearTimeout(gConnectionTimeout);
 
   let addons = [];
   try {
-    const response = await gClient.listAddons();
-    if (!response.error && response.addons.length > 0) {
-      addons = response.addons;
-    }
+    addons = await gClient.mainRoot.listAddons();
   } catch (e) {
     // listAddons throws if the runtime doesn't support addons
   }
 
   let parent = document.getElementById("addonTargetActors");
   if (addons.length > 0) {
     // Add one entry for each add-on.
     for (const addon of addons) {
@@ -158,17 +155,17 @@ var onConnectionReady = async function([
 };
 
 /**
  * Build one button for an add-on.
  */
 function buildAddonLink(addon, parent) {
   const a = document.createElement("a");
   a.onclick = async function() {
-    openToolbox(addon, true, "webconsole");
+    openToolbox(null, true, "webconsole", addon);
   };
 
   a.textContent = addon.name;
   a.title = addon.id;
   a.href = "#";
 
   parent.appendChild(a);
 }
--- a/devtools/server/tests/unit/test_addon_events.js
+++ b/devtools/server/tests/unit/test_addon_events.js
@@ -13,17 +13,17 @@ add_task(async function testReloadExited
   DebuggerServer.registerAllActors();
 
   const client = new DebuggerClient(DebuggerServer.connectPipe());
   await client.connect();
 
   // Retrieve the current list of addons to be notified of the next list update.
   // We will also call listAddons every time we receive the event "addonListChanged" for
   // the same reason.
-  await client.listAddons();
+  await client.mainRoot.listAddons();
 
   info("Install the addon");
   const addonFile = do_get_file("addons/web-extension", false);
 
   let installedAddon;
   await expectAddonListChanged(client, async () => {
     installedAddon = await AddonManager.installTemporaryAddon(addonFile);
   });
@@ -51,10 +51,10 @@ add_task(async function testReloadExited
 
   await close(client);
 });
 
 async function expectAddonListChanged(client, predicate) {
   const onAddonListChanged = client.mainRoot.once("addonListChanged");
   await predicate();
   await onAddonListChanged;
-  await client.listAddons();
+  await client.mainRoot.listAddons();
 }
--- a/devtools/server/tests/unit/test_addons_actor.js
+++ b/devtools/server/tests/unit/test_addons_actor.js
@@ -24,20 +24,20 @@ add_task(async function testSuccessfulIn
   const usePlatformSeparator = true;
   const addonPath = getFilePath("addons/web-extension",
                                 allowMissing, usePlatformSeparator);
   const installedAddon = await addons.installTemporaryAddon(addonPath);
   equal(installedAddon.id, "test-addons-actor@mozilla.org");
   // The returned object is currently not a proper actor.
   equal(installedAddon.actor, false);
 
-  const addonList = await client.listAddons();
-  ok(addonList && addonList.addons && addonList.addons.map(a => a.name),
+  const addonList = await client.mainRoot.listAddons();
+  ok(addonList && addonList.map(a => a.name),
      "Received list of add-ons");
-  const addon = addonList.addons.filter(a => a.id === installedAddon.id)[0];
+  const addon = addonList.find(a => a.id === installedAddon.id);
   ok(addon, "Test add-on appeared in root install list");
 
   await close(client);
 });
 
 add_task(async function testNonExistantPath() {
   const [client, addons] = await connect();
 
--- a/devtools/shared/client/debugger-client.js
+++ b/devtools/shared/client/debugger-client.js
@@ -339,24 +339,16 @@ DebuggerClient.prototype = {
   /*
    * This function exists only to preserve DebuggerClient's interface;
    * new code should say 'client.mainRoot.listTabs()'.
    */
   listTabs: function(options) {
     return this.mainRoot.listTabs(options);
   },
 
-  /*
-   * This function exists only to preserve DebuggerClient's interface;
-   * new code should say 'client.mainRoot.listAddons()'.
-   */
-  listAddons: function() {
-    return this.mainRoot.listAddons();
-  },
-
   getTab: function(filter) {
     return this.mainRoot.getTab(filter);
   },
 
   /**
    * Attach to a target actor:
    *
    *  - start watching for new documents (emits `tabNativated` messages)