зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1284166 - <setting>s do not properly handle non-ASCII characters. r=kmag
This commit is contained in:
Родитель
557bc92405
Коммит
b013f58f80
|
@ -25,6 +25,8 @@ XPCOMUtils.defineLazyGetter(window, "gChromeWin", function() {
|
|||
.getInterface(Ci.nsIDOMWindow)
|
||||
.QueryInterface(Ci.nsIDOMChromeWindow);
|
||||
});
|
||||
XPCOMUtils.defineLazyModuleGetter(window, "Preferences",
|
||||
"resource://gre/modules/Preferences.jsm");
|
||||
|
||||
var ContextMenus = {
|
||||
target: null,
|
||||
|
|
|
@ -259,10 +259,6 @@ select {
|
|||
|
||||
/* XBL bindings */
|
||||
|
||||
settings {
|
||||
-moz-binding: url("chrome://mozapps/content/extensions/setting.xml#settings");
|
||||
}
|
||||
|
||||
setting {
|
||||
display: none;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,8 @@ const SIGNING_REQUIRED = CONSTANTS.REQUIRE_SIGNING ?
|
|||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
|
||||
"resource://gre/modules/PluralForm.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Preferences",
|
||||
"resource://gre/modules/Preferences.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Experiments",
|
||||
"resource:///modules/experiments/Experiments.jsm");
|
||||
|
|
|
@ -15,13 +15,6 @@
|
|||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<binding id="settings">
|
||||
<content orient="vertical">
|
||||
<xul:label class="settings-title" xbl:inherits="xbl:text=label" flex="1"/>
|
||||
<children/>
|
||||
</content>
|
||||
</binding>
|
||||
|
||||
<binding id="setting-base">
|
||||
<implementation>
|
||||
<constructor><![CDATA[
|
||||
|
@ -299,8 +292,7 @@
|
|||
<method name="valueFromPreference">
|
||||
<body>
|
||||
<![CDATA[
|
||||
const nsISupportsString = Components.interfaces.nsISupportsString;
|
||||
this.value = Services.prefs.getComplexValue(this.pref, nsISupportsString).data;
|
||||
this.value = Preferences.get(this.pref, "");
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
@ -308,10 +300,7 @@
|
|||
<method name="valueToPreference">
|
||||
<body>
|
||||
<![CDATA[
|
||||
const nsISupportsString = Components.interfaces.nsISupportsString;
|
||||
let iss = Components.classes["@mozilla.org/supports-string;1"].createInstance(nsISupportsString);
|
||||
iss.data = this.value;
|
||||
Services.prefs.setComplexValue(this.pref, nsISupportsString, iss);
|
||||
Preferences.set(this.pref, this.value);
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
@ -397,7 +386,7 @@
|
|||
<method name="valueFromPreference">
|
||||
<body>
|
||||
<![CDATA[
|
||||
this.value = Services.prefs.getCharPref(this.pref);
|
||||
this.value = Preferences.get(this.pref, "");
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
@ -405,7 +394,7 @@
|
|||
<method name="valueToPreference">
|
||||
<body>
|
||||
<![CDATA[
|
||||
Services.prefs.setCharPref(this.pref, this.value);
|
||||
Preferences.set(this.pref, this.value);
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
@ -460,20 +449,7 @@
|
|||
<method name="valueFromPreference">
|
||||
<body>
|
||||
<![CDATA[
|
||||
let val;
|
||||
switch (Services.prefs.getPrefType(this.pref)) {
|
||||
case Ci.nsIPrefBranch.PREF_STRING:
|
||||
val = Services.prefs.getCharPref(this.pref);
|
||||
break;
|
||||
case Ci.nsIPrefBranch.PREF_INT:
|
||||
val = Services.prefs.getIntPref(this.pref);
|
||||
break;
|
||||
case Ci.nsIPrefBranch.PREF_BOOL:
|
||||
val = Services.prefs.getBoolPref(this.pref).toString();
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
let val = Preferences.get(this.pref, "").toString();
|
||||
|
||||
if ("itemCount" in this.control) {
|
||||
for (let i = 0; i < this.control.itemCount; i++) {
|
||||
|
@ -494,12 +470,12 @@
|
|||
<![CDATA[
|
||||
// We might not have a pref already set, so we guess the type from the value attribute
|
||||
let val = this.control.selectedItem.value;
|
||||
if (val == "true" || val == "false")
|
||||
Services.prefs.setBoolPref(this.pref, val == "true");
|
||||
else if (/^-?\d+$/.test(val))
|
||||
Services.prefs.setIntPref(this.pref, val);
|
||||
else
|
||||
Services.prefs.setCharPref(this.pref, val);
|
||||
if (val == "true" || val == "false") {
|
||||
val = val == "true";
|
||||
} else if (/^-?\d+$/.test(val)) {
|
||||
val = parseInt(val, 10);
|
||||
}
|
||||
Preferences.set(this.pref, val);
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
|
||||
// Tests various aspects of the details view
|
||||
Components.utils.import("resource://gre/modules/Preferences.jsm");
|
||||
|
||||
var gManagerWindow;
|
||||
var gCategoryUtilities;
|
||||
|
@ -249,10 +250,11 @@ add_test(function() {
|
|||
EventUtils.synthesizeKey("a", {}, gManagerWindow);
|
||||
EventUtils.synthesizeKey("r", {}, gManagerWindow);
|
||||
is(input.value, "bar", "Text box should have updated value");
|
||||
input.value += "\u03DE"; // Cheat to add this non-ASCII character without typing it.
|
||||
EventUtils.synthesizeKey("/", {}, gManagerWindow);
|
||||
is(input.value, "bar/", "Text box should have updated value");
|
||||
is(input.value, "bar\u03DE/", "Text box should have updated value");
|
||||
is(gManagerWindow.document.getBindingParent(gManagerWindow.document.activeElement), input, "Search box should not have focus");
|
||||
is(Services.prefs.getCharPref("extensions.inlinesettings1.string"), "bar/", "String pref should have been updated");
|
||||
is(Preferences.get("extensions.inlinesettings1.string", "wrong"), "bar\u03DE/", "String pref should have been updated");
|
||||
|
||||
ok(!settings[4].hasAttribute("first-row"), "Not the first row");
|
||||
input = settings[4].firstElementChild;
|
||||
|
@ -282,24 +284,25 @@ add_test(function() {
|
|||
is(input.value, "", "Label value should be empty");
|
||||
is(input.tooltipText, "", "Label tooltip should be empty");
|
||||
|
||||
var profD = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
var testFile = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
testFile.append("\u2622");
|
||||
var curProcD = Services.dirsvc.get("CurProcD", Ci.nsIFile);
|
||||
|
||||
MockFilePicker.returnFiles = [profD];
|
||||
MockFilePicker.returnFiles = [testFile];
|
||||
MockFilePicker.returnValue = Ci.nsIFilePicker.returnOK;
|
||||
EventUtils.synthesizeMouseAtCenter(button, { clickCount: 1 }, gManagerWindow);
|
||||
is(MockFilePicker.mode, Ci.nsIFilePicker.modeOpen, "File picker mode should be open file");
|
||||
is(input.value, profD.path, "Label value should match file chosen");
|
||||
is(input.tooltipText, profD.path, "Label tooltip should match file chosen");
|
||||
is(Services.prefs.getCharPref("extensions.inlinesettings1.file"), profD.path, "File pref should match file chosen");
|
||||
is(input.value, testFile.path, "Label value should match file chosen");
|
||||
is(input.tooltipText, testFile.path, "Label tooltip should match file chosen");
|
||||
is(Preferences.get("extensions.inlinesettings1.file", "wrong"), testFile.path, "File pref should match file chosen");
|
||||
|
||||
MockFilePicker.returnFiles = [curProcD];
|
||||
MockFilePicker.returnValue = Ci.nsIFilePicker.returnCancel;
|
||||
EventUtils.synthesizeMouseAtCenter(button, { clickCount: 1 }, gManagerWindow);
|
||||
is(MockFilePicker.mode, Ci.nsIFilePicker.modeOpen, "File picker mode should be open file");
|
||||
is(input.value, profD.path, "Label value should not have changed");
|
||||
is(input.tooltipText, profD.path, "Label tooltip should not have changed");
|
||||
is(Services.prefs.getCharPref("extensions.inlinesettings1.file"), profD.path, "File pref should not have changed");
|
||||
is(input.value, testFile.path, "Label value should not have changed");
|
||||
is(input.tooltipText, testFile.path, "Label tooltip should not have changed");
|
||||
is(Preferences.get("extensions.inlinesettings1.file", "wrong"), testFile.path, "File pref should not have changed");
|
||||
|
||||
ok(!settings[7].hasAttribute("first-row"), "Not the first row");
|
||||
button = gManagerWindow.document.getAnonymousElementByAttribute(settings[7], "anonid", "button");
|
||||
|
@ -307,21 +310,21 @@ add_test(function() {
|
|||
is(input.value, "", "Label value should be empty");
|
||||
is(input.tooltipText, "", "Label tooltip should be empty");
|
||||
|
||||
MockFilePicker.returnFiles = [profD];
|
||||
MockFilePicker.returnFiles = [testFile];
|
||||
MockFilePicker.returnValue = Ci.nsIFilePicker.returnOK;
|
||||
EventUtils.synthesizeMouseAtCenter(button, { clickCount: 1 }, gManagerWindow);
|
||||
is(MockFilePicker.mode, Ci.nsIFilePicker.modeGetFolder, "File picker mode should be directory");
|
||||
is(input.value, profD.path, "Label value should match file chosen");
|
||||
is(input.tooltipText, profD.path, "Label tooltip should match file chosen");
|
||||
is(Services.prefs.getCharPref("extensions.inlinesettings1.directory"), profD.path, "Directory pref should match file chosen");
|
||||
is(input.value, testFile.path, "Label value should match file chosen");
|
||||
is(input.tooltipText, testFile.path, "Label tooltip should match file chosen");
|
||||
is(Preferences.get("extensions.inlinesettings1.directory", "wrong"), testFile.path, "Directory pref should match file chosen");
|
||||
|
||||
MockFilePicker.returnFiles = [curProcD];
|
||||
MockFilePicker.returnValue = Ci.nsIFilePicker.returnCancel;
|
||||
EventUtils.synthesizeMouseAtCenter(button, { clickCount: 1 }, gManagerWindow);
|
||||
is(MockFilePicker.mode, Ci.nsIFilePicker.modeGetFolder, "File picker mode should be directory");
|
||||
is(input.value, profD.path, "Label value should not have changed");
|
||||
is(input.tooltipText, profD.path, "Label tooltip should not have changed");
|
||||
is(Services.prefs.getCharPref("extensions.inlinesettings1.directory"), profD.path, "Directory pref should not have changed");
|
||||
is(input.value, testFile.path, "Label value should not have changed");
|
||||
is(input.tooltipText, testFile.path, "Label tooltip should not have changed");
|
||||
is(Preferences.get("extensions.inlinesettings1.directory", "wrong"), testFile.path, "Directory pref should not have changed");
|
||||
|
||||
var unsizedInput = gManagerWindow.document.getAnonymousElementByAttribute(settings[2], "anonid", "input");
|
||||
var sizedInput = gManagerWindow.document.getAnonymousElementByAttribute(settings[8], "anonid", "input");
|
||||
|
@ -380,9 +383,9 @@ add_test(function() {
|
|||
is(radios[1].selected, true, "Correct radio button should be selected");
|
||||
isnot(radios[2].selected, true, "Correct radio button should be selected");
|
||||
EventUtils.synthesizeMouseAtCenter(radios[0], { clickCount: 1 }, gManagerWindow);
|
||||
is(Services.prefs.getCharPref("extensions.inlinesettings3.radioString"), "india", "Radio pref should have been updated");
|
||||
is(Preferences.get("extensions.inlinesettings3.radioString", "wrong"), "india", "Radio pref should have been updated");
|
||||
EventUtils.synthesizeMouseAtCenter(radios[2], { clickCount: 1 }, gManagerWindow);
|
||||
is(Services.prefs.getCharPref("extensions.inlinesettings3.radioString"), "kilo", "Radio pref should have been updated");
|
||||
is(Preferences.get("extensions.inlinesettings3.radioString", "wrong"), "kilo \u338F", "Radio pref should have been updated");
|
||||
|
||||
ok(!settings[3].hasAttribute("first-row"), "Not the first row");
|
||||
Services.prefs.setIntPref("extensions.inlinesettings3.menulist", 8);
|
||||
|
@ -588,7 +591,7 @@ add_test(function() {
|
|||
Services.prefs.setBoolPref("extensions.inlinesettings1.bool", false);
|
||||
Services.prefs.setIntPref("extensions.inlinesettings1.boolint", 1);
|
||||
Services.prefs.setIntPref("extensions.inlinesettings1.integer", 12);
|
||||
Services.prefs.setCharPref("extensions.inlinesettings1.string", "bar/");
|
||||
Preferences.set("extensions.inlinesettings1.string", "bar\u03DE/");
|
||||
Services.prefs.setCharPref("extensions.inlinesettings1.color", "#FF9900");
|
||||
Services.prefs.setCharPref("extensions.inlinesettings1.file", profD.path);
|
||||
Services.prefs.setCharPref("extensions.inlinesettings1.directory", profD.path);
|
||||
|
@ -615,7 +618,7 @@ add_test(function() {
|
|||
is(input.value, "12", "Number box should have initial value");
|
||||
|
||||
input = gManagerWindow.document.getAnonymousElementByAttribute(settings[3], "anonid", "input");
|
||||
is(input.value, "bar/", "Text box should have initial value");
|
||||
is(input.value, "bar\u03DE/", "Text box should have initial value");
|
||||
|
||||
input = gManagerWindow.document.getAnonymousElementByAttribute(settings[5], "anonid", "input");
|
||||
is(input.color, "#FF9900", "Color picker should have initial value");
|
||||
|
@ -640,7 +643,7 @@ add_test(function() {
|
|||
// change the tests above.
|
||||
Services.prefs.setBoolPref("extensions.inlinesettings3.radioBool", false);
|
||||
Services.prefs.setIntPref("extensions.inlinesettings3.radioInt", 6);
|
||||
Services.prefs.setCharPref("extensions.inlinesettings3.radioString", "kilo");
|
||||
Preferences.set("extensions.inlinesettings3.radioString", "kilo \u338F");
|
||||
Services.prefs.setIntPref("extensions.inlinesettings3.menulist", 9);
|
||||
|
||||
var addon = get_addon_element(gManagerWindow, "inlinesettings3@tests.mozilla.org");
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
|
||||
// Tests various aspects of the details view
|
||||
Components.utils.import("resource://gre/modules/Preferences.jsm");
|
||||
|
||||
var gManagerWindow;
|
||||
var gCategoryUtilities;
|
||||
|
@ -376,7 +377,7 @@ add_test(function() {
|
|||
EventUtils.synthesizeMouseAtCenter(radios[0], { clickCount: 1 }, gManagerWindow);
|
||||
is(Services.prefs.getCharPref("extensions.inlinesettings3.radioString"), "india", "Radio pref should have been updated");
|
||||
EventUtils.synthesizeMouseAtCenter(radios[2], { clickCount: 1 }, gManagerWindow);
|
||||
is(Services.prefs.getCharPref("extensions.inlinesettings3.radioString"), "kilo", "Radio pref should have been updated");
|
||||
is(Preferences.get("extensions.inlinesettings3.radioString", "wrong"), "kilo \u338F", "Radio pref should have been updated");
|
||||
|
||||
ok(!settings[3].hasAttribute("first-row"), "Not the first row");
|
||||
Services.prefs.setIntPref("extensions.inlinesettings3.menulist", 8);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<radiogroup>
|
||||
<radio label="India" value="india" />
|
||||
<radio label="Juliet" value="juliet" />
|
||||
<radio label="Kilo" value="kilo" />
|
||||
<radio label="Kilo ㎏" value="kilo ㎏" />
|
||||
</radiogroup>
|
||||
</setting>
|
||||
<setting pref="extensions.inlinesettings3.menulist" type="menulist" title="Menulist">
|
||||
|
|
Загрузка…
Ссылка в новой задаче