diff --git a/toolkit/mozapps/extensions/AddonManager.jsm b/toolkit/mozapps/extensions/AddonManager.jsm index ed6a29c5a39..72bcf2da7de 100644 --- a/toolkit/mozapps/extensions/AddonManager.jsm +++ b/toolkit/mozapps/extensions/AddonManager.jsm @@ -880,6 +880,18 @@ var AddonManager = { PENDING_INSTALL: 8, PENDING_UPGRADE: 16, + // Constants for operations in Addon.operationsRequiringRestart + // Indicates that restart isn't required for any operation. + OP_NEEDS_RESTART_NONE: 0, + // Indicates that restart is required for enabling the addon. + OP_NEEDS_RESTART_ENABLE: 1, + // Indicates that restart is required for disabling the addon. + OP_NEEDS_RESTART_DISABLE: 2, + // Indicates that restart is required for uninstalling the addon. + OP_NEEDS_RESTART_UNINSTALL: 4, + // Indicates that restart is required for installing the addon. + OP_NEEDS_RESTART_INSTALL: 8, + // Constants for permissions in Addon.permissions. // Indicates that the Addon can be uninstalled. PERM_CAN_UNINSTALL: 1, diff --git a/toolkit/mozapps/extensions/LightweightThemeManager.jsm b/toolkit/mozapps/extensions/LightweightThemeManager.jsm index e248aab05ab..9742a6850c9 100644 --- a/toolkit/mozapps/extensions/LightweightThemeManager.jsm +++ b/toolkit/mozapps/extensions/LightweightThemeManager.jsm @@ -421,6 +421,10 @@ function AddonWrapper(aTheme, aBeingEnabled) { return pending; }); + this.__defineGetter__("operationsRequiringRestart", function() { + return AddonManager.OP_NEEDS_RESTART_NONE; + }); + this.__defineGetter__("size", function() { // The size changes depending on whether the theme is in use or not, this is // probably not worth exposing. diff --git a/toolkit/mozapps/extensions/PluginProvider.jsm b/toolkit/mozapps/extensions/PluginProvider.jsm index 4b48064c92e..d5f2785db79 100644 --- a/toolkit/mozapps/extensions/PluginProvider.jsm +++ b/toolkit/mozapps/extensions/PluginProvider.jsm @@ -264,7 +264,11 @@ function PluginWrapper(aId, aName, aDescription, aTags) { }); this.__defineGetter__("pendingOperations", function() { - return 0; + return AddonManager.PENDING_NONE; + }); + + this.__defineGetter__("operationsRequiringRestart", function() { + return AddonManager.OP_NEEDS_RESTART_NONE; }); this.__defineGetter__("permissions", function() { diff --git a/toolkit/mozapps/extensions/XPIProvider.jsm b/toolkit/mozapps/extensions/XPIProvider.jsm index fa3985aecd4..f73e6ef633c 100644 --- a/toolkit/mozapps/extensions/XPIProvider.jsm +++ b/toolkit/mozapps/extensions/XPIProvider.jsm @@ -5149,6 +5149,20 @@ function AddonWrapper(aAddon) { return pending; }); + this.__defineGetter__("operationsRequiringRestart", function() { + let ops = 0; + if (XPIProvider.installRequiresRestart(aAddon)) + ops |= AddonManager.OP_NEEDS_RESTART_INSTALL; + if (XPIProvider.uninstallRequiresRestart(aAddon)) + ops |= AddonManager.OP_NEEDS_RESTART_UNINSTALL; + if (XPIProvider.enableRequiresRestart(aAddon)) + ops |= AddonManager.OP_NEEDS_RESTART_ENABLE; + if (XPIProvider.disableRequiresRestart(aAddon)) + ops |= AddonManager.OP_NEEDS_RESTART_DISABLE; + + return ops; + }); + this.__defineGetter__("permissions", function() { let permissions = 0; if (!aAddon.appDisabled) { diff --git a/toolkit/mozapps/extensions/test/browser/head.js b/toolkit/mozapps/extensions/test/browser/head.js index 452e7572fd9..9281de9b1a4 100644 --- a/toolkit/mozapps/extensions/test/browser/head.js +++ b/toolkit/mozapps/extensions/test/browser/head.js @@ -286,8 +286,10 @@ MockProvider.prototype = { if (!this.started) return; + let requiresRestart = (aAddon.operationsRequiringRestart & + AddonManager.OP_NEEDS_RESTART_INSTALL) != 0; AddonManagerPrivate.callInstallListeners("onExternalInstall", null, aAddon, - null, false) + null, requiresRestart) }, /** @@ -576,8 +578,8 @@ MockProvider.prototype = { /***** Mock Addon object for the Mock Provider *****/ -function MockAddon(aId, aName, aType, aRestartless) { - // Only set required attributes +function MockAddon(aId, aName, aType, aOperationsRequiringRestart) { + // Only set required attributes. this.id = aId || ""; this.name = aName || ""; this.type = aType || "extension"; @@ -592,8 +594,11 @@ function MockAddon(aId, aName, aType, aRestartless) { this.creator = ""; this.pendingOperations = 0; this.permissions = 0; - - this._restartless = aRestartless || false; + this.operationsRequiringRestart = aOperationsRequiringRestart || + (AddonManager.OP_NEEDS_RESTART_INSTALL | + AddonManager.OP_NEEDS_RESTART_UNINSTALL | + AddonManager.OP_NEEDS_RESTART_ENABLE | + AddonManager.OP_NEEDS_RESTART_DISABLE); } MockAddon.prototype = { diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap.js b/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap.js index ac2aee70250..988b5597c04 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_bootstrap.js @@ -61,6 +61,8 @@ function run_test_1() { do_check_true(install.addon.hasResource("install.rdf")); do_check_true(install.addon.hasResource("bootstrap.js")); do_check_false(install.addon.hasResource("foo.bar")); + do_check_eq(install.addon.operationsRequiringRestart & + AddonManager.OP_NEEDS_RESTART_INSTALL, 0); do_check_not_in_crash_annotation("bootstrap1@tests.mozilla.org", "1.0"); prepare_test({ @@ -121,6 +123,8 @@ function run_test_2() { ] }); + do_check_eq(b1.operationsRequiringRestart & + AddonManager.OP_NEEDS_RESTART_DISABLE, 0); b1.userDisabled = true; ensure_test_completed(); @@ -179,6 +183,8 @@ function run_test_4() { ] }); + do_check_eq(b1.operationsRequiringRestart & + AddonManager.OP_NEEDS_RESTART_ENABLE, 0); b1.userDisabled = false; ensure_test_completed(); @@ -285,6 +291,8 @@ function run_test_7() { ] }); + do_check_eq(b1.operationsRequiringRestart & + AddonManager.OP_NEEDS_RESTART_UNINSTALL, 0); b1.uninstall(); check_test_7(); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_disable.js b/toolkit/mozapps/extensions/test/xpcshell/test_disable.js index 77c9fc26fcc..c1adc8c705b 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_disable.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_disable.js @@ -72,6 +72,8 @@ function run_test_1() { }); AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) { + do_check_neq(a1.operationsRequiringRestart & + AddonManager.OP_NEEDS_RESTART_DISABLE, 0); a1.userDisabled = true; do_check_eq(a1.aboutURL, "chrome://foo/content/about.xul"); do_check_eq(a1.optionsURL, "chrome://foo/content/options.xul"); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_install.js b/toolkit/mozapps/extensions/test/xpcshell/test_install.js index d127ea66522..efa2baf0a37 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_install.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_install.js @@ -65,7 +65,8 @@ function run_test_1() { do_check_true(install.addon.hasResource("install.rdf")); do_check_eq(install.addon.install, install); do_check_eq(install.addon.size, ADDON1_SIZE); - + do_check_neq(install.addon.operationsRequiringRestart & + AddonManager.OP_NEEDS_RESTART_INSTALL, 0); let file = do_get_addon("test_install1"); let uri = Services.io.newFileURI(file).spec; do_check_eq(install.addon.getResourceURI("install.rdf").spec, "jar:" + uri + "!/install.rdf"); diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_uninstall.js b/toolkit/mozapps/extensions/test/xpcshell/test_uninstall.js index 64b36057f98..672aed6a65e 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_uninstall.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_uninstall.js @@ -60,6 +60,8 @@ function run_test_1() { }); AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) { do_check_eq(a1.pendingOperations, 0); + do_check_neq(a1.operationsRequiringRestart & + AddonManager.OP_NEEDS_RESTART_UNINSTALL, 0); a1.uninstall(); do_check_true(hasFlag(a1.pendingOperations, AddonManager.PENDING_UNINSTALL)); do_check_in_crash_annotation(addon1.id, addon1.version);