Bug 1287007 - Fix test_ext_management_uninstall_self.js
The test logic was broken by design: Two tests uninstall the addon,
but only one uninstall observer was used. Consequently, the second
test resumes the test before the addon was actually uninstalled.
It is probably sheer luck that the test worked before.
MozReview-Commit-ID: DcT48ZQ2bRp
--- a/toolkit/components/extensions/test/xpcshell/test_ext_management_uninstall_self.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_management_uninstall_self.js
@@ -14,17 +14,17 @@ const manifest = {
gecko: {
id,
},
},
name: "test extension name",
version: "1.0",
};
-const waitForUninstalled = new Promise(resolve => {
+const waitForUninstalled = () => new Promise(resolve => {
const listener = {
onUninstalled: (addon) => {
equal(addon.id, id, "The expected add-on has been uninstalled");
AddonManager.getAddonByID(addon.id, checkedAddon => {
equal(checkedAddon, null, "Add-on no longer exists");
AddonManager.removeAddonListener(listener);
resolve();
});
@@ -62,17 +62,17 @@ add_task(function* test_management_unins
background,
useAddonManager: "temporary",
});
yield extension.startup();
let addon = yield promiseAddonByID(id);
notEqual(addon, null, "Add-on is installed");
extension.sendMessage("uninstall");
- yield waitForUninstalled;
+ yield waitForUninstalled();
yield extension.markUnloaded();
Services.obs.notifyObservers(extension.extension.file, "flush-cache-entry", null);
});
add_task(function* test_management_uninstall_prompt_uninstall() {
promptService._response = 0;
function background() {
@@ -86,17 +86,17 @@ add_task(function* test_management_unins
background,
useAddonManager: "temporary",
});
yield extension.startup();
let addon = yield promiseAddonByID(id);
notEqual(addon, null, "Add-on is installed");
extension.sendMessage("uninstall");
- yield waitForUninstalled;
+ yield waitForUninstalled();
yield extension.markUnloaded();
// Test localization strings
equal(promptService._confirmExArgs[1], `Uninstall ${manifest.name}`);
equal(promptService._confirmExArgs[2],
`The extension “${manifest.name}” is requesting to be uninstalled. What would you like to do?`);
equal(promptService._confirmExArgs[4], "Uninstall");
equal(promptService._confirmExArgs[5], "Keep Installed");