Bug 1410736 - Replace remaining uses of general.useragent.locale with LocaleService API. r=jfkthame

MozReview-Commit-ID: CmXBFcKxOkX

--HG--
extra : rebase_source : deeeee81fd187aa9ca4f26f9f5c69633ff405e34
This commit is contained in:
Zibi Braniecki 2017-11-02 14:11:41 -07:00
Родитель 576717207b
Коммит 5db1dc8a9d
18 изменённых файлов: 52 добавлений и 83 удалений

Просмотреть файл

@ -55,14 +55,12 @@ function asyncInit() {
} }
function asyncReInit() { function asyncReInit() {
const kLocalePref = "general.useragent.locale";
let promise = new Promise(resolve => { let promise = new Promise(resolve => {
waitForSearchNotification("reinit-complete", resolve); waitForSearchNotification("reinit-complete", resolve);
}); });
Services.search.QueryInterface(Ci.nsIObserver) Services.search.QueryInterface(Ci.nsIObserver)
.observe(null, "nsPref:changed", kLocalePref); .observe(null, "intl:requested-locales-changed", null);
return promise; return promise;
} }

Просмотреть файл

@ -55,14 +55,12 @@ function asyncInit() {
} }
function asyncReInit() { function asyncReInit() {
const kLocalePref = "general.useragent.locale";
let promise = new Promise(resolve => { let promise = new Promise(resolve => {
waitForSearchNotification("reinit-complete", resolve); waitForSearchNotification("reinit-complete", resolve);
}); });
Services.search.QueryInterface(Ci.nsIObserver) Services.search.QueryInterface(Ci.nsIObserver)
.observe(null, "nsPref:changed", kLocalePref); .observe(null, "intl:requested-locales-changed", null);
return promise; return promise;
} }

Просмотреть файл

