Commit 742e0ce8 authored by Michael Kaply's avatar Michael Kaply
Browse files

Bug 1528068 - Allow RequestedLocales to be a string. r=Felipe

Differential Revision: https://phabricator.services.mozilla.com/D26819

--HG--
extra : moz-landing-system : lando
parent 3f3eb7a7
......@@ -779,7 +779,11 @@ var Policies = {
"RequestedLocales": {
onBeforeAddons(manager, param) {
Services.locale.requestedLocales = param;
if (Array.isArray(param)) {
Services.locale.requestedLocales = param;
} else {
Services.locale.requestedLocales = param.split(",");
}
},
},
......
......@@ -626,7 +626,7 @@
},
"RequestedLocales": {
"type": "array",
"type": ["string", "array"],
"items": {
"type": "string"
}
......
......@@ -5,14 +5,14 @@
const REQ_LOC_CHANGE_EVENT = "intl:requested-locales-changed";
function promiseLocaleChanged() {
function promiseLocaleChanged(requestedLocale) {
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");
is(reqLocs[0], requestedLocale);
Services.obs.removeObserver(localeObserver, REQ_LOC_CHANGE_EVENT);
resolve();
}
......@@ -22,9 +22,9 @@ function promiseLocaleChanged() {
});
}
add_task(async function test_requested_locale() {
add_task(async function test_requested_locale_array() {
let originalLocales = Services.locale.requestedLocales;
let localePromise = promiseLocaleChanged();
let localePromise = promiseLocaleChanged("de");
await setupPolicyEngineWithJson({
"policies": {
"RequestedLocales": ["de"],
......@@ -33,3 +33,15 @@ add_task(async function test_requested_locale() {
await localePromise;
Services.locale.requestedLocales = originalLocales;
});
add_task(async function test_requested_locale_string() {
let originalLocales = Services.locale.requestedLocales;
let localePromise = promiseLocaleChanged("fr");
await setupPolicyEngineWithJson({
"policies": {
"RequestedLocales": "fr",
},
});
await localePromise;
Services.locale.requestedLocales = originalLocales;
});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment