From 1244bc429513e90e29ea712ce52cae6f4f925b6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A3o=20Gottwald?= Date: Sun, 5 Apr 2009 10:10:24 +0200 Subject: [PATCH] Bug 481560 - tab closes and location bar clears before the window closes. r=gavin --- browser/base/content/tabbrowser.xml | 12 +++++++++++- browser/base/content/test/Makefile.in | 1 + .../base/content/test/browser_bug481560.js | 19 +++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 browser/base/content/test/browser_bug481560.js diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml index fb435587717b..336c3cfcccb0 100644 --- a/browser/base/content/tabbrowser.xml +++ b/browser/base/content/tabbrowser.xml @@ -1510,7 +1510,7 @@ @@ -1526,6 +1526,7 @@ + -1 || this._windowIsClosing) @@ -1547,6 +1548,15 @@ aCloseWindowWithLastTab : this.mPrefs.getBoolPref("browser.tabs.closeWindowWithLastTab"); + // Closing the tab and replacing it with a blank one is notably slower + // than closing the window right away. If the caller opts in, take + // the fast path. + if (closeWindow && + aCloseWindowFastpath && + this._removingTabs.length == 0 && + (this._windowIsClosing = window.closeWindow(true))) + return null; + newTab = this.addTab("about:blank"); newTab.collapsed = true; l++; diff --git a/browser/base/content/test/Makefile.in b/browser/base/content/test/Makefile.in index bac4c2be485a..1f87f867ccdf 100644 --- a/browser/base/content/test/Makefile.in +++ b/browser/base/content/test/Makefile.in @@ -74,6 +74,7 @@ _BROWSER_FILES = browser_sanitize-timespans.js \ browser_bug441778.js \ browser_bug455852.js \ browser_bug462673.js \ + browser_bug481560.js \ browser_discovery.js \ discovery.html \ moz.png \ diff --git a/browser/base/content/test/browser_bug481560.js b/browser/base/content/test/browser_bug481560.js new file mode 100644 index 000000000000..199dfad127dc --- /dev/null +++ b/browser/base/content/test/browser_bug481560.js @@ -0,0 +1,19 @@ +function test() { + waitForExplicitFinish(); + + var win = openDialog(getBrowserURL(), "_blank", "chrome,all,dialog=no"); + + win.addEventListener("load", function () { + win.removeEventListener("load", arguments.callee, false); + + win.gBrowser.selectedTab.addEventListener("TabClose", function () { + ok(false, "shouldn't have gotten the TabClose event for the last tab"); + }, false); + + EventUtils.synthesizeKey("w", { accelKey: true }, win); + + ok(win.closed, "accel+w closed the window immediately"); + + finish(); + }, false); +}