Bug 1363760 - Part 1 - Allow the about:debugging tests to pass if there are no temporary addons installed r=jdescottes
authorAlex Gaynor <agaynor@mozilla.com>
Tue, 30 May 2017 10:04:29 -0400
changeset 361848 65fcedb6c1f8
parent 361847 c52cd79ee39d
child 361849 0205cdd17a67
push id31945
push userryanvm@gmail.com
push dateThu, 01 Jun 2017 20:42:17 +0000
treeherdermozilla-central@15e32469eb04 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes
bugs1363760
milestone55.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 1363760 - Part 1 - Allow the about:debugging tests to pass if there are no temporary addons installed r=jdescottes The current DOM tests for about:debugging implicitly assume that there is a temporary addon installed before they start. This is currently always true because mochitest and specialpowers are installed as temporary addons, but the goal of this bug is to install them as non-temporary addons. The specific cause of the breakage is the assumption that uninstalling an addon removes an <li> from the addons <ul>, but when you go from one addon to zero the entire <ul> is removed. MozReview-Commit-ID: VJIcy17uQc
devtools/client/aboutdebugging/test/browser_addons_remove.js
devtools/client/aboutdebugging/test/head.js
--- a/devtools/client/aboutdebugging/test/browser_addons_remove.js
+++ b/devtools/client/aboutdebugging/test/browser_addons_remove.js
@@ -23,18 +23,18 @@ add_task(function* removeLegacyExtension
     path: "addons/unpacked/install.rdf",
     name: addonName,
   });
 
   ok(getTargetEl(document, addonID), "add-on is shown");
 
   // Click the remove button and wait for the DOM to change.
   const addonListMutation = waitForMutation(
-    getTemporaryAddonList(document),
-    { childList: true });
+    getTemporaryAddonList(document).parentNode,
+    { childList: true, subtree: true });
   getRemoveButton(document, addonID).click();
   yield addonListMutation;
 
   ok(!getTargetEl(document, addonID), "add-on is not shown");
 
   yield closeAboutDebugging(tab);
 });
 
@@ -52,18 +52,18 @@ add_task(function* removeWebextension() 
     name: addonName,
     isWebExtension: true,
   });
 
   ok(getTargetEl(document, addonID), "add-on is shown");
 
   // Click the remove button and wait for the DOM to change.
   const addonListMutation = waitForMutation(
-    getTemporaryAddonList(document),
-    { childList: true });
+    getTemporaryAddonList(document).parentNode,
+    { childList: true, subtree: true });
   getRemoveButton(document, addonID).click();
   yield addonListMutation;
 
   ok(!getTargetEl(document, addonID), "add-on is not shown");
 
   yield closeAboutDebugging(tab);
 });
 
--- a/devtools/client/aboutdebugging/test/head.js
+++ b/devtools/client/aboutdebugging/test/head.js
@@ -208,17 +208,18 @@ function* installAddon({document, path, 
   let names = [...addonList.querySelectorAll(".target-name")];
   names = names.map(element => element.textContent);
   ok(names.includes(name),
     "The addon name appears in the list of addons: " + names);
 }
 
 function* uninstallAddon({document, id, name}) {
   let addonList = getAddonListWithAddon(document, id);
-  let addonListMutation = waitForMutation(addonList, { childList: true });
+  let addonListMutation = waitForMutation(addonList.parentNode,
+                                          { childList: true, subtree: true });
 
   // Now uninstall this addon
   yield new Promise(done => {
     AddonManager.getAddonByID(id, addon => {
       let listener = {
         onUninstalled: function (uninstalledAddon) {
           if (uninstalledAddon != addon) {
             return;
@@ -228,23 +229,28 @@ function* uninstallAddon({document, id, 
           done();
         }
       };
       AddonManager.addAddonListener(listener);
       addon.uninstall();
     });
   });
 
-  // Ensure that the UI removes the addon from the list
   yield addonListMutation;
-  let names = [...addonList.querySelectorAll(".target-name")];
-  names = names.map(element => element.textContent);
-  ok(!names.includes(name),
-    "After uninstall, the addon name disappears from the list of addons: "
-    + names);
+
+  // If parentNode is none, that means the entire addonList was removed from the
+  // document. This happens when the addon we are removing is the last one.
+  if (addonList.parentNode !== null) {
+    // Ensure that the UI removes the addon from the list
+    let names = [...addonList.querySelectorAll(".target-name")];
+    names = names.map(element => element.textContent);
+    ok(!names.includes(name),
+      "After uninstall, the addon name disappears from the list of addons: "
+      + names);
+  }
 }
 
 /**
  * Returns a promise that will resolve when the add-on list has been updated.
  *
  * @param {Node} document
  * @return {Promise}
  */