From 1d9cc07ff7d1178ad24ecbe99cd5f879c2f50ca8 Mon Sep 17 00:00:00 2001 From: Blair McBride Date: Thu, 3 Jul 2014 16:19:58 +1200 Subject: [PATCH] Bug 1026853 - Experiment is displayed as "pending removal" in detailed view. r=irving --- toolkit/mozapps/extensions/internal/XPIProvider.jsm | 13 +++++++++---- .../extensions/test/xpcshell/test_experiment.js | 8 ++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/toolkit/mozapps/extensions/internal/XPIProvider.jsm b/toolkit/mozapps/extensions/internal/XPIProvider.jsm index e9fd92bf821..dd2b2c1cefe 100644 --- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm +++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm @@ -6646,10 +6646,15 @@ function AddonWrapper(aAddon) { 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 inconsistency 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; diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_experiment.js b/toolkit/mozapps/extensions/test/xpcshell/test_experiment.js index e070c363c8c..25172749ddb 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_experiment.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_experiment.js @@ -24,6 +24,10 @@ add_test(function test_experiment() { "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; @@ -72,6 +76,10 @@ add_test(function test_userDisabledNotPersisted() { 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();