Bug 1251289 - Fix chrome.i18n.getAcceptLanguages to *not* replace dashes with underscores in language codes. r=kmag
authorbsilverberg <bsilverberg@mozilla.com>
Thu, 25 Feb 2016 13:18:16 -0500
changeset 322168 b0b0257a6cbe7bc4328440bcfa9b843324b17550
parent 322167 0b3813f906c1fbe669a887801a7b59de87956e6c
child 322169 2f513fdef55943e338931c9ef2a0c46f4f9cbef9
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1251289
milestone47.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 1251289 - Fix chrome.i18n.getAcceptLanguages to *not* replace dashes with underscores in language codes. r=kmag MozReview-Commit-ID: 1plfVzxwq3V
toolkit/components/extensions/ExtensionUtils.jsm
toolkit/components/extensions/test/mochitest/test_ext_i18n.html
--- a/toolkit/components/extensions/ExtensionUtils.jsm
+++ b/toolkit/components/extensions/ExtensionUtils.jsm
@@ -428,21 +428,17 @@ LocaleData.prototype = {
     }
 
     this.messages.set(locale, result);
     return result;
   },
 
   get acceptLanguages() {
     let result = Preferences.get("intl.accept_languages", "", Ci.nsIPrefLocalizedString);
-    result = result.split(",");
-    result = result.map(lang => {
-      return lang.replace(/-/g, "_").trim();
-    });
-    return result;
+    return result.split(/\s*,\s*/g);
   },
 
 
   get uiLocale() {
     // Return the browser locale, but convert it to a Chrome-style
     // locale code.
     return Locale.getLocale().replace(/-/g, "_");
   },
--- a/toolkit/components/extensions/test/mochitest/test_ext_i18n.html
+++ b/toolkit/components/extensions/test/mochitest/test_ext_i18n.html
@@ -223,21 +223,21 @@ add_task(function* test_get_accept_langu
     },
   });
 
   let win = window.open("file_sample.html");
 
   yield extension.startup();
   yield extension.awaitMessage("ready");
 
-  let expectedLangs = ["en_US", "en"];
+  let expectedLangs = ["en-US", "en"];
   extension.sendMessage(["expect-results", expectedLangs]);
   yield extension.awaitMessage("done");
 
-  expectedLangs = ["en_US", "en", "fr_CA", "fr"];
+  expectedLangs = ["en-US", "en", "fr-CA", "fr"];
   SpecialPowers.setCharPref("intl.accept_languages", expectedLangs.toString());
   extension.sendMessage(["expect-results", expectedLangs]);
   yield extension.awaitMessage("done");
   SpecialPowers.clearUserPref("intl.accept_languages");
 
   win.close();
 
   yield extension.unload();