зеркало из https://github.com/mozilla/gecko-dev.git
Bug 705903 - Web console filter button should retain checked state when any of its menuitems are checked. r=msucan
This commit is contained in:
Родитель
0757cc46b2
Коммит
e17da89869
|
@ -3941,7 +3941,7 @@ HeadsUpDisplay.prototype = {
|
|||
let menuPopup = this.makeXULNode("menupopup");
|
||||
toolbarButton.appendChild(menuPopup);
|
||||
|
||||
let allChecked = true;
|
||||
let someChecked = false;
|
||||
for (let i = 0; i < aDescriptor.severities.length; i++) {
|
||||
let severity = aDescriptor.severities[i];
|
||||
let menuItem = this.makeXULNode("menuitem");
|
||||
|
@ -3955,8 +3955,8 @@ HeadsUpDisplay.prototype = {
|
|||
|
||||
let checked = this.filterPrefs[prefKey];
|
||||
menuItem.setAttribute("checked", checked);
|
||||
if (!checked) {
|
||||
allChecked = false;
|
||||
if (checked) {
|
||||
someChecked = true;
|
||||
}
|
||||
|
||||
menuItem.addEventListener("command", toggleFilter, false);
|
||||
|
@ -3964,7 +3964,7 @@ HeadsUpDisplay.prototype = {
|
|||
menuPopup.appendChild(menuItem);
|
||||
}
|
||||
|
||||
toolbarButton.setAttribute("checked", allChecked);
|
||||
toolbarButton.setAttribute("checked", someChecked);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,57 +3,114 @@
|
|||
|
||||
function test() {
|
||||
let prefService = Services.prefs;
|
||||
let prefs = [
|
||||
"network",
|
||||
"networkinfo",
|
||||
"csserror",
|
||||
"cssparser",
|
||||
"exception",
|
||||
"jswarn",
|
||||
"error",
|
||||
"warn",
|
||||
"info",
|
||||
"log"
|
||||
];
|
||||
|
||||
//Set all prefs to true
|
||||
prefs.forEach(function(pref) {
|
||||
prefService.setBoolPref("devtools.webconsole.filter." + pref, true);
|
||||
});
|
||||
let prefs = {
|
||||
"net": [
|
||||
"network",
|
||||
"networkinfo"
|
||||
],
|
||||
"css": [
|
||||
"csserror",
|
||||
"cssparser"
|
||||
],
|
||||
"js": [
|
||||
"exception",
|
||||
"jswarn"
|
||||
],
|
||||
"logging": [
|
||||
"error",
|
||||
"warn",
|
||||
"info",
|
||||
"log"
|
||||
]
|
||||
};
|
||||
|
||||
// Set all prefs to true
|
||||
for (let category in prefs) {
|
||||
prefs[category].forEach(function(pref) {
|
||||
prefService.setBoolPref("devtools.webconsole.filter." + pref, true);
|
||||
});
|
||||
}
|
||||
|
||||
addTab("about:blank");
|
||||
openConsole();
|
||||
|
||||
let hud = HUDService.getHudByWindow(content);
|
||||
let hudId = HUDService.getHudIdByWindow(content);
|
||||
|
||||
//Check if the filters menuitems exists and is checked
|
||||
prefs.forEach(function(pref) {
|
||||
let checked = hud.HUDBox.querySelector("menuitem[prefKey=" + pref + "]").
|
||||
getAttribute("checked");
|
||||
is(checked, "true", "menuitem for " + pref + " exists and is checked");
|
||||
});
|
||||
|
||||
//Set all prefs to false
|
||||
prefs.forEach(function(pref) {
|
||||
HUDService.setFilterState(hudId, pref, false);
|
||||
});
|
||||
let hud = HUDService.getHudByWindow(content);
|
||||
|
||||
// Check if the filters menuitems exists and are checked
|
||||
for (let category in prefs) {
|
||||
let button = hud.HUDBox.querySelector(".webconsole-filter-button[category=\""
|
||||
+ category + "\"]");
|
||||
ok(isChecked(button), "main button for " + category + " category is checked");
|
||||
|
||||
prefs[category].forEach(function(pref) {
|
||||
let menuitem = hud.HUDBox.querySelector("menuitem[prefKey=" + pref + "]");
|
||||
ok(isChecked(menuitem), "menuitem for " + pref + " is checked");
|
||||
});
|
||||
}
|
||||
|
||||
// Set all prefs to false
|
||||
for (let category in prefs) {
|
||||
prefs[category].forEach(function(pref) {
|
||||
HUDService.setFilterState(hud.hudId, pref, false);
|
||||
});
|
||||
}
|
||||
|
||||
//Re-init the console
|
||||
closeConsole();
|
||||
openConsole();
|
||||
|
||||
hud = HUDService.getHudByWindow(content);
|
||||
|
||||
//Check if filters menuitems exists and are unchecked
|
||||
prefs.forEach(function(pref) {
|
||||
let checked = hud.HUDBox.querySelector("menuitem[prefKey=" + pref + "]").
|
||||
getAttribute("checked");
|
||||
is(checked, "false", "menuitem for " + pref + " exists and is not checked");
|
||||
prefService.clearUserPref("devtools.webconsole.filter." + pref);
|
||||
});
|
||||
|
||||
|
||||
// Check if the filter button and menuitems are unchecked
|
||||
for (let category in prefs) {
|
||||
let button = hud.HUDBox.querySelector(".webconsole-filter-button[category=\""
|
||||
+ category + "\"]");
|
||||
ok(isUnchecked(button), "main button for " + category + " category is not checked");
|
||||
|
||||
prefs[category].forEach(function(pref) {
|
||||
let menuitem = hud.HUDBox.querySelector("menuitem[prefKey=" + pref + "]");
|
||||
ok(isUnchecked(menuitem), "menuitem for " + pref + " is not checked");
|
||||
});
|
||||
}
|
||||
|
||||
// Set first pref in each category to true
|
||||
for (let category in prefs) {
|
||||
HUDService.setFilterState(hud.hudId, prefs[category][0], true);
|
||||
}
|
||||
|
||||
// Re-init the console
|
||||
closeConsole();
|
||||
openConsole();
|
||||
|
||||
hud = HUDService.getHudByWindow(content);
|
||||
|
||||
// Check the main category button is checked and first menuitem is checked
|
||||
for (let category in prefs) {
|
||||
let button = hud.HUDBox.querySelector(".webconsole-filter-button[category=\""
|
||||
+ category + "\"]");
|
||||
ok(isChecked(button), category + " button is checked when first pref is true");
|
||||
|
||||
let pref = prefs[category][0];
|
||||
let menuitem = hud.HUDBox.querySelector("menuitem[prefKey=" + pref + "]");
|
||||
ok(isChecked(menuitem), "first " + category + " menuitem is checked");
|
||||
}
|
||||
|
||||
// Clear prefs
|
||||
for (let category in prefs) {
|
||||
prefs[category].forEach(function(pref) {
|
||||
prefService.clearUserPref("devtools.webconsole.filter." + pref);
|
||||
});
|
||||
}
|
||||
|
||||
gBrowser.removeCurrentTab();
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
function isChecked(aNode) {
|
||||
return aNode.getAttribute("checked") === "true";
|
||||
}
|
||||
|
||||
function isUnchecked(aNode) {
|
||||
return aNode.getAttribute("checked") === "false";
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче