Bug 1026853 - Experiment is displayed as "pending removal" in detailed view. r=irving,a=lmandel
authorBlair McBride <bmcbride@mozilla.com>
Fri, 25 Jul 2014 14:21:28 +0200
changeset 208165 ecdde13a0aaa
parent 208164 794d229b5125
child 208166 fe0621be0dc3
push id3751
push usergeorg.fritzsche@googlemail.com
push date2014-07-25 12:21 +0000
treeherdermozilla-beta@ecdde13a0aaa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersirving, lmandel
bugs1026853
milestone32.0
Bug 1026853 - Experiment is displayed as "pending removal" in detailed view. r=irving,a=lmandel
toolkit/mozapps/extensions/internal/XPIProvider.jsm
toolkit/mozapps/extensions/test/xpcshell/test_experiment.js
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -6637,20 +6637,25 @@ function AddonWrapper(aAddon) {
         return AddonManager.PENDING_INSTALL;
     }
     else if (aAddon.pendingUninstall) {
       // If an add-on is pending uninstall then we ignore any other pending
       // operations
       return AddonManager.PENDING_UNINSTALL;
     }
 
-    if (aAddon.active && isAddonDisabled(aAddon))
-      pending |= AddonManager.PENDING_DISABLE;
-    else if (!aAddon.active && !isAddonDisabled(aAddon))
-      pending |= AddonManager.PENDING_ENABLE;
+    // Extensions have an intentional inconsistancy between what the DB says is
+    // enabled and what we say to the ouside world. so we need to cover up that
+    // lie here as well.
+    if (aAddon.type != "experiment") {
+      if (aAddon.active && isAddonDisabled(aAddon))
+        pending |= AddonManager.PENDING_DISABLE;
+      else if (!aAddon.active && !isAddonDisabled(aAddon))
+        pending |= AddonManager.PENDING_ENABLE;
+    }
 
     if (aAddon.pendingUpgrade)
       pending |= AddonManager.PENDING_UPGRADE;
 
     return pending;
   });
 
   this.__defineGetter__("operationsRequiringRestart", function AddonWrapper_operationsRequiringRestartGetter() {
--- a/toolkit/mozapps/extensions/test/xpcshell/test_experiment.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_experiment.js
@@ -19,16 +19,20 @@ add_test(function test_experiment() {
 
         Assert.ok(addon.userDisabled, "Experiments are userDisabled by default.");
         Assert.equal(addon.isActive, false, "Add-on is not active.");
         Assert.equal(addon.updateURL, null, "No updateURL for experiments.");
         Assert.equal(addon.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DISABLE,
                      "Background updates are disabled.");
         Assert.equal(addon.permissions, AddonManager.PERM_CAN_UNINSTALL,
                      "Permissions are minimal.");
+        Assert.ok(!(addon.pendingOperations & AddonManager.PENDING_ENABLE),
+                  "Should not be pending enable");
+        Assert.ok(!(addon.pendingOperations & AddonManager.PENDING_DISABLE),
+                  "Should not be pending disable");
 
         // Setting applyBackgroundUpdates should not work.
         addon.applyBackgroundUpdates = AddonManager.AUTOUPDATE_ENABLE;
         Assert.equal(addon.applyBackgroundUpdates, AddonManager.AUTOUPDATE_DISABLE,
                      "Setting applyBackgroundUpdates shouldn't do anything.");
 
         let noCompatibleCalled = false;
         let noUpdateCalled = false;
@@ -67,16 +71,20 @@ add_test(function test_userDisabledNotPe
 
         Assert.ok("experiment1@tests.mozilla.org" in XPIProvider.bootstrappedAddons,
                   "Experiment add-on listed in XPIProvider bootstrapped list.");
 
         AddonManager.getAddonByID("experiment1@tests.mozilla.org", (addon) => {
           Assert.ok(addon, "Add-on retrieved.");
           Assert.equal(addon.userDisabled, false, "Add-on is still enabled after API retrieve.");
           Assert.ok(addon.isActive, "Add-on is still active.");
+          Assert.ok(!(addon.pendingOperations & AddonManager.PENDING_ENABLE),
+                    "Should not be pending enable");
+          Assert.ok(!(addon.pendingOperations & AddonManager.PENDING_DISABLE),
+                    "Should not be pending disable");
 
           // Now when we restart the manager the add-on should revert state.
           restartManager();
           let persisted = JSON.parse(Services.prefs.getCharPref("extensions.bootstrappedAddons"));
           Assert.ok(!("experiment1@tests.mozilla.org" in persisted),
                     "Experiment add-on not persisted to bootstrappedAddons.");
 
           AddonManager.getAddonByID("experiment1@tests.mozilla.org", (addon) => {