Bug 1317173 - Parent window should be frozen when a new child window is opened, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Thu, 08 Dec 2016 05:51:47 -1000
changeset 325438 991e29b1efd2495c5c8a35c98fed48643cd3e27f
parent 325437 422dd1f29d6e8e8d05300e02849724e7d5d032f0
child 325439 a3945af43157bf892bb9415086406774cb380a56
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewerssmaug
bugs1317173
milestone53.0a1
Bug 1317173 - Parent window should be frozen when a new child window is opened, r=smaug
embedding/components/windowwatcher/nsWindowWatcher.cpp
--- a/embedding/components/windowwatcher/nsWindowWatcher.cpp
+++ b/embedding/components/windowwatcher/nsWindowWatcher.cpp
@@ -960,16 +960,28 @@ nsWindowWatcher::OpenWindowInternal(mozI
     }
 
     NS_ASSERTION(mWindowCreator,
                  "attempted to open a new window with no WindowCreator");
     rv = NS_ERROR_FAILURE;
     if (mWindowCreator) {
       nsCOMPtr<nsIWebBrowserChrome> newChrome;
 
+      nsCOMPtr<nsPIDOMWindowInner> parentTopInnerWindow;
+      if (parentWindow) {
+        nsCOMPtr<nsPIDOMWindowOuter> parentTopWindow = parentWindow->GetTop();
+        if (parentTopWindow) {
+          parentTopInnerWindow = parentTopWindow->GetCurrentInnerWindow();
+        }
+      }
+
+      if (parentTopInnerWindow) {
+        parentTopInnerWindow->Suspend();
+      }
+
       /* If the window creator is an nsIWindowCreator2, we can give it
          some hints. The only hint at this time is whether the opening window
          is in a situation that's likely to mean this is an unrequested
          popup window we're creating. However we're not completely honest:
          we clear that indicator if the opener is chrome, so that the
          downstream consumer can treat the indicator to mean simply
          that the new window is subject to popup control. */
       nsCOMPtr<nsIWindowCreator2> windowCreator2(
@@ -979,16 +991,20 @@ nsWindowWatcher::OpenWindowInternal(mozI
         rv = CreateChromeWindow(features, parentChrome, chromeFlags,
                                 nullptr, openerWindow, getter_AddRefs(newChrome));
 
       } else {
         rv = mWindowCreator->CreateChromeWindow(parentChrome, chromeFlags,
                                                 getter_AddRefs(newChrome));
       }
 
+      if (parentTopInnerWindow) {
+        parentTopInnerWindow->Resume();
+      }
+
       if (newChrome) {
         nsCOMPtr<nsIXULWindow> xulWin = do_GetInterface(newChrome);
         if (xulWin) {
           nsCOMPtr<nsIXULBrowserWindow> xulBrowserWin;
           xulWin->GetXULBrowserWindow(getter_AddRefs(xulBrowserWin));
           if (xulBrowserWin) {
             nsPIDOMWindowOuter* openerWindow = aForceNoOpener ? nullptr : parentWindow.get();
             xulBrowserWin->ForceInitialBrowserNonRemote(openerWindow);