Bug 1317173 - Parent window should be frozen when a new child window is opened. r=smaug, a=gchang
☠☠ backed out by eae3062829b3 ☠ ☠
authorAndrea Marchesini <amarchesini@mozilla.com>
Thu, 08 Dec 2016 05:51:47 -1000
changeset 462186 ffc99a75ab86606c9b06d56d027fdea70682b52c
parent 462185 31ebd0e871c54c2e212d2fcc30adaf986bcae367
child 462187 1d09fe652dd461e64b81ba09b74c541e255c25d8
push id41678
push userfelipc@gmail.com
push dateMon, 16 Jan 2017 20:19:38 +0000
reviewerssmaug, gchang
bugs1317173
milestone51.0
Bug 1317173 - Parent window should be frozen when a new child window is opened. r=smaug, a=gchang
embedding/components/windowwatcher/nsWindowWatcher.cpp
--- a/embedding/components/windowwatcher/nsWindowWatcher.cpp
+++ b/embedding/components/windowwatcher/nsWindowWatcher.cpp
@@ -978,16 +978,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->SuspendTimeouts();
+      }
+
       /* 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(
@@ -1014,16 +1026,20 @@ nsWindowWatcher::OpenWindowInternal(mozI
         rv = CreateChromeWindow(features, parentChrome, chromeFlags, contextFlags,
                                 nullptr, getter_AddRefs(newChrome));
 
       } else {
         rv = mWindowCreator->CreateChromeWindow(parentChrome, chromeFlags,
                                                 getter_AddRefs(newChrome));
       }
 
+      if (parentTopInnerWindow) {
+        parentTopInnerWindow->ResumeTimeouts();
+      }
+
       if (newChrome) {
         nsCOMPtr<nsIXULWindow> xulWin = do_GetInterface(newChrome);
         if (xulWin) {
           nsCOMPtr<nsIXULBrowserWindow> xulBrowserWin;
           xulWin->GetXULBrowserWindow(getter_AddRefs(xulBrowserWin));
           if (xulBrowserWin) {
             xulBrowserWin->ForceInitialBrowserNonRemote();
           }