Bug 1491046 - Allow a whitelist of preferences via policy. r=Felipe,flod
☠☠ backed out by b7470e0dfb3e ☠ ☠
authorMichael Kaply <mozilla@kaply.com>
Tue, 02 Apr 2019 18:42:24 +0000
changeset 467644 88a9c30783a6ba2b184aef3f0a5304c4387775f1
parent 467643 10f14d91c8249c211f301b35cfff85907f8580dc
child 467645 15f725097416d14b300e407d11f3dcda726ca337
push id35806
push userrgurzau@mozilla.com
push dateWed, 03 Apr 2019 04:07:39 +0000
treeherdermozilla-central@45808ab18609 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersFelipe, flod
bugs1491046
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1491046 - Allow a whitelist of preferences via policy. r=Felipe,flod Differential Revision: https://phabricator.services.mozilla.com/D25685
browser/components/enterprisepolicies/Policies.jsm
browser/components/enterprisepolicies/schemas/policies-schema.json
browser/components/enterprisepolicies/tests/browser/browser.ini
browser/components/enterprisepolicies/tests/browser/browser_policy_preferences.js
browser/locales/en-US/browser/policies/policies-descriptions.ftl
--- a/browser/components/enterprisepolicies/Policies.jsm
+++ b/browser/components/enterprisepolicies/Policies.jsm
@@ -746,16 +746,24 @@ var Policies = {
         }
         setAndLockPref("dom.disable_open_during_load", blockValue);
       } else if (param.Default !== undefined) {
         setDefaultPref("dom.disable_open_during_load", !!param.Default);
       }
     },
   },
 
+  "Preferences": {
+    onBeforeAddons(manager, param) {
+      for (let preference in param) {
+        setAndLockPref(preference, param[preference]);
+      }
+    },
+  },
+
   "Proxy": {
     onBeforeAddons(manager, param) {
       if (param.Locked) {
         manager.disallowFeature("changeProxySettings");
         ProxyPolicies.configureProxySettings(param, setAndLockPref);
       } else {
         ProxyPolicies.configureProxySettings(param, setDefaultPref);
       }
--- a/browser/components/enterprisepolicies/schemas/policies-schema.json
+++ b/browser/components/enterprisepolicies/schemas/policies-schema.json
@@ -546,16 +546,31 @@
         },
 
         "Locked": {
           "type": "boolean"
         }
       }
     },
 
+    "Preferences": {
+      "type": "object",
+      "properties": {
+        "network.IDN_show_punycode": {
+          "type": "boolean"
+        },
+        "browser.fixup.dns_first_for_single_words": {
+          "type": "boolean"
+        },
+        "browser.cache.disk.parent_directory": {
+          "type": "string"
+        }
+      }
+    },
+
     "Proxy": {
       "type": "object",
       "properties": {
         "Mode": {
           "type": "string",
           "enum": ["none", "system", "manual", "autoDetect", "autoConfig"]
         },
 
--- a/browser/components/enterprisepolicies/tests/browser/browser.ini
+++ b/browser/components/enterprisepolicies/tests/browser/browser.ini
@@ -53,13 +53,14 @@ skip-if = (verify && debug && (os == 'ma
 [browser_policy_disable_telemetry.js]
 [browser_policy_display_bookmarks.js]
 [browser_policy_display_menu.js]
 [browser_policy_extensions.js]
 [browser_policy_locale.js]
 [browser_policy_override_postupdatepage.js]
 [browser_policy_permissions.js]
 [browser_policy_proxy.js]
+[browser_policy_preferences.js]
 [browser_policy_search_engine.js]
 [browser_policy_searchbar.js]
 [browser_policy_set_homepage.js]
 [browser_policy_support_menu.js]
 [browser_policy_websitefilter.js]
new file mode 100644
--- /dev/null
+++ b/browser/components/enterprisepolicies/tests/browser/browser_policy_preferences.js
@@ -0,0 +1,22 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/* This test is not intended to test all preferences that
+   can be set with Preferences, just a subset to verify
+   the overall functionality */
+
+"use strict";
+
+add_task(async function test_policy_preferences() {
+  await setupPolicyEngineWithJson({
+    "policies": {
+      "Preferences": {
+        "network.IDN_show_punycode": true,
+        "app.update.log": true,
+      },
+    },
+  });
+
+  checkLockedPref("network.IDN_show_punycode", true);
+  is(Services.prefs.getBoolPref("app.update.log"), false, "Disallowed pref was not been changed");
+ });
--- a/browser/locales/en-US/browser/policies/policies-descriptions.ftl
+++ b/browser/locales/en-US/browser/policies/policies-descriptions.ftl
@@ -106,16 +106,18 @@ policy-OfferToSaveLogins = Enforce the s
 policy-OverrideFirstRunPage = Override the first run page. Set this policy to blank if you want to disable the first run page.
 
 policy-OverridePostUpdatePage = Override the post-update “What’s New” page. Set this policy to blank if you want to disable the post-update page.
 
 policy-Permissions = Configure permissions for camera, microphone, location and notifications.
 
 policy-PopupBlocking = Allow certain websites to display popups by default.
 
+policy-Preferences = Set and lock the value for a subset of preferences.
+
 policy-Proxy = Configure proxy settings.
 
 policy-RequestedLocales = Set the list of requested locales for the application in order of preference.
 
 policy-SanitizeOnShutdown = Clear all navigation data on shutdown.
 
 policy-SearchBar = Set the default location of the search bar. The user is still allowed to customize it.