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 370396 991e29b1efd2495c5c8a35c98fed48643cd3e27f
parent 370395 422dd1f29d6e8e8d05300e02849724e7d5d032f0
child 370397 a3945af43157bf892bb9415086406774cb380a56
push id6996
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 20:48:21 +0000
treeherdermozilla-beta@d89512dab048 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1317173
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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);