Bug 1544824 - Redirect to list view when an extension is removed r=rpl
authorMark Striemer <mstriemer@mozilla.com>
Fri, 17 May 2019 20:21:25 +0000
changeset 474415 4cc7642d8e0f98492aab3209e3c547d1b270c430
parent 474414 c0df3469a4cb5982613aca1cfef71af8ba38b843
child 474416 7dc6dbc72a41b56669726ebc835aeb5cf0ded1ab
push id85795
push usermstriemer@mozilla.com
push dateFri, 17 May 2019 22:28:35 +0000
treeherderautoland@4cc7642d8e0f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrpl
bugs1544824
milestone68.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 1544824 - Redirect to list view when an extension is removed r=rpl Differential Revision: https://phabricator.services.mozilla.com/D30738
toolkit/mozapps/extensions/content/aboutaddons.js
toolkit/mozapps/extensions/test/browser/browser_html_detail_view.js
--- a/toolkit/mozapps/extensions/content/aboutaddons.js
+++ b/toolkit/mozapps/extensions/content/aboutaddons.js
@@ -55,17 +55,17 @@ const PREF_RECOMMENDATION_ENABLED = "bro
 const PREF_TELEMETRY_ENABLED = "datareporting.healthreport.uploadEnabled";
 const PRIVATE_BROWSING_PERM_NAME = "internal:privateBrowsingAllowed";
 const PRIVATE_BROWSING_PERMS =
   {permissions: [PRIVATE_BROWSING_PERM_NAME], origins: []};
 
 const AddonCardListenerHandler = {
   ADDON_EVENTS: new Set([
     "onDisabled", "onEnabled", "onInstalled", "onPropertyChanged",
-    "onUninstalled",
+    "onUninstalling",
   ]),
   MANAGER_EVENTS: new Set(["onUpdateModeChanged"]),
   INSTALL_EVENTS: new Set(["onNewInstall", "onInstallEnded"]),
 
   delegateAddonEvent(name, args) {
     this.delegateEvent(name, args[0], args);
   },
 
@@ -1228,16 +1228,22 @@ class AddonCard extends HTMLElement {
     }
   }
 
   onEnabled(addon) {
     this.reloading = false;
     this.update();
   }
 
+  onUninstalling() {
+    // Dispatch a remove event, the DetailView is listening for this to get us
+    // back to the list view when the current add-on is removed.
+    this.sendEvent("remove");
+  }
+
   onUpdateModeChanged() {
     this.update();
   }
 
   onPropertyChanged(addon, changed) {
     if (this.details && changed.includes("applyBackgroundUpdates")) {
       this.details.update();
     } else if (addon.type == "plugin" && changed.includes("userDisabled")) {
--- a/toolkit/mozapps/extensions/test/browser/browser_html_detail_view.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_html_detail_view.js
@@ -635,16 +635,89 @@ add_task(async function testPrivateBrows
 
   ok(!badge.hidden, "The PB badge is hidden");
   ok(await hasPrivateAllowed("pb@mochi.test"), "PB is disallowed");
 
   await extension.unload();
   await closeView(win);
 });
 
+add_task(async function testExternalUninstall() {
+  let id = "remove@mochi.test";
+  let extension = ExtensionTestUtils.loadExtension({
+    manifest: {
+      name: "Remove me",
+      applications: {gecko: {id}},
+    },
+    useAddonManager: "temporary",
+  });
+  await extension.startup();
+  let addon = await AddonManager.getAddonByID(id);
+
+  let win = await loadInitialView("extension");
+  let doc = win.document;
+
+  // Load the detail view.
+  let card = doc.querySelector(`addon-card[addon-id="${id}"]`);
+  let detailsLoaded = waitForViewLoad(win);
+  card.querySelector('[action="expand"]').click();
+  await detailsLoaded;
+
+  // Uninstall the add-on with undo. Should go to extension list.
+  let listLoaded = waitForViewLoad(win);
+  await addon.uninstall(true);
+  await listLoaded;
+
+  // Verify the list view was loaded and the card is gone.
+  let list = doc.querySelector("addon-list");
+  is(list.type, "extension", "We're on the extension list page");
+  card = list.querySelector(`addon-card[addon-id="${id}"]`);
+  ok(!card, "The card has been removed");
+
+  await extension.unload();
+  closeView(win);
+});
+
+add_task(async function testExternalThemeUninstall() {
+  let id = "remove-theme@mochi.test";
+  let extension = ExtensionTestUtils.loadExtension({
+    manifest: {
+      applications: {gecko: {id}},
+      name: "Remove theme",
+      theme: {},
+    },
+    useAddonManager: "temporary",
+  });
+  await extension.startup();
+  let addon = await AddonManager.getAddonByID(id);
+
+  let win = await loadInitialView("theme");
+  let doc = win.document;
+
+  // Load the detail view.
+  let card = doc.querySelector(`addon-card[addon-id="${id}"]`);
+  let detailsLoaded = waitForViewLoad(win);
+  card.querySelector('[action="expand"]').click();
+  await detailsLoaded;
+
+  // Uninstall the add-on without undo. Should go to theme list.
+  let listLoaded = waitForViewLoad(win);
+  await addon.uninstall();
+  await listLoaded;
+
+  // Verify the list view was loaded and the card is gone.
+  let list = doc.querySelector("addon-list");
+  is(list.type, "theme", "We're on the theme list page");
+  card = list.querySelector(`addon-card[addon-id="${id}"]`);
+  ok(!card, "The card has been removed");
+
+  await extension.unload();
+  closeView(win);
+});
+
 add_task(async function testPrivateBrowsingAllowedListView() {
   let extension = ExtensionTestUtils.loadExtension({
     manifest: {
       name: "Allowed PB extension",
       applications: {gecko: {id: "allowed@mochi.test"}},
     },
     useAddonManager: "permanent",
   });