Bug 871156 - Allow Ctrl+W to close the tab when the Web Console is focused; r=robcee

This commit is contained in:
Mihai Sucan 2013-05-16 15:35:53 +03:00
parent f73332d456
commit 1c4ff5e9b2
5 changed files with 75 additions and 2 deletions

View File

@ -547,6 +547,10 @@ ViewHelpers.create({ constructor: BrowserConsole, proto: WebConsole.prototype },
this._bc_init = this.$init().then((aReason) => {
let title = this.ui.rootElement.getAttribute("browserConsoleTitle");
this.ui.rootElement.setAttribute("title", title);
let cmd_close = this.ui.document.getElementById("cmd_close");
cmd_close.removeAttribute("disabled");
return aReason;
});

View File

@ -129,6 +129,7 @@ MOCHITEST_BROWSER_FILES = \
browser_bug_869003_inspect_cross_domain_object.js \
browser_bug_862916_console_dir_and_filter_off.js \
browser_console_native_getters.js \
browser_bug_871156_ctrlw_close_tab.js \
head.js \
$(NULL)

View File

@ -0,0 +1,66 @@
/*
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Check that Ctrl-W closes the Browser Console and that Ctrl-W closes the
// current tab when using the Web Console - bug 871156.
function test()
{
const TEST_URI = "data:text/html;charset=utf8,<title>bug871156</title>\n" +
"<p>hello world";
addTab(TEST_URI);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
openConsole(null, consoleOpened);
}, true);
function consoleOpened(hud)
{
ok(hud, "Web Console opened");
let tabClosed = false, toolboxDestroyed = false;
gBrowser.tabContainer.addEventListener("TabClose", function onTabClose() {
gBrowser.tabContainer.removeEventListener("TabClose", onTabClose);
ok(true, "tab closed");
tabClosed = true;
if (toolboxDestroyed) {
testBrowserConsole();
}
});
let toolbox = gDevTools.getToolbox(hud.target);
toolbox.once("destroyed", () => {
ok(true, "toolbox destroyed");
toolboxDestroyed = true;
if (tabClosed) {
testBrowserConsole();
}
});
EventUtils.synthesizeKey("w", { accelKey: true }, hud.iframeWindow);
}
function testBrowserConsole()
{
info("test the Browser Console");
HUDConsoleUI.toggleBrowserConsole().then((hud) => {
ok(hud, "Browser Console opened");
Services.obs.addObserver(function onDestroy() {
Services.obs.removeObserver(onDestroy, "web-console-destroyed");
ok(true, "the Browser Console closed");
executeSoon(finishTest);
}, "web-console-destroyed", false);
EventUtils.synthesizeKey("w", { accelKey: true }, hud.iframeWindow);
});
}
}

View File

@ -37,7 +37,7 @@
<command id="cmd_fullZoomEnlarge" oncommand="goDoCommand('cmd_fontSizeEnlarge');"/>
<command id="cmd_fullZoomReduce" oncommand="goDoCommand('cmd_fontSizeReduce');"/>
<command id="cmd_fullZoomReset" oncommand="goDoCommand('cmd_fontSizeReset');"/>
<command id="cmd_close" oncommand="goDoCommand('cmd_close');"/>
<command id="cmd_close" oncommand="goDoCommand('cmd_close');" disabled="true"/>
</commandset>
<keyset id="consoleKeys">
<key id="key_fullZoomReduce" key="&fullZoomReduceCmd.commandkey;" command="cmd_fullZoomReduce" modifiers="accel"/>

View File

@ -187,7 +187,9 @@ function log(aThing) {
i++;
}
}
else if (type.match("Error$") || aThing.name == "NS_ERROR_FAILURE") {
else if (type.match("Error$") ||
(typeof aThing.name == "string" &&
aThing.name.match("NS_ERROR_"))) {
reply += " Message: " + aThing + "\n";
if (aThing.stack) {
reply += " Stack:\n";