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 412323 65fcedb6c1f8ff440941774d47cb2a7734f80222
parent 412322 c52cd79ee39d895b4bd607b1c28b94a3d5b8d70b
child 412324 0205cdd17a67432a736f15888347eae8861fc5fa
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [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}
  */