[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

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



commit cf2d009c8aba6ffd168d87efb99e0f684b71759d
Author: Olli Pettay <Olli.Pettay@xxxxxxxxxxx>
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);
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits