Bug 1506546 - Refactor getAddonActorForId test helper. r=yulia
authorAlexandre Poirot <poirot.alex@gmail.com>
Tue, 27 Nov 2018 19:18:46 +0000
changeset 504787 67c951597bd97cc0f19e8f2b61d91e4acedce14e
parent 504786 57811a27eb990ade17f43a056e31dc146dc9785d
child 504788 e5fb062f20f85af04b876b05e5031ab3282d64bc
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 getAddonActorForId test helper. r=yulia MozReview-Commit-ID: A7JxzO7rhhe Differential Revision: https://phabricator.services.mozilla.com/D12573
devtools/client/debugger/test/mochitest/head.js
devtools/client/shared/test/browser_dbg_addon-console.js
devtools/client/shared/test/browser_dbg_listaddons.js
devtools/client/shared/test/helper_addons.js
--- a/devtools/client/debugger/test/mochitest/head.js
+++ b/devtools/client/debugger/test/mochitest/head.js
@@ -158,29 +158,16 @@ function getTargetActorForUrl(aClient, a
   aClient.listTabs().then(aResponse => {
     let targetActor = aResponse.tabs.filter(aGrip => aGrip.url == aUrl).pop();
     deferred.resolve(targetActor);
   });
 
   return deferred.promise;
 }
 
