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
--- 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}
*/