Bug 1553650 - AddonList onUninstalling handler should check the addon type and pending operations. r=mstriemer,robwu
authorLuca Greco <lgreco@mozilla.com>
Wed, 05 Jun 2019 11:56:26 +0000
changeset 536791 59eee64bf66de9d38de28e93a132e8b3f07d349e
parent 536790 504624a04c7641044d0c8edc4c3e66ed7e4e4fab
child 536792 16500a22225b64acab9dc01c328cb5927883d5b9
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstriemer, robwu
bugs1553650
milestone68.0
Bug 1553650 - AddonList onUninstalling handler should check the addon type and pending operations. r=mstriemer,robwu a=jcristau Differential Revision: https://phabricator.services.mozilla.com/D32369
toolkit/mozapps/extensions/content/aboutaddons.js
toolkit/mozapps/extensions/test/browser/browser_html_list_view.js
--- a/toolkit/mozapps/extensions/content/aboutaddons.js
+++ b/toolkit/mozapps/extensions/content/aboutaddons.js
@@ -2126,19 +2126,22 @@ class AddonList extends HTMLElement {
     this.updateAddon(addon);
   }
 
   onDisabled(addon) {
     this.updateAddon(addon);
   }
 
   onUninstalling(addon) {
-    this.pendingUninstallAddons.add(addon);
-    this.addPendingUninstallBar(addon);
-    this.updateAddon(addon);
+    if (isPending(addon, "uninstall") &&
+        (this.type === "all" || addon.type === this.type)) {
+      this.pendingUninstallAddons.add(addon);
+      this.addPendingUninstallBar(addon);
+      this.updateAddon(addon);
+    }
   }
 
   onInstalled(addon) {
     if (this.querySelector(`addon-card[addon-id="${addon.id}"]`)) {
       return;
     }
     this.addAddon(addon);
   }
--- a/toolkit/mozapps/extensions/test/browser/browser_html_list_view.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_html_list_view.js
@@ -178,16 +178,30 @@ add_task(async function testExtensionLis
   ok(getCardByAddonId(disabledSection, addon.id),
      "The card for the first extension is in the disabled section");
   ok(getCardByAddonId(enabledSection, addon2.id),
      "The card for the second extension is in the enabled section");
 
   await extension2.unload();
   await extension.unload();
 
+  // Install a theme and verify that it is not listed in the pending
+  // uninstall message bars while the list extensions view is loaded.
+  const themeXpi = AddonTestUtils.createTempWebExtensionFile({
+    manifest: {
+      name: "My theme",
+      applications: {gecko: {id: "theme@mochi.test"}},
+      theme: {},
+    },
+  });
+  const themeAddon = await AddonManager.installTemporaryAddon(themeXpi);
+  // Leave it pending uninstall, the following assertions related to
+  // the pending uninstall message bars will fail if the theme is listed.
+  await themeAddon.uninstall(true);
+
   // Install a third addon to verify that is being fully removed once the
   // about:addons page is closed.
   const xpi = AddonTestUtils.createTempWebExtensionFile({
     manifest: {
       name: "Test extension 3",
       applications: {gecko: {id: "test-3@mochi.test"}},
       icons: {
         32: "test-icon.png",
@@ -210,16 +224,24 @@ add_task(async function testExtensionLis
   assertHasPendingUninstalls(list, 1);
   ok(addon3 && !!(addon3.pendingOperations & AddonManager.PENDING_UNINSTALL),
      "The third addon is pending uninstall");
 
   await closeView(win);
 
   ok(!await AddonManager.getAddonByID(addon3.id),
      "The third addon has been fully uninstalled");
+
+  ok(themeAddon.pendingOperations & AddonManager.PENDING_UNINSTALL,
+     "The theme addon is pending after the list extension view is closed");
+
+  await themeAddon.uninstall();
+
+  ok(!await AddonManager.getAddonByID(themeAddon.id),
+     "The theme addon is fully uninstalled");
 });
 
 add_task(async function testMouseSupport() {
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       name: "Test extension",
       applications: {gecko: {id: "test@mochi.test"}},
     },