Bug 1287007 - Fix test_ext_management_uninstall_self.js draft
authorRob Wu <rob@robwu.nl>
Tue, 13 Sep 2016 13:59:37 -0700
changeset 428445 99e88e15e92d273d05b411b92efd51fe7d7eb9bb
parent 428444 a86fd1c2502d51b36d7e9d8b6c4e788002d205d7
child 428446 4e76e3f93a905dd3af9a58cfec9d571903c47e26
push id33305
push userbmo:rob@robwu.nl
push dateSun, 23 Oct 2016 20:56:25 +0000
bugs1287007
milestone52.0a1
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
toolkit/components/extensions/test/xpcshell/test_ext_management_uninstall_self.js
--- 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");