Bug 702342 - Filter Button should remain popped up when unchecking a suboption if any of the other suboptions remain checked. r=msucan

This commit is contained in:
Heather Arthur 2011-11-23 19:02:23 -08:00
parent c640e09835
commit 4de902e4ee
2 changed files with 36 additions and 26 deletions

View File

@ -6290,18 +6290,17 @@ HeadsUpDisplayUICommands = {
// Adjust the state of the button appropriately. // Adjust the state of the button appropriately.
let menuPopup = this.parentNode; let menuPopup = this.parentNode;
let allChecked = true; let someChecked = false;
let menuItem = menuPopup.firstChild; let menuItem = menuPopup.firstChild;
while (menuItem) { while (menuItem) {
if (menuItem.getAttribute("checked") !== "true") { if (menuItem.getAttribute("checked") === "true") {
allChecked = false; someChecked = true;
break; break;
} }
menuItem = menuItem.nextSibling; menuItem = menuItem.nextSibling;
} }
let toolbarButton = menuPopup.parentNode; let toolbarButton = menuPopup.parentNode;
toolbarButton.setAttribute("checked", allChecked); toolbarButton.setAttribute("checked", someChecked);
break; break;
} }
} }

View File

@ -59,17 +59,17 @@ function testMenuFilterButton(aCategory) {
ok(isChecked(button), "the button for category " + aCategory + " is " + ok(isChecked(button), "the button for category " + aCategory + " is " +
"checked after turning on all its menu items"); "checked after turning on all its menu items");
// Turn one filter off; make sure the button is no longer checked. // Turn one filter off; make sure the button is still checked.
prefKey = firstMenuItem.getAttribute("prefKey"); prefKey = firstMenuItem.getAttribute("prefKey");
chooseMenuItem(firstMenuItem); chooseMenuItem(firstMenuItem);
ok(!isChecked(firstMenuItem), "the first menu item for category " + ok(!isChecked(firstMenuItem), "the first menu item for category " +
aCategory + " is no longer checked after clicking it"); aCategory + " is no longer checked after clicking it");
ok(!HUDService.filterPrefs[hudId][prefKey], prefKey + " messages are " + ok(!HUDService.filterPrefs[hudId][prefKey], prefKey + " messages are " +
"turned off after clicking the appropriate menu item"); "turned off after clicking the appropriate menu item");
ok(!isChecked(button), "the button for category " + aCategory + " is no " + ok(isChecked(button), "the button for category " + aCategory + " is still " +
"longer checked after turning off its first menu item"); "checked after turning off its first menu item");
// Turn all the filters on by clicking the main part of the button. // Turn all the filters off by clicking the main part of the button.
let anonymousNodes = document.getAnonymousNodes(button); let anonymousNodes = document.getAnonymousNodes(button);
let subbutton; let subbutton;
for (let i = 0; i < anonymousNodes.length; i++) { for (let i = 0; i < anonymousNodes.length; i++) {
@ -82,23 +82,8 @@ function testMenuFilterButton(aCategory) {
ok(subbutton, "we have the subbutton for category " + aCategory); ok(subbutton, "we have the subbutton for category " + aCategory);
clickButton(subbutton); clickButton(subbutton);
ok(isChecked(button), "the button for category " + aCategory + " is " + ok(!isChecked(button), "the button for category " + aCategory + " is " +
"checked after clicking its main part"); "no longer checked after clicking its main part");
menuItem = firstMenuItem;
while (menuItem) {
let prefKey = menuItem.getAttribute("prefKey");
ok(isChecked(menuItem), "menu item " + prefKey + " for category " +
aCategory + " is checked after clicking the button");
ok(HUDService.filterPrefs[hudId][prefKey], prefKey + " messages are " +
"on after clicking the button");
menuItem = menuItem.nextSibling;
}
// Turn all the filters off by clicking the main part of the button.
clickButton(subbutton);
ok(!isChecked(subbutton), "the button for category " + aCategory + " is " +
"no longer checked after clicking it");
menuItem = firstMenuItem; menuItem = firstMenuItem;
while (menuItem) { while (menuItem) {
@ -110,6 +95,32 @@ function testMenuFilterButton(aCategory) {
menuItem = menuItem.nextSibling; menuItem = menuItem.nextSibling;
} }
// Turn all the filters on by clicking the main part of the button.
clickButton(subbutton);
ok(isChecked(button), "the button for category " + aCategory + " is " +
"checked after clicking its main part");
menuItem = firstMenuItem;
while (menuItem) {
let prefKey = menuItem.getAttribute("prefKey");
ok(isChecked(menuItem), "menu item " + prefKey + " for category " +
aCategory + " is checked after clicking the button");
ok(HUDService.filterPrefs[hudId][prefKey], prefKey + " messages are " +
"on after clicking the button");
menuItem = menuItem.nextSibling;
}
// Uncheck the main button by unchecking all the filters
menuItem = firstMenuItem;
while (menuItem) {
chooseMenuItem(menuItem);
menuItem = menuItem.nextSibling;
}
ok(!isChecked(button), "the button for category " + aCategory + " is " +
"unchecked after unchecking all its filters");
// Turn all the filters on again by clicking the button. // Turn all the filters on again by clicking the button.
clickButton(subbutton); clickButton(subbutton);
} }