Bug 1436851 - Create an enterprise policy to disable system addon updates
MozReview-Commit-ID: AzxFGpFvxtm
--- a/browser/components/enterprisepolicies/EnterprisePolicies.js
+++ b/browser/components/enterprisepolicies/EnterprisePolicies.js
@@ -329,22 +329,28 @@ class JSONPoliciesProvider {
return this._policies;
}
get failed() {
return this._failed;
}
_getConfigurationFile() {
- let configFile = Services.dirsvc.get("XREAppDist", Ci.nsIFile);
- configFile.append(POLICIES_FILENAME);
+ let configFile = null;
+ try {
+ configFile = Services.dirsvc.get("XREAppDist", Ci.nsIFile);
+ configFile.append(POLICIES_FILENAME);
+ } catch (ex) {
+ // Getting the correct directory will fail in xpcshell tests. This should
+ // be handled the same way as if the configFile simply does not exist.
+ }
let alternatePath = Services.prefs.getStringPref(PREF_ALTERNATE_PATH, "");
- if (alternatePath && !configFile.exists()) {
+ if (alternatePath && (!configFile || !configFile.exists())) {
// We only want to use the alternate file path if the file on the install
// folder doesn't exist. Otherwise it'd be possible for a user to override
// the admin-provided policies by changing the user-controlled prefs.
// This pref is only meant for tests, so it's fine to use this extra
// synchronous configFile.exists() above.
if (alternatePath.startsWith(MAGIC_TEST_ROOT_PREFIX)) {
// Intentionally not using a default value on this pref lookup. If no
// test root is set, we are not currently testing and this function
--- a/browser/components/enterprisepolicies/Policies.jsm
+++ b/browser/components/enterprisepolicies/Policies.jsm
@@ -185,16 +185,24 @@ var Policies = {
if (param) {
manager.disallowFeature("privatebrowsing");
manager.disallowFeature("about:privatebrowsing", true);
setAndLockPref("browser.privatebrowsing.autostart", false);
}
}
},
+ "DisableSysAddonUpdate": {
+ onBeforeAddons(manager, param) {
+ if (param) {
+ manager.disallowFeature("SysAddonUpdate");
+ }
+ }
+ },
+
"DisplayBookmarksToolbar": {
onBeforeUIStartup(manager, param) {
if (param) {
// This policy is meant to change the default behavior, not to force it.
// If this policy was alreay applied and the user chose to re-hide the
// bookmarks toolbar, do not show it again.
runOnce("displayBookmarksToolbar", () => {
gXulStore.setValue(BROWSER_DOCUMENT_URL, "PersonalToolbar", "collapsed", "false");
--- a/browser/components/enterprisepolicies/schemas/policies-schema.json
+++ b/browser/components/enterprisepolicies/schemas/policies-schema.json
@@ -153,16 +153,25 @@
"DisablePrivateBrowsing": {
"description": "Disables private browsing.",
"first_available": "60.0",
"type": "boolean",
"enum": [true]
},
+ "DisableSysAddonUpdate": {
+ "description": "Prevent the browser from installing and updating system addons.",
+ "first_available": "60.0",
+ "enterprise_only": true,
+
+ "type": "boolean",
+ "enum": [true]
+ },
+
"DisplayBookmarksToolbar": {
"description": "Causes the bookmarks toolbar to be displayed by default.",
"first_available": "60.0",
"type": "boolean"
},
"DisplayMenuBar": {