Bug 767994 - reset the toolbar error counter when the clear button is pressed; r=paul

This commit is contained in:
Mihai Sucan 2012-06-25 18:58:14 +03:00
parent bc579c9f17
commit dd01ca9e4d
3 changed files with 32 additions and 3 deletions

View File

@ -506,6 +506,22 @@ function DT__updateErrorsCount(aChangedTabId)
}
};
/**
* Reset the errors counter for the given tab.
*
* @param nsIDOMElement aTab The xul:tab for which you want to reset the page
* errors counters.
*/
DeveloperToolbar.prototype.resetErrorsCount =
function DT_resetErrorsCount(aTab)
{
let tabId = aTab.linkedPanel;
if (tabId in this._errorsCount) {
this._errorsCount[tabId] = 0;
this._updateErrorsCount(tabId);
}
};
/**
* Panel to handle command line output.
* @param aChromeDoc document from which we can pull the parts we need.

View File

@ -30,7 +30,7 @@ function test() {
function getErrorsCount() {
let match = webconsole.label.match(/\((\d+)\)$/);
return (match || [])[1];
return match ? match[1] : 0;
}
function onOpenToolbar() {
@ -149,11 +149,23 @@ function test() {
validator: function() {
return hud.outputNode.textContent.indexOf("foobarBug762996click") > -1;
},
success: doPageReload.bind(null, hud),
success: doClearConsoleButton.bind(null, hud),
failure: finish,
};
}
function doClearConsoleButton(hud) {
let clearButton = hud.HUDBox
.querySelector(".webconsole-clear-console-button");
EventUtils.synthesizeMouse(clearButton, 2, 2, {}, window);
is(hud.outputNode.textContent.indexOf("foobarBug762996click"), -1,
"clear console button worked");
is(getErrorsCount(), 0, "page errors counter has been reset");
doPageReload(hud);
}
function doPageReload(hud) {
tab1.linkedBrowser.addEventListener("load", function _onReload() {
tab1.linkedBrowser.removeEventListener("load", _onReload, true);
@ -179,7 +191,7 @@ function test() {
validator: function() {
return hud.outputNode.querySelectorAll(".hud-exception").length;
},
value: 4,
value: 3,
success: function() {
isnot(hud.outputNode.textContent.indexOf("foobarBug762996load"), -1,
"foobarBug762996load found in console output after page reload");

View File

@ -1841,6 +1841,7 @@ HeadsUpDisplay.prototype = {
function HUD_clearButton_onCommand() {
let hud = HUDService.getHudReferenceById(hudId);
hud.jsterm.clearOutput(true);
hud.chromeWindow.DeveloperToolbar.resetErrorsCount(hud.tab);
}
let clearButton = this.makeXULNode("toolbarbutton");