Bug 951245 - Forwarding to outer should check for active document, not current inner, to handle document.open() cases. r=peterv, a=bajaj
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 20 Dec 2013 14:28:18 -0500
changeset 174532 b15394225283452f00de34cfe86ebaf00f8002a0
parent 174531 45a275782d8a327974a9243a340f0723bcfb0b0f
child 174533 9b1fc11fc88321dba1d388a0bdd30e84f6acbff0
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspeterv, bajaj
bugs951245
milestone28.0a2
Bug 951245 - Forwarding to outer should check for active document, not current inner, to handle document.open() cases. r=peterv, a=bajaj
dom/base/nsGlobalWindow.cpp
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -301,64 +301,66 @@ nsGlobalWindow::DOMMinTimeoutValue() con
 // timer code can handle, really. See DELAY_INTERVAL_LIMIT in
 // nsTimerImpl.h for details.
 #define DOM_MAX_TIMEOUT_VALUE    DELAY_INTERVAL_LIMIT
 
 #define FORWARD_TO_OUTER(method, args, err_rval)                              \
   PR_BEGIN_MACRO                                                              \
   if (IsInnerWindow()) {                                                      \
     nsGlobalWindow *outer = GetOuterWindowInternal();                         \
-    if (!outer || outer->GetCurrentInnerWindow() != this) {                   \
+    if (!HasActiveDocument()) {                                                \
       NS_WARNING(outer ?                                                      \
-                 "Inner window is not its outer's current inner window." :    \
+                 "Inner window does not have active document." :              \
                  "No outer window available!");                               \
       return err_rval;                                                        \
     }                                                                         \
     return outer->method args;                                                \
   }                                                                           \
   PR_END_MACRO
 
 #define FORWARD_TO_OUTER_OR_THROW(method, args, errorresult, err_rval)        \
   PR_BEGIN_MACRO                                                              \
   if (IsInnerWindow()) {                                                      \
     nsGlobalWindow *outer = GetOuterWindowInternal();                         \
-    if (!outer) {                                                             \
-      NS_WARNING("No outer window available!");                               \
-      errorresult.Throw(NS_ERROR_NOT_INITIALIZED);                            \
-    } else if (outer->GetCurrentInnerWindow() != this) {                      \
-      errorresult.Throw(NS_ERROR_XPC_SECURITY_MANAGER_VETO);                  \
+    if (!HasActiveDocument()) {                                               \
+      if (!outer) {                                                           \
+        NS_WARNING("No outer window available!");                             \
+        errorresult.Throw(NS_ERROR_NOT_INITIALIZED);                          \
+      } else {                                                                \
+        errorresult.Throw(NS_ERROR_XPC_SECURITY_MANAGER_VETO);                \
+      }                                                                       \
     } else {                                                                  \
       return outer->method args;                                              \
     }                                                                         \
     return err_rval;                                                          \
   }                                                                           \
   PR_END_MACRO
 
 #define FORWARD_TO_OUTER_VOID(method, args)                                   \
   PR_BEGIN_MACRO                                                              \
   if (IsInnerWindow()) {                                                      \
     nsGlobalWindow *outer = GetOuterWindowInternal();                         \
-    if (!outer || outer->GetCurrentInnerWindow() != this) {                   \
+    if (!HasActiveDocument()) {                                               \
       NS_WARNING(outer ?                                                      \
-                 "Inner window is not its outer's current inner window." :    \
+                 "Inner window does not have active document." :              \
                  "No outer window available!");                               \
       return;                                                                 \
     }                                                                         \
     outer->method args;                                                       \
     return;                                                                   \
   }                                                                           \
   PR_END_MACRO
 
 #define FORWARD_TO_OUTER_CHROME(method, args, err_rval)                       \
   PR_BEGIN_MACRO                                                              \
   if (IsInnerWindow()) {                                                      \
     nsGlobalWindow *outer = GetOuterWindowInternal();                         \
-    if (!outer || outer->GetCurrentInnerWindow() != this) {                   \
+    if (!HasActiveDocument()) {                                               \
       NS_WARNING(outer ?                                                      \
-                 "Inner window is not its outer's current inner window." :    \
+                 "Inner window does not have active document." :              \
                  "No outer window available!");                               \
       return err_rval;                                                        \
     }                                                                         \
     return ((nsGlobalChromeWindow *)outer)->method args;                      \
   }                                                                           \
   PR_END_MACRO
 
 #define FORWARD_TO_INNER_CHROME(method, args, err_rval)                       \
@@ -371,19 +373,19 @@ nsGlobalWindow::DOMMinTimeoutValue() con
     return ((nsGlobalChromeWindow *)mInnerWindow)->method args;               \
   }                                                                           \
   PR_END_MACRO
 
 #define FORWARD_TO_OUTER_MODAL_CONTENT_WINDOW(method, args, err_rval)         \
   PR_BEGIN_MACRO                                                              \
   if (IsInnerWindow()) {                                                      \
     nsGlobalWindow *outer = GetOuterWindowInternal();                         \
-    if (!outer || outer->GetCurrentInnerWindow() != this) {                   \
+    if (!HasActiveDocument()) {                                               \
       NS_WARNING(outer ?                                                      \
-                 "Inner window is not its outer's current inner window." :    \
+                 "Inner window does not have active document." :              \
                  "No outer window available!");                               \
       return err_rval;                                                        \
     }                                                                         \
     return ((nsGlobalModalWindow *)outer)->method args;                       \
   }                                                                           \
   PR_END_MACRO
 
 #define FORWARD_TO_INNER(method, args, err_rval)                              \