Bug 484315 - With browser.tabs.closeWindowWithLastTab set to false popups cannot be closed. r=gavin
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -1476,19 +1476,19 @@
if (ds.contentViewer && !ds.contentViewer.permitUnload())
return null;
}
var closeWindow = false;
var l = this.mTabs.length - this._removingTabs.length;
var newTab = false;
if (l == 1) {
- closeWindow = aCloseWindowWithLastTab != null ?
- aCloseWindowWithLastTab :
- this.mPrefs.getBoolPref("browser.tabs.closeWindowWithLastTab");
+ closeWindow = aCloseWindowWithLastTab != null ? aCloseWindowWithLastTab :
+ !window.toolbar.visible ||
+ 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)))
--- a/browser/base/content/test/Makefile.in
+++ b/browser/base/content/test/Makefile.in
@@ -92,16 +92,17 @@ include $(topsrcdir)/config/rules.mk
browser_bug424101.js \
browser_bug427559.js \
browser_bug432599.js \
browser_bug435035.js \
browser_bug441778.js \
browser_bug455852.js \
browser_bug462673.js \
browser_bug481560.js \
+ browser_bug484315.js \
browser_bug477014.js \
browser_bug495058.js \
browser_bug517902.js \
browser_bug521216.js \
browser_discovery.js \
browser_tabfocus.js \
discovery.html \
moz.png \
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/browser_bug484315.js
@@ -0,0 +1,25 @@
+function test() {
+ var contentWin = window.open("about:blank", "", "width=100,height=100");
+ var enumerator = Cc["@mozilla.org/appshell/window-mediator;1"]
+ .getService(Ci.nsIWindowMediator)
+ .getEnumerator("navigator:browser");
+
+ while (enumerator.hasMoreElements()) {
+ let win = enumerator.getNext();
+ if (win.content == contentWin) {
+ gPrefService.setBoolPref("browser.tabs.closeWindowWithLastTab", false);
+ win.gBrowser.removeCurrentTab();
+ ok(win.closed, "popup is closed");
+
+ // clean up
+ if (!win.closed)
+ win.close();
+ if (gPrefService.prefHasUserValue("browser.tabs.closeWindowWithLastTab"))
+ gPrefService.clearUserPref("browser.tabs.closeWindowWithLastTab");
+
+ return;
+ }
+ }
+
+ throw "couldn't find the content window";
+}