diff --git a/toolkit/components/console/hudservice/HUDService.jsm b/toolkit/components/console/hudservice/HUDService.jsm index c6076845e982..f6e46b7c3441 100644 --- a/toolkit/components/console/hudservice/HUDService.jsm +++ b/toolkit/components/console/hudservice/HUDService.jsm @@ -2824,6 +2824,10 @@ HUD_SERVICE.prototype = let windowUI = nBox.ownerDocument.getElementById("console_window_" + hudId); if (windowUI) { // The Web Console popup is already open, no need to continue. + if (aContentWindow == aContentWindow.top) { + let hud = this.hudReferences[hudId]; + hud.reattachConsole(aContentWindow); + } return; } @@ -3228,10 +3232,8 @@ HeadsUpDisplay.prototype = { let panel = this.chromeDocument.createElementNS(XUL_NS, "panel"); - let label = this.getStr("webConsoleOwnWindowTitle"); - let config = { id: "console_window_" + this.hudId, - label: label, + label: this.getPanelTitle(), titlebar: "normal", noautohide: "true", norestorefocus: "true", @@ -3360,6 +3362,17 @@ HeadsUpDisplay.prototype = { return panel; }, + /** + * Retrieve the Web Console panel title. + * + * @return string + * The Web Console panel title. + */ + getPanelTitle: function HUD_getPanelTitle() + { + return this.getFormatStr("webConsoleWindowTitleAndURL", [this.uriSpec]); + }, + positions: { above: 0, // the childNode index below: 2, @@ -3511,6 +3524,10 @@ HeadsUpDisplay.prototype = { this.contentDocument = this.contentWindow.document; this.uriSpec = this.contentWindow.location.href; + if (this.consolePanel) { + this.consolePanel.label = this.getPanelTitle(); + } + if (!this.jsterm) { this.createConsoleInput(this.contentWindow, this.consoleWrap, this.outputNode); } diff --git a/toolkit/components/console/hudservice/tests/browser/Makefile.in b/toolkit/components/console/hudservice/tests/browser/Makefile.in index 3e4adba9741c..c358190005a4 100644 --- a/toolkit/components/console/hudservice/tests/browser/Makefile.in +++ b/toolkit/components/console/hudservice/tests/browser/Makefile.in @@ -142,6 +142,7 @@ _BROWSER_TEST_FILES = \ browser_webconsole_bug_585991_autocomplete_popup.js \ browser_webconsole_bug_585991_autocomplete_keys.js \ browser_webconsole_bug_651501_document_body_autocomplete.js \ + browser_webconsole_bug_663443_panel_title.js \ head.js \ $(NULL) diff --git a/toolkit/components/console/hudservice/tests/browser/browser_webconsole_bug_663443_panel_title.js b/toolkit/components/console/hudservice/tests/browser/browser_webconsole_bug_663443_panel_title.js new file mode 100644 index 000000000000..3828e1c1ba86 --- /dev/null +++ b/toolkit/components/console/hudservice/tests/browser/browser_webconsole_bug_663443_panel_title.js @@ -0,0 +1,45 @@ +/* vim:set ts=2 sw=2 sts=2 et: */ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +const TEST_URI = "data:text/html,

test for bug 663443. test1"; + +const POSITION_PREF = "devtools.webconsole.position"; + +function tabLoad(aEvent) { + browser.removeEventListener(aEvent.type, arguments.callee, true); + + Services.prefs.setCharPref(POSITION_PREF, "window"); + + openConsole(); + + document.addEventListener("popupshown", function() { + document.removeEventListener("popupshown", arguments.callee, false); + + let hudId = HUDService.getHudIdByWindow(content); + ok(hudId, "Web Console is open"); + + let HUD = HUDService.hudReferences[hudId]; + ok(HUD.consolePanel, "Web Console opened in a panel"); + + isnot(HUD.consolePanel.label.indexOf("test1"), -1, "panel title is correct"); + + browser.addEventListener("load", function() { + browser.removeEventListener("load", arguments.callee, true); + + isnot(HUD.consolePanel.label.indexOf("test2"), -1, + "panel title is correct after page navigation"); + + Services.prefs.clearUserPref(POSITION_PREF); + + executeSoon(finish); + }, true); + + content.location = "data:text/html,

test2 for bug 663443"; + }, false); +} + +function test() { + addTab(TEST_URI); + browser.addEventListener("load", tabLoad, true); +} diff --git a/toolkit/locales/en-US/chrome/global/headsUpDisplay.properties b/toolkit/locales/en-US/chrome/global/headsUpDisplay.properties index fd7e1557ab00..19f017436713 100644 --- a/toolkit/locales/en-US/chrome/global/headsUpDisplay.properties +++ b/toolkit/locales/en-US/chrome/global/headsUpDisplay.properties @@ -135,9 +135,9 @@ webConsolePositionBelow=Below # Web Console interface is displayed in a floating panel. webConsolePositionWindow=Window -# LOCALIZATION NOTE (webConsoleOwnWindowTitle): The Web Console floating panel -# title. -webConsoleOwnWindowTitle=Web Console +# LOCALIZATION NOTE (webConsoleWindowTitleAndURL): The Web Console floating +# panel title, followed by the web page URL. +webConsoleWindowTitleAndURL=Web Console - %S # LOCALIZATION NOTE (Autocomplete.label): # The autocomplete popup panel label/title.