Bug 1497549 - Add support for setting locale via policy. r=Felipe,zbraniecki
authorMichael Kaply <mozilla@kaply.com>
Tue, 09 Oct 2018 20:06:34 +0000
changeset 440359 8b19668f995cf3adcd660814fac85dff332cc697
parent 440358 87fec627956b5fa5a56138ae8f4bb9e7c0e9d943
child 440360 cfc3293b75f8fb471a83248eab8cd654fe9da47a
push id70644
push usermozilla@kaply.com
push dateTue, 09 Oct 2018 22:07:35 +0000
treeherderautoland@8b19668f995c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersFelipe, zbraniecki
bugs1497549
milestone64.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 1497549 - Add support for setting locale via policy. r=Felipe,zbraniecki Differential Revision: https://phabricator.services.mozilla.com/D8112
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_locale.js
browser/locales/en-US/browser/policies/policies-descriptions.ftl
--- a/browser/components/enterprisepolicies/Policies.jsm
+++ b/browser/components/enterprisepolicies/Policies.jsm
@@ -661,16 +661,22 @@ var Policies = {
         manager.disallowFeature("changeProxySettings");
         ProxyPolicies.configureProxySettings(param, setAndLockPref);
       } else {
         ProxyPolicies.configureProxySettings(param, setDefaultPref);
       }
     },
   },
 
+  "RequestedLocales": {
+    onBeforeAddons(manager, param) {
+      Services.locale.requestedLocales = param;
+    },
+  },
+
   "SanitizeOnShutdown": {
     onBeforeUIStartup(manager, param) {
       setAndLockPref("privacy.sanitize.sanitizeOnShutdown", param);
       if (param) {
         setAndLockPref("privacy.clearOnShutdown.cache", true);
         setAndLockPref("privacy.clearOnShutdown.cookies", true);
         setAndLockPref("privacy.clearOnShutdown.downloads", true);
         setAndLockPref("privacy.clearOnShutdown.formdata", true);
--- a/browser/components/enterprisepolicies/schemas/policies-schema.json
+++ b/browser/components/enterprisepolicies/schemas/policies-schema.json
@@ -581,16 +581,23 @@
         },
 
         "AutoLogin": {
           "type": "boolean"
         }
       }
     },
 
+    "RequestedLocales": {
+      "type": "array",
+      "items": {
+        "type": "string"
+      }
+    },
+
     "SanitizeOnShutdown": {
       "type": "boolean"
     },
 
     "SearchBar": {
       "type": "string",
       "enum": ["unified", "separate"]
     },
--- a/browser/components/enterprisepolicies/tests/browser/browser.ini
+++ b/browser/components/enterprisepolicies/tests/browser/browser.ini
@@ -44,15 +44,16 @@ skip-if = (verify && debug && (os == 'ma
 [browser_policy_disable_profile_reset.js]
 [browser_policy_disable_profile_import.js]
 [browser_policy_disable_safemode.js]
 [browser_policy_disable_shield.js]
 [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_search_engine.js]
 [browser_policy_searchbar.js]
 [browser_policy_set_homepage.js]
 [browser_policy_websitefilter.js]
new file mode 100644
--- /dev/null
+++ b/browser/components/enterprisepolicies/tests/browser/browser_policy_locale.js
@@ -0,0 +1,33 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const REQ_LOC_CHANGE_EVENT = "intl:requested-locales-changed";
+
+function promiseLocaleChanged() {
+  return new Promise(resolve => {
+    let localeObserver = {
+      observe(aSubject, aTopic, aData) {
+        switch (aTopic) {
+          case REQ_LOC_CHANGE_EVENT:
+            let reqLocs = Services.locale.requestedLocales;
+            is(reqLocs[0], "de");
+            Services.obs.removeObserver(localeObserver, REQ_LOC_CHANGE_EVENT);
+            resolve();
+        }
+      },
+    };
+    Services.obs.addObserver(localeObserver, REQ_LOC_CHANGE_EVENT);
+  });
+}
+
+add_task(async function test_requested_locale() {
+  let localePromise = promiseLocaleChanged();
+  await setupPolicyEngineWithJson({
+    "policies": {
+      "RequestedLocales": ["de"],
+    },
+  });
+  await localePromise;
+});
--- a/browser/locales/en-US/browser/policies/policies-descriptions.ftl
+++ b/browser/locales/en-US/browser/policies/policies-descriptions.ftl
@@ -101,16 +101,18 @@ policy-OverrideFirstRunPage = Override t
 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-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.
 
 policy-SearchEngines = Configure search engine settings. This policy is only available on the Extended Support Release (ESR) version.
 
 # For more information, see https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/PKCS11/Module_Installation
 policy-SecurityDevices = Install PKCS #11 modules.