bmo#542999 mozilla-1.9.2
authorWolfgang Rosenauer <wr@rosenauer.org>
Thu, 25 Feb 2010 23:18:44 +0100
branchmozilla-1.9.2
changeset 57 fee8a3636d4a
parent 56 6c1feeed3314
child 58 e0951c708771
bmo#542999
mozilla-crash-annotation.patch
mozilla-ua-locale-pref.patch
mozilla-xulrunner192/mozilla-ua-locale-pref.patch
mozilla-xulrunner192/mozilla-xulrunner192.changes
mozilla-xulrunner192/mozilla-xulrunner192.spec
series
--- a/mozilla-crash-annotation.patch	Fri Jan 22 10:35:06 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-From: Wolfgang Rosenauer <wr@rosenauer.org>
-Subject: add distribution information to crash reports when available
-References:
-
-diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp
---- a/toolkit/xre/nsAppRunner.cpp
-+++ b/toolkit/xre/nsAppRunner.cpp
-@@ -3299,26 +3299,47 @@ XRE_main(int argc, char* argv[], const n
-       rv |= xpcom.SetWindowCreator(nativeApp);
-       NS_ENSURE_SUCCESS(rv, 1);
- 
- #ifdef MOZ_CRASHREPORTER
-       // tell the crash reporter to also send the release channel
-       nsCOMPtr<nsIPrefService> prefs = do_GetService("@mozilla.org/preferences-service;1", &rv);
-       if (NS_SUCCEEDED(rv)) {
-         nsCOMPtr<nsIPrefBranch> defaultPrefBranch;
-+        nsCOMPtr<nsIPrefBranch> distPrefBranch;
-+        nsXPIDLCString sval;
-+
-         rv = prefs->GetDefaultBranch(nsnull, getter_AddRefs(defaultPrefBranch));
--
-         if (NS_SUCCEEDED(rv)) {
--          nsXPIDLCString sval;
-           rv = defaultPrefBranch->GetCharPref("app.update.channel", getter_Copies(sval));
-           if (NS_SUCCEEDED(rv)) {
-             CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ReleaseChannel"),
-                                                sval);
-           }
-         }
-+
-+        rv = prefs->GetBranch("distribution", getter_AddRefs(distPrefBranch));
-+        if (NS_SUCCEEDED(rv)) {
-+          rv = distPrefBranch->GetCharPref("id", getter_Copies(sval));
-+          if (NS_SUCCEEDED(rv)) {
-+            CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("Distributor"),
-+                                               sval);
-+          } else {
-+            printf("GetCharPref('id') failed \n");
-+          }
-+          rv = distPrefBranch->GetCharPref("version", getter_Copies(sval));
-+          if (NS_SUCCEEDED(rv)) {
-+            CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("Distributor_version"),
-+                                               sval);
-+          } else {
-+            printf("GetCharPref('version') failed \n");
-+          }
-+        } else {
-+printf("GetBranch('distribution') failed\n");
-+        }
-       }
- #endif
-       {
-         if (startOffline) {
-           nsCOMPtr<nsIIOService2> io (do_GetService("@mozilla.org/network/io-service;1"));
-           NS_ENSURE_TRUE(io, 1);
-           io->SetManageOfflineStatus(PR_FALSE);
-           io->SetOffline(PR_TRUE);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mozilla-ua-locale-pref.patch	Thu Feb 25 23:18:44 2010 +0100
@@ -0,0 +1,133 @@
+diff --git a/chrome/src/nsChromeRegistry.cpp b/chrome/src/nsChromeRegistry.cpp
+--- a/chrome/src/nsChromeRegistry.cpp
++++ b/chrome/src/nsChromeRegistry.cpp
+@@ -1267,20 +1267,21 @@ nsChromeRegistry::WrappersEnabled(nsIURI
+   return PL_DHASH_ENTRY_IS_LIVE(entry) &&
+          entry->flags & PackageEntry::XPCNATIVEWRAPPERS;
+ }
+ 
+ nsresult
+ nsChromeRegistry::SelectLocaleFromPref(nsIPrefBranch* prefs)
+ {
+   nsresult rv;
+-  PRBool matchOSLocale = PR_FALSE;
++  PRBool matchOSLocale = PR_FALSE, userLocaleOverride = PR_FALSE;
++  prefs->PrefHasUserValue(SELECTED_LOCALE_PREF, &userLocaleOverride);
+   rv = prefs->GetBoolPref(MATCH_OS_LOCALE_PREF, &matchOSLocale);
+ 
+-  if (NS_SUCCEEDED(rv) && matchOSLocale) {
++  if (NS_SUCCEEDED(rv) && matchOSLocale && !userLocaleOverride) {
+     // compute lang and region code only when needed!
+     nsCAutoString uiLocale;
+     rv = getUILangCountry(uiLocale);
+     if (NS_SUCCEEDED(rv))
+       mSelectedLocale = uiLocale;
+   }
+   else {
+     nsXPIDLCString provider;
+diff --git a/chrome/test/unit/test_bug519468.js b/chrome/test/unit/test_bug519468.js
+--- a/chrome/test/unit/test_bug519468.js
++++ b/chrome/test/unit/test_bug519468.js
+@@ -31,50 +31,90 @@
+  * decision by deleting the provisions above and replace them with the notice
+  * and other provisions required by the GPL or the LGPL. If you do not delete
+  * the provisions above, a recipient may use your version of this file under
+  * the terms of any one of the MPL, the GPL or the LGPL.
+  *
+  * ***** END LICENSE BLOCK *****
+  */
+ 
++function write_locale(stream, locale, package) {
++  var s = "locale " + package + " " + locale + " jar:" + locale + ".jar!";
++  s += "/locale/" + locale + "/" + package +"/\n";
++  stream.write(s, s.length);
++}
++
++var localeService = Cc["@mozilla.org/intl/nslocaleservice;1"]
++                    .getService(Ci.nsILocaleService);
++
++var systemLocale = localeService.getLocaleComponentForUserAgent();
++
++var locales;
++
++if (systemLocale == "en-US")
++  locales = [ "en-US", "fr-FR", "de-DE" ];
++else if (systemLocale == "fr-FR")
++  locales = [ "en-US", systemLocale, "de-DE" ];
++else
++  locales = [ "en-US", systemLocale, "fr-FR" ];
++
++var workingDir = Cc["@mozilla.org/file/directory_service;1"].
++                 getService(Ci.nsIProperties).get("TmpD", Ci.nsIFile);
++var manifest = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
++manifest.initWithFile(workingDir);
++manifest.append("test_bug519468.manifest");
++manifest.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0600);
++var stream = Cc["@mozilla.org/network/file-output-stream;1"].
++             createInstance(Ci.nsIFileOutputStream);
++stream.init(manifest, 0x04 | 0x08 | 0x20, 0600, 0); // write, create, truncate
++locales.slice(0,2).forEach(function(l) write_locale(stream, l, "testmatchos"));
++write_locale(stream, locales[2], "testnomatchos");
++stream.close();
++
+ var MANIFESTS = [
+-  do_get_file("data/test_bug519468.manifest")
++  manifest
+ ];
+ 
+ registerManifests(MANIFESTS);
+ 
+ var chromeReg = Cc["@mozilla.org/chrome/chrome-registry;1"]
+                 .getService(Ci.nsIXULChromeRegistry)
+                 .QueryInterface(Ci.nsIToolkitChromeRegistry);
+ 
+-var localeService = Cc["@mozilla.org/intl/nslocaleservice;1"]
+-                    .getService(Ci.nsILocaleService);
+-
+ var prefService = Cc["@mozilla.org/preferences-service;1"]
+                   .getService(Ci.nsIPrefService)
+                   .QueryInterface(Ci.nsIPrefBranch);
+ 
+ function test_locale(aTest) {
+   prefService.setBoolPref("intl.locale.matchOS", aTest.matchOS);
+-  prefService.setCharPref("general.useragent.locale", aTest.selected || "en-US");
++  if (aTest.selected)
++    prefService.setCharPref("general.useragent.locale", aTest.selected);
++  else
++    try {
++      prefService.clearUserPref("general.useragent.locale");
++    } catch(e) {}
+ 
+-  var selectedLocale = chromeReg.getSelectedLocale("testmatchos");
++  var selectedLocale = chromeReg.getSelectedLocale(aTest.package);
+   do_check_eq(selectedLocale, aTest.locale);
+ }
+ 
+ function run_test()
+ {
+-  var systemLocale = localeService.getLocaleComponentForUserAgent();
+-
+   var tests = [
+-    {matchOS: false, selected: null, locale: "en-US"},
+     {matchOS: true, selected: null, locale: systemLocale},
+-    {matchOS: true, selected: "fr-FR", locale: systemLocale},
+-    {matchOS: false, selected: "fr-FR", locale: "fr-FR"},
+-    {matchOS: true, selected: null, locale: systemLocale}
++    {matchOS: true, selected: locales[0], locale: locales[0]},
++    {matchOS: true, selected: locales[1], locale: locales[1]},
++    {matchOS: true, selected: locales[2], locale: locales[0]},
++    {matchOS: true, selected: null, locale: locales[2], package: "testnomatchos"},
++    {matchOS: false, selected: null, locale: locales[0]},
++    {matchOS: false, selected: locales[0], locale: locales[0]},
++    {matchOS: false, selected: locales[1], locale: locales[1]},
++    {matchOS: false, selected: locales[2], locale: locales[0]},
+   ];
+ 
+   for (var i = 0; i < tests.length; ++ i) {
+     var test = tests[i];
++    if (!test.package)
++      test.package = "testmatchos";
+     test_locale(test);
+   }
++  manifest.remove(false);
+ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mozilla-xulrunner192/mozilla-ua-locale-pref.patch	Thu Feb 25 23:18:44 2010 +0100
@@ -0,0 +1,1 @@
+../mozilla-ua-locale-pref.patch
\ No newline at end of file
--- a/mozilla-xulrunner192/mozilla-xulrunner192.changes	Fri Jan 22 10:35:06 2010 +0100
+++ b/mozilla-xulrunner192/mozilla-xulrunner192.changes	Thu Feb 25 23:18:44 2010 +0100
@@ -1,3 +1,9 @@
+-------------------------------------------------------------------
+Thu Feb 25 23:17:08 CET 2010 - wr@rosenauer.org
+
+- general.useragent.locale in profile overrides 
+  intl.locale.matchOS (bmo#542999)
+
 -------------------------------------------------------------------
 Mon Jan 18 09:28:56 CET 2010 - wr@rosenauer.org
 
--- a/mozilla-xulrunner192/mozilla-xulrunner192.spec	Fri Jan 22 10:35:06 2010 +0100
+++ b/mozilla-xulrunner192/mozilla-xulrunner192.spec	Thu Feb 25 23:18:44 2010 +0100
@@ -84,6 +84,7 @@
 # ---
 Patch14:        mozilla-breakpad-update.patch
 Patch15:        mozilla-milestone.patch
+Patch16:        mozilla-ua-locale-pref.patch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 Requires(post):  update-alternatives coreutils
 Requires(preun): update-alternatives coreutils
@@ -219,6 +220,7 @@
 %patch13 -p1
 %patch14 -p1
 %patch15 -p1
+%patch16 -p1  # bmo#542999
 
 %build
 %if %suse_version >= 1110
--- a/series	Fri Jan 22 10:35:06 2010 +0100
+++ b/series	Thu Feb 25 23:18:44 2010 +0100
@@ -13,8 +13,8 @@
 gecko-lockdown.patch
 toolkit-ui-lockdown.patch
 mozilla-breakpad-update.patch
+mozilla-ua-locale-pref.patch
 mozilla-milestone.patch
-mozilla-crash-annotation.patch
 
 # Firefox patches
 firefox-libxul-sdk.patch