Bug 1271032 - Make getPref Unicode-aware. r=mkaply

This commit is contained in:
Masatoshi Kimura 2016-05-10 19:45:22 +09:00
parent 4e12ba331b
commit 4881494273
4 changed files with 10 additions and 0 deletions

View File

@ -114,6 +114,12 @@ function getPref(prefName) {
switch (prefBranch.getPrefType(prefName)) {
case prefBranch.PREF_STRING:
if (gIsUTF8) {
const nsISupportsString = Components.interfaces.nsISupportsString;
let string = Components.classes["@mozilla.org/supports-string;1"]
.createInstance(nsISupportsString);
return prefBranch.getComplexValue(prefName, nsISupportsString).data;
}
return prefBranch.getCharPref(prefName);
case prefBranch.PREF_INT:

View File

@ -2,4 +2,5 @@
// ©
lockPref("_test.string.ASCII", "ASCII");
lockPref("_test.string.non-ASCII", "日本語");
lockPref("_test.string.getPref", getPref("_test.string.non-ASCII"));
lockPref("_test.string.gIsUTF8", String(this.gIsUTF8));

View File

@ -2,4 +2,5 @@
lockPref("_test.string.ASCII", "UTF-8");
lockPref("_test.string.non-ASCII", "日本語");
lockPref("_test.string.getPref", getPref("_test.string.non-ASCII"));
lockPref("_test.string.gIsUTF8", String(this.gIsUTF8));

View File

@ -31,6 +31,7 @@ function run_test() {
prefs: {
"_test.string.ASCII": "UTF-8",
"_test.string.non-ASCII": "日本語",
"_test.string.getPref": "日本語",
"_test.string.gIsUTF8": "true"
}
}, {
@ -38,6 +39,7 @@ function run_test() {
prefs: {
"_test.string.ASCII": "ASCII",
"_test.string.non-ASCII": "日本語",
"_test.string.getPref": "日本語",
"_test.string.gIsUTF8": "false",
}
}];