[tor-commits] [tor-browser/esr24] Bug 982909 - Consistently use inner window when calling OpenJS. r=jst, r=mrbkap, a=lsblakk

mikeperry at torproject.org mikeperry at torproject.org
Fri Aug 29 05:26:38 UTC 2014


commit cf2d009c8aba6ffd168d87efb99e0f684b71759d
Author: Olli Pettay <Olli.Pettay at helsinki.fi>
Date:   Thu Mar 13 15:44:25 2014 -0400

    Bug 982909 - Consistently use inner window when calling OpenJS. r=jst, r=mrbkap, a=lsblakk
---
 content/html/document/src/nsHTMLDocument.cpp |    2 +-
 dom/base/nsGlobalWindow.cpp                  |   10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp
index 6608154..6e3635f 100644
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -1416,7 +1416,7 @@ nsHTMLDocument::Open(JSContext* /* unused */,
   NS_ASSERTION(nsContentUtils::CanCallerAccess(static_cast<nsIDOMHTMLDocument*>(this)),
                "XOW should have caught this!");
 
-  nsCOMPtr<nsIDOMWindow> window = GetWindow();
+  nsCOMPtr<nsIDOMWindow> window = GetInnerWindow();
   if (!window) {
     rv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
     return nullptr;
diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp
index bc6ecc4..7b6707a 100644
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -426,6 +426,14 @@ nsGlobalWindow::DOMMinTimeoutValue() const {
   }                                                                           \
   PR_END_MACRO
 
+#define NS_ENSURE_OUTER_WINDOW_OR_ACTIVE_DOCUMENT                              \
+  NS_ENSURE_TRUE(!IsInnerWindow() ||                                           \
+                 (mOuterWindow &&                                              \
+                  ((mOuterWindow->GetCurrentInnerWindow() == this) ||          \
+                   (mOuterWindow->GetCurrentInnerWindow() &&                   \
+                    mOuterWindow->GetCurrentInnerWindow()->GetDoc() == mDoc))),\
+                 NS_ERROR_NOT_INITIALIZED);
+
 // CIDs
 static NS_DEFINE_CID(kXULControllersCID, NS_XULCONTROLLERS_CID);
 
@@ -6425,6 +6433,7 @@ NS_IMETHODIMP
 nsGlobalWindow::OpenJS(const nsAString& aUrl, const nsAString& aName,
                        const nsAString& aOptions, nsIDOMWindow **_retval)
 {
+  NS_ENSURE_OUTER_WINDOW_OR_ACTIVE_DOCUMENT
   return OpenInternal(aUrl, aName, aOptions,
                       false,          // aDialog
                       false,          // aContentModal
@@ -7742,6 +7751,7 @@ nsGlobalWindow::ShowModalDialog(const nsAString& aURI, nsIVariant *aArgs_,
                                 const nsAString& aOptions, uint8_t aArgc,
                                 nsIVariant **aRetVal)
 {
+  NS_ENSURE_OUTER_WINDOW_OR_ACTIVE_DOCUMENT
   FORWARD_TO_OUTER(ShowModalDialog, (aURI, aArgs_, aOptions, aArgc, aRetVal),
                    NS_ERROR_NOT_INITIALIZED);
 





More information about the tor-commits mailing list