зеркало из https://github.com/mozilla/gecko-dev.git
Bug 669390 - Allow setting a preference value from the menulist inline preferences; r=Unfocused
This commit is contained in:
Родитель
51833c2046
Коммит
148d191339
|
@ -133,9 +133,10 @@ setting[type="directory"] {
|
|||
-moz-binding: url("chrome://mozapps/content/extensions/setting.xml#setting-path");
|
||||
}
|
||||
|
||||
setting[type="radio"] {
|
||||
setting[type="radio"],
|
||||
setting[type="menulist"] {
|
||||
display: -moz-grid-line;
|
||||
-moz-binding: url("chrome://mozapps/content/extensions/setting.xml#setting-radio");
|
||||
-moz-binding: url("chrome://mozapps/content/extensions/setting.xml#setting-multi");
|
||||
}
|
||||
|
||||
#addonitem-popup > menuitem[disabled="true"] {
|
||||
|
|
|
@ -312,7 +312,7 @@
|
|||
</xul:label>
|
||||
</xul:vbox>
|
||||
<xul:hbox anonid="input-container" class="setting-input">
|
||||
<children includes="button|menulist"/>
|
||||
<children includes="button"/>
|
||||
</xul:hbox>
|
||||
</content>
|
||||
</binding>
|
||||
|
@ -473,7 +473,7 @@
|
|||
</implementation>
|
||||
</binding>
|
||||
|
||||
<binding id="setting-radio" extends="chrome://mozapps/content/extensions/setting.xml#setting-base">
|
||||
<binding id="setting-multi" extends="chrome://mozapps/content/extensions/setting.xml#setting-base">
|
||||
<content>
|
||||
<xul:vbox class="setting-label">
|
||||
<xul:label class="preferences-title" xbl:inherits="value=title" crop="end" flex="1"/>
|
||||
|
@ -482,14 +482,14 @@
|
|||
</xul:label>
|
||||
</xul:vbox>
|
||||
<xul:hbox class="setting-input">
|
||||
<children includes="radiogroup" />
|
||||
<children includes="radiogroup|menulist" />
|
||||
</xul:hbox>
|
||||
</content>
|
||||
|
||||
<implementation>
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
this.radioGroup.addEventListener("command", this.valueToPreference.bind(this), false);
|
||||
this.control.addEventListener("command", this.valueToPreference.bind(this), false);
|
||||
]]>
|
||||
</constructor>
|
||||
|
||||
|
@ -511,9 +511,9 @@
|
|||
return;
|
||||
}
|
||||
|
||||
for (let i = 0; i < this.radioGroup.itemCount; i++) {
|
||||
if (this.radioGroup.getItemAtIndex(i).value == val) {
|
||||
this.radioGroup.selectedIndex = i;
|
||||
for (let i = 0; i < this.control.itemCount; i++) {
|
||||
if (this.control.getItemAtIndex(i).value == val) {
|
||||
this.control.selectedIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -525,7 +525,7 @@
|
|||
<body>
|
||||
<![CDATA[
|
||||
// We might not have a pref already set, so we guess the type from the value attribute
|
||||
let val = this.radioGroup.selectedItem.value;
|
||||
let val = this.control.selectedItem.value;
|
||||
if (val == "true" || val == "false")
|
||||
Services.prefs.setBoolPref(this.pref, val == "true");
|
||||
else if (/^-?\d+$/.test(val))
|
||||
|
@ -536,7 +536,7 @@
|
|||
</body>
|
||||
</method>
|
||||
|
||||
<field name="radioGroup">this.getElementsByTagName("radiogroup")[0];</field>
|
||||
<field name="control">this.getElementsByTagName(this.getAttribute("type") == "radio" ? "radiogroup" : "menulist")[0];</field>
|
||||
</implementation>
|
||||
</binding>
|
||||
</bindings>
|
||||
|
|
|
@ -4,15 +4,6 @@
|
|||
<setting pref="extensions.inlinesettings1.boolint" type="boolint" on="1" off="2" title="BoolInt"/>
|
||||
<setting pref="extensions.inlinesettings1.integer" type="integer" title="Integer"/>
|
||||
<setting pref="extensions.inlinesettings1.string" type="string" title="String"/>
|
||||
<setting type="control" title="Menulist">
|
||||
<menulist sizetopopup="always" oncommand="window._testValue = this.value;">
|
||||
<menupopup>
|
||||
<menuitem label="Alpha" value="1" />
|
||||
<menuitem label="Bravo" value="2" />
|
||||
<menuitem label="Charlie" value="3" />
|
||||
</menupopup>
|
||||
</menulist>
|
||||
</setting>
|
||||
<setting pref="extensions.inlinesettings1.color" type="color" title="Color"/>
|
||||
<setting pref="extensions.inlinesettings1.file" type="file" title="File"/>
|
||||
<setting pref="extensions.inlinesettings1.directory" type="directory" title="Directory"/>
|
||||
|
|
|
@ -8,7 +8,7 @@ var gManagerWindow;
|
|||
var gCategoryUtilities;
|
||||
var gProvider;
|
||||
|
||||
const SETTINGS_ROWS = 8;
|
||||
const SETTINGS_ROWS = 7;
|
||||
|
||||
var observer = {
|
||||
lastData: null,
|
||||
|
@ -80,6 +80,7 @@ function end_test() {
|
|||
Services.prefs.clearUserPref("extensions.inlinesettings3.radioBool");
|
||||
Services.prefs.clearUserPref("extensions.inlinesettings3.radioInt");
|
||||
Services.prefs.clearUserPref("extensions.inlinesettings3.radioString");
|
||||
Services.prefs.clearUserPref("extensions.inlinesettings3.menulist");
|
||||
|
||||
close_manager(gManagerWindow, function() {
|
||||
AddonManager.getAddonByID("inlinesettings1@tests.mozilla.org", function(aAddon) {
|
||||
|
@ -190,17 +191,8 @@ add_test(function() {
|
|||
is(Services.prefs.getCharPref("extensions.inlinesettings1.string"), "bar", "String pref should have been updated");
|
||||
|
||||
ok(!settings[4].hasAttribute("first-row"), "Not the first row");
|
||||
var input = settings[4].firstElementChild;
|
||||
is(input.value, "1", "Menulist should have initial value");
|
||||
input.focus();
|
||||
EventUtils.synthesizeKey("b", {}, gManagerWindow);
|
||||
is(input.value, "2", "Menulist should have updated value");
|
||||
is(gManagerWindow._testValue, "2", "Menulist oncommand handler should've updated the test value");
|
||||
delete gManagerWindow._testValue;
|
||||
|
||||
ok(!settings[5].hasAttribute("first-row"), "Not the first row");
|
||||
Services.prefs.setCharPref("extensions.inlinesettings1.color", "#FF0000");
|
||||
input = gManagerWindow.document.getAnonymousElementByAttribute(settings[5], "anonid", "input");
|
||||
input = gManagerWindow.document.getAnonymousElementByAttribute(settings[4], "anonid", "input");
|
||||
is(input.color, "#FF0000", "Color picker should have initial value");
|
||||
input.focus();
|
||||
EventUtils.synthesizeKey("VK_RIGHT", {}, gManagerWindow);
|
||||
|
@ -213,9 +205,9 @@ add_test(function() {
|
|||
try {
|
||||
mockFilePickerFactory.register();
|
||||
|
||||
ok(!settings[6].hasAttribute("first-row"), "Not the first row");
|
||||
var button = gManagerWindow.document.getAnonymousElementByAttribute(settings[6], "anonid", "button");
|
||||
input = gManagerWindow.document.getAnonymousElementByAttribute(settings[6], "anonid", "input");
|
||||
ok(!settings[5].hasAttribute("first-row"), "Not the first row");
|
||||
var button = gManagerWindow.document.getAnonymousElementByAttribute(settings[5], "anonid", "button");
|
||||
input = gManagerWindow.document.getAnonymousElementByAttribute(settings[5], "anonid", "input");
|
||||
is(input.value, "", "Label value should be empty");
|
||||
|
||||
var profD = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
|
@ -235,9 +227,9 @@ add_test(function() {
|
|||
is(input.value, profD.path, "Label value should not have changed");
|
||||
is(Services.prefs.getCharPref("extensions.inlinesettings1.file"), profD.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");
|
||||
input = gManagerWindow.document.getAnonymousElementByAttribute(settings[7], "anonid", "input");
|
||||
ok(!settings[6].hasAttribute("first-row"), "Not the first row");
|
||||
button = gManagerWindow.document.getAnonymousElementByAttribute(settings[6], "anonid", "button");
|
||||
input = gManagerWindow.document.getAnonymousElementByAttribute(settings[6], "anonid", "input");
|
||||
is(input.value, "", "Label value should be empty");
|
||||
|
||||
_returnFile = profD;
|
||||
|
@ -278,7 +270,7 @@ add_test(function() {
|
|||
|
||||
var grid = gManagerWindow.document.getElementById("detail-grid");
|
||||
var settings = grid.querySelectorAll("rows > setting");
|
||||
is(settings.length, 3, "Grid should have settings children");
|
||||
is(settings.length, 4, "Grid should have settings children");
|
||||
|
||||
// Force bindings to apply
|
||||
settings[0].clientTop;
|
||||
|
@ -315,6 +307,15 @@ add_test(function() {
|
|||
EventUtils.synthesizeMouseAtCenter(radios[2], { clickCount: 1 }, gManagerWindow);
|
||||
is(Services.prefs.getCharPref("extensions.inlinesettings3.radioString"), "kilo", "Radio pref should have been updated");
|
||||
|
||||
ok(!settings[3].hasAttribute("first-row"), "Not the first row");
|
||||
Services.prefs.setIntPref("extensions.inlinesettings3.menulist", 8);
|
||||
var input = settings[3].firstElementChild;
|
||||
is(input.value, "8", "Menulist should have initial value");
|
||||
input.focus();
|
||||
EventUtils.synthesizeKey("n", {}, gManagerWindow);
|
||||
is(input.value, "9", "Menulist should have updated value");
|
||||
is(Services.prefs.getIntPref("extensions.inlinesettings3.menulist"), 9, "Menulist pref should have been updated");
|
||||
|
||||
button = gManagerWindow.document.getElementById("detail-prefs-btn");
|
||||
is_element_hidden(button, "Preferences button should not be visible");
|
||||
|
||||
|
|
|
@ -20,4 +20,13 @@
|
|||
<radio label="Kilo" value="kilo" />
|
||||
</radiogroup>
|
||||
</setting>
|
||||
<setting pref="extensions.inlinesettings3.menulist" type="menulist" title="Menulist">
|
||||
<menulist sizetopopup="always">
|
||||
<menupopup>
|
||||
<menuitem label="Lima" value="7" />
|
||||
<menuitem label="Mike" value="8" />
|
||||
<menuitem label="November" value="9" />
|
||||
</menupopup>
|
||||
</menulist>
|
||||
</setting>
|
||||
</vbox>
|
||||
|
|
Загрузка…
Ссылка в новой задаче