@ -9,6 +9,7 @@ var MANIFESTS = [
// Stub in the locale service so we can control what gets returned as the OS locale setting // Stub in the locale service so we can control what gets returned as the OS locale setting
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
registerManifests(MANIFESTS); registerManifests(MANIFESTS);
@ -33,7 +34,7 @@ function enum_to_array(strings) {
function run_test() { function run_test() {
// without override // without override
prefService.setCharPref("general.useragent.locale", "de"); Services.locale.setRequestedLocales(["de"]);
do_check_eq(chromeReg.getSelectedLocale("basepack"), "en-US"); do_check_eq(chromeReg.getSelectedLocale("basepack"), "en-US");
do_check_eq(chromeReg.getSelectedLocale("overpack"), "de"); do_check_eq(chromeReg.getSelectedLocale("overpack"), "de");
do_check_matches(enum_to_array(chromeReg.getLocalesForPackage("basepack")), do_check_matches(enum_to_array(chromeReg.getLocalesForPackage("basepack")),

Просмотреть файл

@ -31,8 +31,10 @@ var gStringBundle;
W3CTest.runner.requestLongerTimeout(2); W3CTest.runner.requestLongerTimeout(2);
const { Services } = SpecialPowers.Cu.import("resource://gre/modules/Services.jsm");
Services.locale.setRequestedLocales(["en-US"]);
SpecialPowers.pushPrefEnv({ "set": [ SpecialPowers.pushPrefEnv({ "set": [
["general.useragent.locale", "en-US"],
// Need to set devPixelsPerPx explicitly to gain // Need to set devPixelsPerPx explicitly to gain
// consistent pixel values in warning messages // consistent pixel values in warning messages
// regardless of platform DPIs. // regardless of platform DPIs.

Просмотреть файл

@ -11,10 +11,11 @@ server.registerDirectory("/data/", do_get_file("data"));
const BASE_URL = `http://localhost:${server.identity.primaryPort}/data`; const BASE_URL = `http://localhost:${server.identity.primaryPort}/data`;
var originalReqLocales = Services.locale.getRequestedLocales();
do_register_cleanup(() => { do_register_cleanup(() => {
Preferences.reset("intl.accept_languages"); Preferences.reset("intl.accept_languages");
Preferences.reset("intl.locale.matchOS"); Services.locale.setRequestedLocales(originalReqLocales);
Preferences.reset("general.useragent.locale");
}); });
@ -218,9 +219,8 @@ add_task(async function test_i18n_negotiation() {
let contentPage = await ExtensionTestUtils.loadContentPage(`${BASE_URL}/file_sample.html`); let contentPage = await ExtensionTestUtils.loadContentPage(`${BASE_URL}/file_sample.html`);
Preferences.set("intl.locale.matchOS", false);
for (let [lang, msg] of [["en-US", "English."], ["jp", "\u65e5\u672c\u8a9e"]]) { for (let [lang, msg] of [["en-US", "English."], ["jp", "\u65e5\u672c\u8a9e"]]) {
Preferences.set("general.useragent.locale", lang); Services.locale.setRequestedLocales([lang]);
let extension = ExtensionTestUtils.loadExtension(extensionData); let extension = ExtensionTestUtils.loadExtension(extensionData);
await extension.startup(); await extension.startup();
@ -232,7 +232,7 @@ add_task(async function test_i18n_negotiation() {
await extension.unload(); await extension.unload();
} }
Preferences.reset("general.useragent.locale"); Services.locale.setRequestedLocales(originalReqLocales);
await contentPage.close(); await contentPage.close();
}); });
@ -377,7 +377,7 @@ add_task(async function test_get_ui_language() {
// We don't currently have a good way to mock this. // We don't currently have a good way to mock this.
if (false) { if (false) {
Preferences.set("general.useragent.locale", "he"); Services.locale.setRequestedLocales(["he"]);
extension.sendMessage(["expect-results", "he"]); extension.sendMessage(["expect-results", "he"]);

Просмотреть файл

@ -122,23 +122,20 @@ async function test_i18n_css(options = {}) {
// We don't currently have a good way to mock this. // We don't currently have a good way to mock this.
if (false) { if (false) {
const LOCALE = "general.useragent.locale";
const DIR = "intl.uidirection"; const DIR = "intl.uidirection";
const DIR_LEGACY = "intl.uidirection.en"; // Needed for Android until bug 1215247 is resolved
// We don't wind up actually switching the chrome registry locale, since we // We don't wind up actually switching the chrome registry locale, since we
// don't have a chrome package for Hebrew. So just override it, and force // don't have a chrome package for Hebrew. So just override it, and force
// RTL directionality. // RTL directionality.
Preferences.set(LOCALE, "he"); var origReqLocales = Services.locale.getRequestedLocales();
Services.locale.setRequestedLocales(["he"]);
Preferences.set(DIR, 1); Preferences.set(DIR, 1);
Preferences.set(DIR_LEGACY, "rtl");
css = await fetch(cssURL); css = await fetch(cssURL);
equal(css, '* { content: "he rtl ltr right left" }', "CSS file localized in mochitest scope"); equal(css, '* { content: "he rtl ltr right left" }', "CSS file localized in mochitest scope");
Preferences.reset(LOCALE); Services.locale.setRequestedLocales(origReqLocales);
Preferences.reset(DIR); Preferences.reset(DIR);
Preferences.reset(DIR_LEGACY);
} }
await extension.awaitFinish("i18n-css"); await extension.awaitFinish("i18n-css");

Просмотреть файл

@ -80,8 +80,7 @@ add_task(async function() {
do_print("Change locale to 'fr' and restart"); do_print("Change locale to 'fr' and restart");
Preferences.set("intl.locale.matchOS", false); Services.locale.setRequestedLocales(["fr"]);
Preferences.set("general.useragent.locale", "fr");
await AddonTestUtils.promiseRestartManager(); await AddonTestUtils.promiseRestartManager();
await extension.awaitStartup(); await extension.awaitStartup();
@ -99,7 +98,7 @@ add_task(async function() {
do_print("Change locale to 'en-US' and restart"); do_print("Change locale to 'en-US' and restart");
Preferences.set("general.useragent.locale", "en-US"); Services.locale.setRequestedLocales(["en-US"]);
await AddonTestUtils.promiseRestartManager(); await AddonTestUtils.promiseRestartManager();
await extension.awaitStartup(); await extension.awaitStartup();

Просмотреть файл

@ -74,14 +74,14 @@ add_task(function test_setup() {
Services.prefs.setCharPref("urlclassifier.downloadBlockTable", Services.prefs.setCharPref("urlclassifier.downloadBlockTable",
"goog-badbinurl-shavar"); "goog-badbinurl-shavar");
// SendRemoteQueryInternal needs locale preference. // SendRemoteQueryInternal needs locale preference.
let locale = Services.prefs.getCharPref("general.useragent.locale"); let originalReqLocales = Services.locale.getRequestedLocales();
Services.prefs.setCharPref("general.useragent.locale", "en-US"); Services.locale.setRequestedLocales(["en-US"]);
do_register_cleanup(function() { do_register_cleanup(function() {
Services.prefs.clearUserPref("browser.safebrowsing.malware.enabled"); Services.prefs.clearUserPref("browser.safebrowsing.malware.enabled");
Services.prefs.clearUserPref("browser.safebrowsing.downloads.enabled"); Services.prefs.clearUserPref("browser.safebrowsing.downloads.enabled");
Services.prefs.clearUserPref("urlclassifier.downloadBlockTable"); Services.prefs.clearUserPref("urlclassifier.downloadBlockTable");
Services.prefs.setCharPref("general.useragent.locale", locale); Services.locale.setRequestedLocales(originalReqLocales);
}); });
gHttpServer = new HttpServer(); gHttpServer = new HttpServer();

Просмотреть файл

@ -163,15 +163,15 @@ add_task(async function test_setup() {
Services.prefs.setCharPref("urlclassifier.downloadAllowTable", Services.prefs.setCharPref("urlclassifier.downloadAllowTable",
"goog-downloadwhite-digest256"); "goog-downloadwhite-digest256");
// SendRemoteQueryInternal needs locale preference. // SendRemoteQueryInternal needs locale preference.
let locale = Services.prefs.getCharPref("general.useragent.locale"); let originalReqLocales = Services.locale.getRequestedLocales();
Services.prefs.setCharPref("general.useragent.locale", "en-US"); Services.locale.setRequestedLocales(["en-US"]);
do_register_cleanup(function() { do_register_cleanup(function() {
Services.prefs.clearUserPref("browser.safebrowsing.malware.enabled"); Services.prefs.clearUserPref("browser.safebrowsing.malware.enabled");
Services.prefs.clearUserPref("browser.safebrowsing.downloads.enabled"); Services.prefs.clearUserPref("browser.safebrowsing.downloads.enabled");
Services.prefs.clearUserPref("urlclassifier.downloadBlockTable"); Services.prefs.clearUserPref("urlclassifier.downloadBlockTable");
Services.prefs.clearUserPref("urlclassifier.downloadAllowTable"); Services.prefs.clearUserPref("urlclassifier.downloadAllowTable");
Services.prefs.setCharPref("general.useragent.locale", locale); Services.locale.setRequestedLocales(originalReqLocales);
}); });
gHttpServer = new HttpServer(); gHttpServer = new HttpServer();

Просмотреть файл

@ -67,6 +67,7 @@ const APP_SEARCH_PREFIX = "resource://search-plugins/";
// See documentation in nsIBrowserSearchService.idl. // See documentation in nsIBrowserSearchService.idl.
const SEARCH_ENGINE_TOPIC = "browser-search-engine-modified"; const SEARCH_ENGINE_TOPIC = "browser-search-engine-modified";
const REQ_LOCALES_CHANGED_TOPIC = "intl:requested-locales-changed";
const QUIT_APPLICATION_TOPIC = "quit-application"; const QUIT_APPLICATION_TOPIC = "quit-application";
const SEARCH_ENGINE_REMOVED = "engine-removed"; const SEARCH_ENGINE_REMOVED = "engine-removed";
@ -137,7 +138,6 @@ const URLTYPE_SEARCH_HTML = "text/html";
const URLTYPE_OPENSEARCH = "application/opensearchdescription+xml"; const URLTYPE_OPENSEARCH = "application/opensearchdescription+xml";
const BROWSER_SEARCH_PREF = "browser.search."; const BROWSER_SEARCH_PREF = "browser.search.";
const LOCALE_PREF = "general.useragent.locale";
const USER_DEFINED = "searchTerms"; const USER_DEFINED = "searchTerms";
@ -2290,7 +2290,7 @@ Engine.prototype = {
// we'll accept as a 'default' engine anything that has been registered at // we'll accept as a 'default' engine anything that has been registered at
// resource://search-plugins/ even if the file doesn't come from the // resource://search-plugins/ even if the file doesn't come from the
// application folder. If not, skip costly additional checks. // application folder. If not, skip costly additional checks.
if (!Services.prefs.prefHasUserValue(LOCALE_PREF) && if (Services.locale.defaultLocale !== Services.locale.getRequestedLocale() &&
!gEnvironment.get("XPCSHELL_TEST_PROFILE_DIR")) !gEnvironment.get("XPCSHELL_TEST_PROFILE_DIR"))
return false; return false;
@ -4666,13 +4666,11 @@ SearchService.prototype = {
this._removeObservers(); this._removeObservers();
break; break;
case "nsPref:changed": case REQ_LOCALES_CHANGED_TOPIC:
if (aVerb == LOCALE_PREF) { // Locale changed. Re-init. We rely on observers, because we can't
// Locale changed. Re-init. We rely on observers, because we can't // return this promise to anyone.
// return this promise to anyone. this._asyncReInit();
this._asyncReInit(); break;
break;
}
} }
}, },
@ -4727,7 +4725,7 @@ SearchService.prototype = {
Services.obs.addObserver(this, QUIT_APPLICATION_TOPIC); Services.obs.addObserver(this, QUIT_APPLICATION_TOPIC);
if (AppConstants.MOZ_BUILD_APP == "mobile/android") { if (AppConstants.MOZ_BUILD_APP == "mobile/android") {
Services.prefs.addObserver(LOCALE_PREF, this); Services.obs.addObserver(this, REQ_LOCALES_CHANGED_TOPIC);
} }
// The current stage of shutdown. Used to help analyze crash // The current stage of shutdown. Used to help analyze crash
@ -4772,7 +4770,7 @@ SearchService.prototype = {
Services.obs.removeObserver(this, QUIT_APPLICATION_TOPIC); Services.obs.removeObserver(this, QUIT_APPLICATION_TOPIC);
if (AppConstants.MOZ_BUILD_APP == "mobile/android") { if (AppConstants.MOZ_BUILD_APP == "mobile/android") {
Services.prefs.removeObserver(LOCALE_PREF, this); Services.obs.removeObserver(this, REQ_LOCALES_CHANGED_TOPIC);
} }
}, },

Просмотреть файл

@ -254,14 +254,14 @@ function isUSTimezone() {
const kDefaultenginenamePref = "browser.search.defaultenginename"; const kDefaultenginenamePref = "browser.search.defaultenginename";
const kTestEngineName = "Test search engine"; const kTestEngineName = "Test search engine";
const kLocalePref = "general.useragent.locale"; const REQ_LOCALES_CHANGED_TOPIC = "intl:requested-locales-changed";
function getDefaultEngineName(isUS) { function getDefaultEngineName(isUS) {
const nsIPLS = Ci.nsIPrefLocalizedString; const nsIPLS = Ci.nsIPrefLocalizedString;
// Copy the logic from nsSearchService // Copy the logic from nsSearchService
let pref = kDefaultenginenamePref; let pref = kDefaultenginenamePref;
if (isUS === undefined) if (isUS === undefined)
isUS = Services.prefs.getCharPref(kLocalePref) == "en-US" && isUSTimezone(); isUS = Services.locale.getRequestedLocale() == "en-US" && isUSTimezone();
if (isUS) { if (isUS) {
pref += ".US"; pref += ".US";
} }
@ -509,7 +509,7 @@ function asyncReInit() {
let promise = waitForSearchNotification("reinit-complete"); let promise = waitForSearchNotification("reinit-complete");
Services.search.QueryInterface(Ci.nsIObserver) Services.search.QueryInterface(Ci.nsIObserver)
.observe(null, "nsPref:changed", kLocalePref); .observe(null, REQ_LOCALES_CHANGED_TOPIC, null);
return promise; return promise;
} }

Просмотреть файл

@ -3,9 +3,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/ */
const PREF_MATCH_OS_LOCALE = "intl.locale.matchOS";
const PREF_SELECTED_LOCALE = "general.useragent.locale";
// Disables security checking our updates which haven't been signed // Disables security checking our updates which haven't been signed
Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false); Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
@ -160,8 +157,7 @@ function run_test() {
server.registerPathHandler("/3", requestHandler); server.registerPathHandler("/3", requestHandler);
server.start(4444); server.start(4444);
Services.prefs.setBoolPref(PREF_MATCH_OS_LOCALE, false); Services.locale.setRequestedLocales(["en-US"]);
Services.prefs.setCharPref(PREF_SELECTED_LOCALE, "en-US");
startupManager(); startupManager();
installAllFiles(ADDONS.map(a => do_get_addon(a.addon)), function() { installAllFiles(ADDONS.map(a => do_get_addon(a.addon)), function() {

Просмотреть файл

@ -3,9 +3,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/ */
const PREF_MATCH_OS_LOCALE = "intl.locale.matchOS";
const PREF_SELECTED_LOCALE = "general.useragent.locale";
const ADDON = "test_bug397778"; const ADDON = "test_bug397778";
const ID = "bug397778@tests.mozilla.org"; const ID = "bug397778@tests.mozilla.org";
@ -13,8 +10,7 @@ function run_test() {
// Setup for test // Setup for test
do_test_pending(); do_test_pending();
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1"); createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1");
Services.prefs.setBoolPref(PREF_MATCH_OS_LOCALE, false); Services.locale.setRequestedLocales(["fr-FR"]);
Services.prefs.setCharPref(PREF_SELECTED_LOCALE, "fr-FR");
// Install test add-on // Install test add-on
startupManager(); startupManager();
@ -46,7 +42,7 @@ function run_test_1() {
function run_test_2() { function run_test_2() {
// Change locale. The more specific de-DE is the best match // Change locale. The more specific de-DE is the best match
Services.prefs.setCharPref(PREF_SELECTED_LOCALE, "de"); Services.locale.setRequestedLocales(["de"]);
restartManager(); restartManager();
AddonManager.getAddonByID(ID, function(addon) { AddonManager.getAddonByID(ID, function(addon) {
@ -60,7 +56,7 @@ function run_test_2() {
function run_test_3() { function run_test_3() {
// Change locale. Locale case should have no effect // Change locale. Locale case should have no effect
Services.prefs.setCharPref(PREF_SELECTED_LOCALE, "DE-de"); Services.locale.setRequestedLocales(["DE-de"]);
restartManager(); restartManager();
AddonManager.getAddonByID(ID, function(addon) { AddonManager.getAddonByID(ID, function(addon) {
@ -74,7 +70,7 @@ function run_test_3() {
function run_test_4() { function run_test_4() {
// Change locale. es-ES should closely match // Change locale. es-ES should closely match
Services.prefs.setCharPref(PREF_SELECTED_LOCALE, "es-AR"); Services.locale.setRequestedLocales(["es-AR"]);
restartManager(); restartManager();
AddonManager.getAddonByID(ID, function(addon) { AddonManager.getAddonByID(ID, function(addon) {
@ -88,7 +84,7 @@ function run_test_4() {
function run_test_5() { function run_test_5() {
// Change locale. Either zh-CN or zh-TW could match // Change locale. Either zh-CN or zh-TW could match
Services.prefs.setCharPref(PREF_SELECTED_LOCALE, "zh"); Services.locale.setRequestedLocales(["zh"]);
restartManager(); restartManager();
AddonManager.getAddonByID(ID, function(addon) { AddonManager.getAddonByID(ID, function(addon) {
@ -103,7 +99,7 @@ function run_test_5() {
function run_test_6() { function run_test_6() {
// Unknown locale should try to match against en-US as well. Of en,en-GB // Unknown locale should try to match against en-US as well. Of en,en-GB
// en should match as being less specific // en should match as being less specific
Services.prefs.setCharPref(PREF_SELECTED_LOCALE, "nl-NL"); Services.locale.setRequestedLocales(["nl-NL"]);
restartManager(); restartManager();
AddonManager.getAddonByID(ID, function(addon) { AddonManager.getAddonByID(ID, function(addon) {

Просмотреть файл

@ -9,7 +9,6 @@ const PREF_BLOCKLIST_ENABLED = "extensions.blocklist.enabled";
const PREF_APP_DISTRIBUTION = "distribution.id"; const PREF_APP_DISTRIBUTION = "distribution.id";
const PREF_APP_DISTRIBUTION_VERSION = "distribution.version"; const PREF_APP_DISTRIBUTION_VERSION = "distribution.version";
const PREF_APP_UPDATE_CHANNEL = "app.update.channel"; const PREF_APP_UPDATE_CHANNEL = "app.update.channel";
const PREF_GENERAL_USERAGENT_LOCALE = "general.useragent.locale";
const CATEGORY_UPDATE_TIMER = "update-timer"; const CATEGORY_UPDATE_TIMER = "update-timer";
// Get the HTTP server. // Get the HTTP server.
@ -121,7 +120,7 @@ function run_test() {
defaults.setCharPref(PREF_APP_UPDATE_CHANNEL, "updatechannel"); defaults.setCharPref(PREF_APP_UPDATE_CHANNEL, "updatechannel");
defaults.setCharPref(PREF_APP_DISTRIBUTION, "distribution"); defaults.setCharPref(PREF_APP_DISTRIBUTION, "distribution");
defaults.setCharPref(PREF_APP_DISTRIBUTION_VERSION, "distribution-version"); defaults.setCharPref(PREF_APP_DISTRIBUTION_VERSION, "distribution-version");
defaults.setCharPref(PREF_GENERAL_USERAGENT_LOCALE, "locale"); Services.locale.setRequestedLocales(["locale"]);
// This should correctly escape everything // This should correctly escape everything
Services.prefs.setCharPref(PREF_BLOCKLIST_URL, "http://localhost:" + gPort + "/2?" + Services.prefs.setCharPref(PREF_BLOCKLIST_URL, "http://localhost:" + gPort + "/2?" +

Просмотреть файл

@ -2,19 +2,12 @@
* http://creativecommons.org/publicdomain/zero/1.0/ * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
// This verifies that localized properties work as expected
const PREF_MATCH_OS_LOCALE = "intl.locale.matchOS";
const PREF_SELECTED_LOCALE = "general.useragent.locale";
function run_test() { function run_test() {
do_test_pending(); do_test_pending();
// Setup for test // Setup for test
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
Services.prefs.setBoolPref(PREF_MATCH_OS_LOCALE, false); Services.locale.setRequestedLocales(["fr-FR"]);
Services.prefs.setCharPref(PREF_SELECTED_LOCALE, "fr-FR");
startupManager(); startupManager();
@ -88,7 +81,7 @@ function run_test_4() {
// Test that changing locale works // Test that changing locale works
function run_test_5() { function run_test_5() {
Services.prefs.setCharPref(PREF_SELECTED_LOCALE, "de-DE"); Services.locale.setRequestedLocales(["de-DE"]);
restartManager(); restartManager();
AddonManager.getAddonByID("addon1@tests.mozilla.org", function(addon) { AddonManager.getAddonByID("addon1@tests.mozilla.org", function(addon) {
@ -103,7 +96,7 @@ function run_test_5() {
// Test that missing locales use the fallbacks // Test that missing locales use the fallbacks
function run_test_6() { function run_test_6() {
Services.prefs.setCharPref(PREF_SELECTED_LOCALE, "nl-NL"); Services.locale.setRequestedLocales(["nl-NL"]);
restartManager(); restartManager();
AddonManager.getAddonByID("addon1@tests.mozilla.org", callback_soon(function(addon) { AddonManager.getAddonByID("addon1@tests.mozilla.org", callback_soon(function(addon) {
@ -132,7 +125,7 @@ function run_test_7() {
// Test that the prefs will override localized values from the manifest // Test that the prefs will override localized values from the manifest
function run_test_8() { function run_test_8() {
Services.prefs.setCharPref(PREF_SELECTED_LOCALE, "fr-FR"); Services.locale.setRequestedLocales(["fr-FR"]);
restartManager(); restartManager();
AddonManager.getAddonByID("addon1@tests.mozilla.org", function(addon) { AddonManager.getAddonByID("addon1@tests.mozilla.org", function(addon) {

Просмотреть файл

@ -4,8 +4,6 @@
// This verifies that add-on update checks work // This verifies that add-on update checks work
const PREF_MATCH_OS_LOCALE = "intl.locale.matchOS";
const PREF_SELECTED_LOCALE = "general.useragent.locale";
const PREF_GETADDONS_CACHE_ENABLED = "extensions.getAddons.cache.enabled"; const PREF_GETADDONS_CACHE_ENABLED = "extensions.getAddons.cache.enabled";
// The test extension uses an insecure update url. // The test extension uses an insecure update url.
@ -38,8 +36,7 @@ var originalSyncGUID;
function run_test() { function run_test() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1"); createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
Services.prefs.setBoolPref(PREF_MATCH_OS_LOCALE, false); Services.locale.setRequestedLocales(["fr-FR"]);
Services.prefs.setCharPref(PREF_SELECTED_LOCALE, "fr-FR");
run_next_test(); run_next_test();
} }

Просмотреть файл

@ -4,8 +4,6 @@
// This verifies that add-on update checks work // This verifies that add-on update checks work
const PREF_MATCH_OS_LOCALE = "intl.locale.matchOS";
const PREF_SELECTED_LOCALE = "general.useragent.locale";
const PREF_GETADDONS_CACHE_ENABLED = "extensions.getAddons.cache.enabled"; const PREF_GETADDONS_CACHE_ENABLED = "extensions.getAddons.cache.enabled";
// The test extension uses an insecure update url. // The test extension uses an insecure update url.
@ -36,8 +34,7 @@ profileDir.append("extensions");
function run_test() { function run_test() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1"); createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
Services.prefs.setBoolPref(PREF_MATCH_OS_LOCALE, false); Services.locale.setRequestedLocales(["fr-FR"]);
Services.prefs.setCharPref(PREF_SELECTED_LOCALE, "fr-FR");
run_next_test(); run_next_test();
} }

Просмотреть файл

@ -6,8 +6,6 @@ Components.utils.import("resource://gre/modules/AppConstants.jsm");
const ID = "webextension1@tests.mozilla.org"; const ID = "webextension1@tests.mozilla.org";
const PREF_SELECTED_LOCALE = "general.useragent.locale";
const profileDir = gProfD.clone(); const profileDir = gProfD.clone();
profileDir.append("extensions"); profileDir.append("extensions");
@ -148,7 +146,7 @@ add_task(async function test_manifest_localization() {
equal(addon.name, "Web Extensiøn foo ☹"); equal(addon.name, "Web Extensiøn foo ☹");
equal(addon.description, "Descriptïon bar ☹ of add-on"); equal(addon.description, "Descriptïon bar ☹ of add-on");
Services.prefs.setCharPref(PREF_SELECTED_LOCALE, "fr-FR"); Services.locale.setRequestedLocales(["fr-FR"]);
await promiseRestartManager(); await promiseRestartManager();
addon = await promiseAddonByID(extensionId); addon = await promiseAddonByID(extensionId);
@ -156,7 +154,7 @@ add_task(async function test_manifest_localization() {
equal(addon.name, "Web Extensiøn le foo ☺"); equal(addon.name, "Web Extensiøn le foo ☺");
equal(addon.description, "Descriptïon le bar ☺ of add-on"); equal(addon.description, "Descriptïon le bar ☺ of add-on");
Services.prefs.setCharPref(PREF_SELECTED_LOCALE, "de"); Services.locale.setRequestedLocales(["de"]);
await promiseRestartManager(); await promiseRestartManager();
addon = await promiseAddonByID(extensionId); addon = await promiseAddonByID(extensionId);