Bug 674562 - Web Console windows don't close on osx; r=mihai.sucan

This commit is contained in:
Rob Campbell 2011-07-28 09:51:00 -03:00
Родитель cc7a6814c7
Коммит ac95698ff9
3 изменённых файлов: 39 добавлений и 31 удалений

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

@ -3136,12 +3136,15 @@ HeadsUpDisplay.prototype = {
panel.addEventListener("popupshown", onPopupShown,false);
let onPopupHiding = (function HUD_onPopupHiding(aEvent) {
let onPopupHidden = (function HUD_onPopupHidden(aEvent) {
if (aEvent.target != panel) {
return;
}
panel.removeEventListener("popuphiding", onPopupHiding, false);
panel.removeEventListener("popuphidden", onPopupHidden, false);
if (panel.parentNode) {
panel.parentNode.removeChild(panel);
}
let width = 0;
try {
@ -3149,12 +3152,15 @@ HeadsUpDisplay.prototype = {
}
catch (ex) { }
if (width > -1) {
if (width > 0) {
Services.prefs.setIntPref("devtools.webconsole.width", panel.clientWidth);
}
Services.prefs.setIntPref("devtools.webconsole.top", panel.popupBoxObject.y);
Services.prefs.setIntPref("devtools.webconsole.left", panel.popupBoxObject.x);
/*
* Removed because of bug 674562
* Services.prefs.setIntPref("devtools.webconsole.top", panel.panelBox.y);
* Services.prefs.setIntPref("devtools.webconsole.left", panel.panelBox.x);
*/
// Make sure we are not going to close again, drop the hudId reference of
// the panel.
@ -3170,19 +3176,6 @@ HeadsUpDisplay.prototype = {
this.consolePanel = null;
}).bind(this);
panel.addEventListener("popuphiding", onPopupHiding, false);
let onPopupHidden = (function HUD_onPopupHidden(aEvent) {
if (aEvent.target != panel) {
return;
}
panel.removeEventListener("popuphidden", onPopupHidden, false);
if (panel.parentNode) {
panel.parentNode.removeChild(panel);
}
}).bind(this);
panel.addEventListener("popuphidden", onPopupHidden, false);
let lastIndex = -1;
@ -3249,10 +3242,14 @@ HeadsUpDisplay.prototype = {
positionConsole: function HUD_positionConsole(aPosition)
{
if (!(aPosition in this.positions)) {
throw new Error("Incorrect argument: " + aPosition + ". Cannot position Web Console");
throw new Error("Incorrect argument: " + aPosition +
". Cannot position Web Console");
}
if (aPosition == "window") {
let closeButton = this.consoleFilterToolbar.
querySelector(".webconsole-close-button");
closeButton.setAttribute("hidden", "true");
this.createOwnWindowPanel();
this.positionMenuitems.window.setAttribute("checked", true);
if (this.positionMenuitems.last) {
@ -3308,6 +3305,10 @@ HeadsUpDisplay.prototype = {
this.outputNode.ensureIndexIsVisible(lastIndex);
}
let closeButton = this.consoleFilterToolbar.
getElementsByClassName("webconsole-close-button")[0];
closeButton.removeAttribute("hidden");
this.uiInOwnWindow = false;
if (this.consolePanel) {
this.HUDBox.removeAttribute("flex");

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

@ -5,18 +5,21 @@
const TEST_URI = "data:text/html,<p>test for bug 663443. test1";
const POSITION_PREF = "devtools.webconsole.position";
const POSITION_ABOVE = "above"; // default
const POSITION_WINDOW = "window";
function tabLoad(aEvent) {
browser.removeEventListener(aEvent.type, arguments.callee, true);
Services.prefs.setCharPref(POSITION_PREF, "window");
Services.prefs.setCharPref(POSITION_PREF, POSITION_WINDOW);
openConsole();
document.addEventListener("popupshown", function() {
document.removeEventListener("popupshown", arguments.callee, false);
document.addEventListener("popupshown", function popupShown() {
document.removeEventListener("popupshown", popupShown, false);
let hudId = HUDService.getHudIdByWindow(content);
ok(hudId, "Web Console is open");
let HUD = HUDService.hudReferences[hudId];
@ -30,9 +33,11 @@ function tabLoad(aEvent) {
isnot(HUD.consolePanel.label.indexOf("test2"), -1,
"panel title is correct after page navigation");
Services.prefs.clearUserPref(POSITION_PREF);
HUD.positionConsole(POSITION_ABOVE);
executeSoon(finish);
closeConsole();
executeSoon(finishTest);
}, true);
content.location = "data:text/html,<p>test2 for bug 663443";

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

@ -51,11 +51,11 @@ function onLoad() {
is(Services.prefs.getCharPref(POSITION_PREF), "below", "pref is below");
// listen for the panel popupshown event.
document.addEventListener("popupshown", function() {
document.removeEventListener("popupshown", arguments.callee, false);
document.addEventListener("popupshown", function popupShown() {
document.removeEventListener("popupshown", popupShown, false);
document.addEventListener("popuphidden", function() {
document.removeEventListener("popuphidden", arguments.callee, false);
document.addEventListener("popuphidden", function popupHidden() {
document.removeEventListener("popuphidden", popupHidden, false);
id = hudBox.parentNode.childNodes[2].getAttribute("id");
is(id, hudId, "below position is correct after reopen");
@ -64,9 +64,11 @@ function onLoad() {
ok(diffHeight < 3, "hudBox height is still correct");
is(Services.prefs.getCharPref(POSITION_PREF), "below", "pref is below");
is(Services.prefs.getIntPref(WIDTH_PREF), panelWidth, "width pref updated");
isnot(Services.prefs.getIntPref(TOP_PREF), 50, "top location pref updated");
isnot(Services.prefs.getIntPref(LEFT_PREF), 51, "left location pref updated");
// following three disabled due to bug 674562
// is(Services.prefs.getIntPref(WIDTH_PREF), panelWidth, "width pref updated - bug 674562");
// isnot(Services.prefs.getIntPref(TOP_PREF), 50, "top location pref updated - bug 674562");
// isnot(Services.prefs.getIntPref(LEFT_PREF), 51, "left location pref updated - bug 674562");
// Close the window console via the toolbar button
let btn = hudBox.querySelector(".webconsole-close-button");