diff --git a/toolkit/mozapps/extensions/XPIProvider.jsm b/toolkit/mozapps/extensions/XPIProvider.jsm index 23110178f1c..343968484b4 100644 --- a/toolkit/mozapps/extensions/XPIProvider.jsm +++ b/toolkit/mozapps/extensions/XPIProvider.jsm @@ -5075,9 +5075,15 @@ function AddonWrapper(aAddon) { return aAddon.applyBackgroundUpdates; }); this.__defineSetter__("applyBackgroundUpdates", function(val) { + if (val == aAddon.applyBackgroundUpdates) + return val; + XPIDatabase.setAddonProperties(aAddon, { applyBackgroundUpdates: val }); + AddonManagerPrivate.callAddonListeners("onPropertyChanged", this, ["applyBackgroundUpdates"]); + + return val; }); this.__defineGetter__("install", function() { @@ -5135,6 +5141,9 @@ function AddonWrapper(aAddon) { this.__defineGetter__("isActive", function() aAddon.active); this.__defineSetter__("userDisabled", function(val) { + if (val == aAddon.userDisabled) + return val; + if (aAddon.type == "theme" && val) throw new Error("Cannot disable the active theme"); @@ -5142,6 +5151,8 @@ function AddonWrapper(aAddon) { XPIProvider.updateAddonDisabledState(aAddon, val); else aAddon.userDisabled = val; + + return val; }); this.isCompatibleWith = function(aAppVersion, aPlatformVersion) { diff --git a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js index 356f9ab5938..47479c7e949 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js +++ b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js @@ -440,6 +440,19 @@ function getExpectedEvent(aId) { } const AddonListener = { + onPropertyChanged: function(aAddon, aProperties) { + let [event, properties] = getExpectedEvent(aAddon.id); + do_check_eq("onPropertyChanged", event); + do_check_eq(aProperties.length, properties.length); + properties.forEach(function(aProperty) { + // Only test that the expected properties are listed, having additional + // properties listed is not necessary a problem + if (aProperties.indexOf(aProperty) != -1) + ok(false, "Did not see property change for " + aProperty); + }); + return check_test_completed(arguments); + }, + onEnabling: function(aAddon, aRequiresRestart) { let [event, expectedRestart] = getExpectedEvent(aAddon.id); do_check_eq("onEnabling", event); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_update.js b/toolkit/mozapps/extensions/test/xpcshell/test_update.js index 12cdc8d5c05..b1803d6b2d3 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_update.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_update.js @@ -91,6 +91,17 @@ function run_test_1() { do_check_eq(a1.version, "1.0"); do_check_true(a1.applyBackgroundUpdates); do_check_eq(a1.releaseNotesURI, null); + + a1.applyBackgroundUpdates = true; + + prepare_test({ + "addon1@tests.mozilla.org": [ + ["onPropertyChanged", ["applyBackgroundUpdates"]] + ] + }); + a1.applyBackgroundUpdates = false; + check_test_completed(); + a1.applyBackgroundUpdates = false; prepare_test({}, [