-function getAddonActorForId(aClient, aAddonId) {
-  info("Get addon actor for ID: " + aAddonId);
-  let deferred = promise.defer();
-
-  aClient.listAddons().then(aResponse => {
-    let addonTargetActor = aResponse.addons.filter(aGrip => aGrip.id == aAddonId).pop();
-    info("got addon actor for ID: " + aAddonId);
-    deferred.resolve(addonTargetActor);
-  });
-
-  return deferred.promise;
-}
-
 async function attachTargetActorForUrl(aClient, aUrl) {
   let grip = await getTargetActorForUrl(aClient, aUrl);
   let [ response, front ] = await aClient.attachTarget(grip.actor);
   return [grip, response, front];
 }
 
 async function attachThreadActorForUrl(aClient, aUrl) {
   let [grip, response] = await attachTargetActorForUrl(aClient, aUrl);
@@ -772,28 +759,16 @@ function hideVarPopupByScrollingEditor(a
   editor.setFirstVisibleLine(0);
   return popupHiding.then(waitForTick);
 }
 
 function reopenVarPopup(...aArgs) {
   return hideVarPopup.apply(this, aArgs).then(() => openVarPopup.apply(this, aArgs));
 }
 
-function attachAddonActorForId(aClient, aAddonId) {
-  let deferred = promise.defer();
-
-  getAddonActorForId(aClient, aAddonId).then(aGrip => {
-    aClient.attachAddon(aGrip).then(([aResponse]) => {
-      deferred.resolve([aGrip, aResponse]);
-    });
-  });
-
-  return deferred.promise;
-}
-
 function doResume(aPanel) {
   const threadClient = aPanel.panelWin.gThreadClient;
   return threadClient.resume();
 }
 
 function doInterrupt(aPanel) {
   const threadClient = aPanel.panelWin.gThreadClient;
   return threadClient.interrupt();
--- a/devtools/client/shared/test/browser_dbg_addon-console.js
+++ b/devtools/client/shared/test/browser_dbg_addon-console.js
@@ -58,20 +58,20 @@ AddonDebugger.prototype = {
     document.documentElement.appendChild(this.frame);
     window.addEventListener("message", this._onMessage);
 
     const transport = DebuggerServer.connectPipe();
     this.client = new DebuggerClient(transport);
 
     yield this.client.connect();
 
-    const addonTargetActor = yield getAddonActorForId(this.client, addonId);
+    const addonTargetFront = yield this.client.mainRoot.getAddon({ id: addonId });
 
     const targetOptions = {
-      form: addonTargetActor,
+      activeTab: addonTargetFront,
       client: this.client,
       chrome: true,
     };
 
     const toolboxOptions = {
       customIframe: this.frame,
     };
 
--- a/devtools/client/shared/test/browser_dbg_listaddons.js
+++ b/devtools/client/shared/test/browser_dbg_listaddons.js
@@ -16,17 +16,17 @@ var { DebuggerClient } = require("devtoo
 /**
  * Make sure the listAddons request works as specified.
  */
 const ADDON1_ID = "jid1-oBAwBoE5rSecNg@jetpack";
 const ADDON1_PATH = "addon1.xpi";
 const ADDON2_ID = "jid1-qjtzNGV8xw5h2A@jetpack";
 const ADDON2_PATH = "addon2.xpi";
 
-var gAddon1, gAddon1Actor, gAddon2, gClient;
+var gAddon1, gAddon1Front, gAddon2, gClient;
 
 function test() {
   DebuggerServer.init();
   DebuggerServer.registerAllActors();
 
   const transport = DebuggerServer.connectPipe();
   gClient = new DebuggerClient(transport);
   gClient.connect().then(([aType, aTraits]) => {
@@ -50,69 +50,69 @@ function testFirstAddon() {
   let addonListChanged = false;
   gClient.mainRoot.once("addonListChanged").then(() => {
     addonListChanged = true;
   });
 
   return addTemporaryAddon(ADDON1_PATH).then(addon => {
     gAddon1 = addon;
 
-    return getAddonActorForId(gClient, ADDON1_ID).then(grip => {
+    return gClient.mainRoot.getAddon({ id: ADDON1_ID }).then(front => {
       ok(!addonListChanged, "Should not yet be notified that list of addons changed.");
-      ok(grip, "Should find an addon actor for addon1.");
-      gAddon1Actor = grip.actor;
+      ok(front, "Should find an addon actor for addon1.");
+      gAddon1Front = front;
     });
   });
 }
 
 function testSecondAddon() {
   let addonListChanged = false;
   gClient.mainRoot.once("addonListChanged").then(() => {
     addonListChanged = true;
   });
 
   return addTemporaryAddon(ADDON2_PATH).then(addon => {
     gAddon2 = addon;
 
-    return getAddonActorForId(gClient, ADDON1_ID).then(fistGrip => {
-      return getAddonActorForId(gClient, ADDON2_ID).then(secondGrip => {
+    return gClient.mainRoot.getAddon({ id: ADDON1_ID }).then(front1 => {
+      return gClient.mainRoot.getAddon({ id: ADDON2_ID }).then(front2 => {
         ok(addonListChanged, "Should be notified that list of addons changed.");
-        is(fistGrip.actor, gAddon1Actor, "First addon's actor shouldn't have changed.");
-        ok(secondGrip, "Should find a addon actor for the second addon.");
+        is(front1, gAddon1Front, "First addon's actor shouldn't have changed.");
+        ok(front2, "Should find a addon actor for the second addon.");
       });
     });
   });
 }
 
 function testRemoveFirstAddon() {
   let addonListChanged = false;
   gClient.mainRoot.once("addonListChanged").then(() => {
     addonListChanged = true;
   });
 
   return removeAddon(gAddon1).then(() => {
-    return getAddonActorForId(gClient, ADDON1_ID).then(grip => {
+    return gClient.mainRoot.getAddon({ id: ADDON1_ID }).then(front => {
       ok(addonListChanged, "Should be notified that list of addons changed.");
-      ok(!grip, "Shouldn't find a addon actor for the first addon anymore.");
+      ok(!front, "Shouldn't find a addon actor for the first addon anymore.");
     });
   });
 }
 
 function testRemoveSecondAddon() {
   let addonListChanged = false;
   gClient.mainRoot.once("addonListChanged").then(() => {
     addonListChanged = true;
   });
 
   return removeAddon(gAddon2).then(() => {
-    return getAddonActorForId(gClient, ADDON2_ID).then(grip => {
+    return gClient.mainRoot.getAddon({ id: ADDON2_ID }).then(front => {
       ok(addonListChanged, "Should be notified that list of addons changed.");
-      ok(!grip, "Shouldn't find a addon actor for the second addon anymore.");
+      ok(!front, "Shouldn't find a addon actor for the second addon anymore.");
     });
   });
 }
 
 registerCleanupFunction(function() {
   gAddon1 = null;
-  gAddon1Actor = null;
+  gAddon1Front = null;
   gAddon2 = null;
   gClient = null;
 });
--- a/devtools/client/shared/test/helper_addons.js
+++ b/devtools/client/shared/test/helper_addons.js
@@ -30,29 +30,16 @@ function getAddonURIFromPath(path) {
 
 function addTemporaryAddon(path) {
   const addonFile = getAddonURIFromPath(path).file;
   info("Installing addon: " + addonFile.path);
 
   return AddonManager.installTemporaryAddon(addonFile);
 }
 
-function getAddonActorForId(client, addonId) {
-  info("Get addon actor for ID: " + addonId);
-  const deferred = getDeferredPromise().defer();
-
-  client.listAddons().then(response => {
-    const addonTargetActor = response.addons.filter(grip => grip.id == addonId).pop();
-    info("got addon actor for ID: " + addonId);
-    deferred.resolve(addonTargetActor);
-  });
-
-  return deferred.promise;
-}
-
 function removeAddon(addon) {
   info("Removing addon.");
 
   const deferred = getDeferredPromise().defer();
 
   const listener = {
     onUninstalled: function(uninstalledAddon) {
       if (uninstalledAddon != addon) {