Bug 1363760 - Part 1 - Allow the about:debugging tests to pass if there are no temporary addons installed draft
authorAlex Gaynor <agaynor@mozilla.com>
Tue, 30 May 2017 10:04:29 -0400
changeset 586471 09fc5c4b2937f237a52a727db6bf048f7df31401
parent 586442 286f71223256cbb3a769432fd860f563c4886e81
child 586472 0f6bb5c1d32e7ea9abb921f2696d76b19c0eb54f
child 586502 1f897aa292ed8bde754482cf682e2a5617963c0a
push id61417
push userbmo:agaynor@mozilla.com
push dateTue, 30 May 2017 14:12:58 +0000
bugs1363760
milestone55.0a1
Bug 1363760 - Part 1 - Allow the about:debugging tests to pass if there are no temporary addons installed 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}
  */