Bug 1422033 - Support opening a new window when no windows are avaliable for a new tab, r=bz
authorNika Layzell <nika@thelayzells.com>
Tue, 05 Dec 2017 16:44:14 -0500
changeset 708631 a65ee5a914a93d86f2de29f43a4d55ed4a6966c6
parent 708630 d7ab986673907d885bca6381ec08dd551be8a2d6
child 708632 b9123a220811b16cdb0b54cbc254d01792c879ad
push id92403
push userVYV03354@nifty.ne.jp
push dateWed, 06 Dec 2017 22:18:41 +0000
reviewersbz
bugs1422033
milestone59.0a1
Bug 1422033 - Support opening a new window when no windows are avaliable for a new tab, r=bz MozReview-Commit-ID: DzSllBVdUhq
dom/ipc/ContentParent.cpp
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -4586,21 +4586,28 @@ ContentParent::CommonCreateWindow(PBrows
                                               aNextTabParentId, aName,
                                               getter_AddRefs(frameLoaderOwner));
     }
     if (NS_SUCCEEDED(aResult) && frameLoaderOwner) {
       RefPtr<nsFrameLoader> frameLoader = frameLoaderOwner->GetFrameLoader();
       if (frameLoader) {
         frameLoader->GetTabParent(getter_AddRefs(aNewTabParent));
       }
+    } else if (NS_SUCCEEDED(aResult) && !frameLoaderOwner) {
+      // Fall through to the normal window opening code path when there is no
+      // window which we can open a new tab in.
+      openLocation = nsIBrowserDOMWindow::OPEN_NEWWINDOW;
     } else {
       *aWindowIsNew = false;
     }
 
-    return IPC_OK();
+    // If we didn't retarget our window open into a new window, we should return now.
+    if (openLocation != nsIBrowserDOMWindow::OPEN_NEWWINDOW) {
+      return IPC_OK();
+    }
   }
 
   nsCOMPtr<nsPIWindowWatcher> pwwatch =
     do_GetService(NS_WINDOWWATCHER_CONTRACTID, &aResult);
   if (NS_WARN_IF(NS_FAILED(aResult))) {
     return IPC_OK();
   }