Bug 484315 - With browser.tabs.closeWindowWithLastTab set to false popups cannot be closed. r=gavin
authorDão Gottwald <dao@mozilla.com>
Fri, 06 Nov 2009 22:39:46 +0100
changeset 33135 d2d2ed0ded6d548827297600b9d5b2a8411db8b1
parent 33134 3deac7ed7df13ec4c59b9315647fa646107a9b2c
child 33136 af8ba1f406037d48ab4e62c2e0bd0c7e536eea5f
push id798
push userdgottwald@mozilla.com
push dateTue, 24 Nov 2009 20:42:48 +0000
reviewersgavin
bugs484315
milestone1.9.2b4pre
Bug 484315 - With browser.tabs.closeWindowWithLastTab set to false popups cannot be closed. r=gavin
browser/base/content/tabbrowser.xml
browser/base/content/test/Makefile.in
browser/base/content/test/browser_bug484315.js
--- 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";
+}