Bug 616620: Hide the disable button for add-ons that are waiting to install. r=robstrong, a=blocks-betaN
authorDave Townsend <dtownsend@oxymoronical.com>
Tue, 11 Jan 2011 09:44:25 -0800
changeset 60306 d48eb4e9d90301b0a684047109ef4b9cc1e6a2a8
parent 60305 3844d838d24afbe1312f0060f31aee3e27b30864
child 60307 fc1817a3d7a4cba01542acb0f949af292cbc0617
push idunknown
push userunknown
push dateunknown
reviewersrobstrong, blocks-betaN
bugs616620
milestone2.0b10pre
Bug 616620: Hide the disable button for add-ons that are waiting to install. r=robstrong, a=blocks-betaN
toolkit/mozapps/extensions/XPIProvider.jsm
toolkit/mozapps/extensions/test/xpcshell/test_install.js
--- a/toolkit/mozapps/extensions/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/XPIProvider.jsm
@@ -6518,27 +6518,31 @@ function AddonWrapper(aAddon) {
     if (XPIProvider.disableRequiresRestart(aAddon))
       ops |= AddonManager.OP_NEEDS_RESTART_DISABLE;
 
     return ops;
   });
 
   this.__defineGetter__("permissions", function() {
     let permissions = 0;
+
+    // Add-ons that aren't installed cannot be modified in any way
+    if (!(aAddon instanceof DBAddonInternal))
+      return permissions;
+
     if (!aAddon.appDisabled) {
       if (aAddon.userDisabled)
         permissions |= AddonManager.PERM_CAN_ENABLE;
       else if (aAddon.type != "theme")
         permissions |= AddonManager.PERM_CAN_DISABLE;
     }
-    // Add-ons that have no install location (these are add-ons that are pending
-    // installation), are in locked install locations, or are pending uninstall
+
+    // Add-ons that are in locked install locations, or are pending uninstall
     // cannot be upgraded or uninstalled
-    if (aAddon._installLocation && !aAddon._installLocation.locked &&
-        !aAddon.pendingUninstall) {
+    if (!aAddon._installLocation.locked && !aAddon.pendingUninstall) {
       // Add-ons that are installed by a file link cannot be upgraded
       if (!aAddon._installLocation.isLinkedAddon(aAddon.id))
         permissions |= AddonManager.PERM_CAN_UPGRADE;
 
       permissions |= AddonManager.PERM_CAN_UNINSTALL;
     }
     return permissions;
   });
--- a/toolkit/mozapps/extensions/test/xpcshell/test_install.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_install.js
@@ -133,16 +133,20 @@ function check_test_1() {
           zipReader.close();
         }
       }
       else {
         let iconFile = uri.QueryInterface(AM_Ci.nsIFileURL).file;
         do_check_true(iconFile.exists());
       }
 
+      // The pending add-on cannot be disabled or enabled.
+      do_check_false(hasFlag(pendingAddons[0].permissions, AddonManager.PERM_CAN_ENABLE));
+      do_check_false(hasFlag(pendingAddons[0].permissions, AddonManager.PERM_CAN_DISABLE));
+
       restartManager();
 
       AddonManager.getAllInstalls(function(activeInstalls) {
         do_check_eq(activeInstalls, 0);
 
         AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
           do_check_neq(a1, null);
           do_check_eq(a1.type, "extension");