Bug 1079450 - Let uninstall listener handle removing add-on from list. r=mfinkle
authorMargaret Leibovic <margaret.leibovic@gmail.com>
Tue, 07 Oct 2014 15:32:28 -0700
changeset 232526 6ee8bbf1b8f2e652ed2bbdfeaf155183ff533ee2
parent 232525 e85576df82277dba460a6382968338941eac321c
child 232527 0554ceb29cdcac1eaad3a4c6d94f995aa79b80cd
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs1079450
milestone35.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 1079450 - Let uninstall listener handle removing add-on from list. r=mfinkle
mobile/android/chrome/content/aboutAddons.js
--- a/mobile/android/chrome/content/aboutAddons.js
+++ b/mobile/android/chrome/content/aboutAddons.js
@@ -438,39 +438,34 @@ var Addons = {
     let addon = detailItem.addon;
     if (!addon)
       return;
 
     this.uninstall(addon);
   },
 
   uninstall: function uninstall(aAddon) {
-    let list = document.getElementById("addons-list");
-
     if (!aAddon) {
-        return;
+      return;
     }
 
     let listItem = this._getElementForAddon(aAddon.id);
+    aAddon.uninstall();
 
-    aAddon.uninstall();
     if (aAddon.pendingOperations & AddonManager.PENDING_UNINSTALL) {
       this.showRestart();
 
       // A disabled addon doesn't need a restart so it has no pending ops and
       // can't be cancelled
       let opType = this._getOpTypeForOperations(aAddon.pendingOperations);
       if (!aAddon.isActive && opType == "")
         opType = "needs-uninstall";
 
       detailItem.setAttribute("opType", opType);
       listItem.setAttribute("opType", opType);
-    } else {
-      list.removeChild(listItem);
-      history.back();
     }
   },
 
   cancelUninstall: function ev_cancelUninstall() {
     let detailItem = document.querySelector("#addons-details > .addon-item");
     let addon = detailItem.addon;
     if (!addon)
       return;
@@ -534,16 +529,22 @@ var Addons = {
       list.insertBefore(element, list.firstElementChild);
     }
   },
 
   onUninstalled: function(aAddon) {
     let list = document.getElementById("addons-list");
     let element = this._getElementForAddon(aAddon.id);
     list.removeChild(element);
+
+    // Go back if we're in the detail view of the add-on that was uninstalled.
+    let detailItem = document.querySelector("#addons-details > .addon-item");
+    if (detailItem.addon == aAddon) {
+      history.back();
+    }
   },
 
   onInstallFailed: function(aInstall) {
   },
 
   onDownloadProgress: function xpidm_onDownloadProgress(aInstall) {
   },