Bug 663443 - No indication to which tab a Web Console window belongs (esp. an empty one); r=ddahl,dietrich

This commit is contained in:
Mihai Sucan 2011-06-18 17:42:14 +03:00
Родитель 91ca72dac8
Коммит 5ada22578d
4 изменённых файлов: 69 добавлений и 6 удалений

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -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)

Просмотреть файл

@ -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,<p>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,<p>test2 for bug 663443";
}, false);
}
function test() {
addTab(TEST_URI);
browser.addEventListener("load", tabLoad, true);
}

Просмотреть файл

@ -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.