Bug 629889 - open all in tabs is broken from Library when no browser window is open. r=mak. a=blocker.
authorAsaf Romano (Mano) <mano@mozilla.com>
Mon, 31 Jan 2011 22:02:43 +0200
changeset 61655 0162ac678b8ff5e7278275243758835e3c072679
parent 61654 c71dc0ee1973787687100c3b294238c775a85f9a
child 61656 947ba01d23f3713824a87190dfc33577ac23543a
push idunknown
push userunknown
push dateunknown
reviewersmak, blocker
bugs629889
milestone2.0b11pre
Bug 629889 - open all in tabs is broken from Library when no browser window is open. r=mak. a=blocker.
browser/components/places/src/PlacesUIUtils.jsm
--- a/browser/components/places/src/PlacesUIUtils.jsm
+++ b/browser/components/places/src/PlacesUIUtils.jsm
@@ -767,26 +767,34 @@ var PlacesUIUtils = {
       if (item.isBookmark)
         this.markPageAsFollowedBookmark(item.uri);
       else
         this.markPageAsTyped(item.uri);
 
       urls.push(item.uri);
     }
 
-    var where = aWindow.whereToOpenLink(aEvent, false, true);
+    // Prefer the caller window if it's a browser window, otherwise use
+    // the top browser window.
+    var browserWindow =
+      aWindow.document.documentElement.getAttribute("windowtype") == "navigator:browser" ?
+      aWindow : this._getTopBrowserWin();
+
+    // whereToOpenLink doesn't return "window" when there's no browser window
+    // open (Bug 630255).
+    var where = browserWindow ?
+                browserWindow.whereToOpenLink(aEvent, false, true) : "window";
     if (where == "window") {
-      aWindow.openDialog(win.getBrowserURL(), "_blank",
+      aWindow.openDialog(aWindow.getBrowserURL(), "_blank",
                          "chrome,all,dialog=no", urls.join("|"));
       return;
     }
 
     var loadInBackground = where == "tabshifted" ? true : false;
     var replaceCurrentTab = where == "tab" ? false : true;
-    var browserWindow = this._getTopBrowserWin();
     browserWindow.gBrowser.loadTabs(urls, loadInBackground, replaceCurrentTab);
   },
 
   /**
    * Helper method for methods which are forced to take a view/window
    * parameter as an optional parameter.  It will be removed post Fx4.
    */
   _getWindow: function PUIU__getWindow(aView) {