diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index f4b7f854a5f..086b08eba54 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -1344,12 +1344,14 @@ nsGlobalWindow::~nsGlobalWindow() void nsGlobalWindow::AddEventTargetObject(DOMEventTargetHelper* aObject) { + MOZ_ASSERT(IsInnerWindow()); mEventTargetObjects.PutEntry(aObject); } void nsGlobalWindow::RemoveEventTargetObject(DOMEventTargetHelper* aObject) { + MOZ_ASSERT(IsInnerWindow()); mEventTargetObjects.RemoveEntry(aObject); } diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h index d3bda51bf26..438508e4e5b 100644 --- a/dom/base/nsGlobalWindow.h +++ b/dom/base/nsGlobalWindow.h @@ -696,6 +696,7 @@ public: void UnmarkGrayTimers(); + // Inner windows only. void AddEventTargetObject(mozilla::DOMEventTargetHelper* aObject); void RemoveEventTargetObject(mozilla::DOMEventTargetHelper* aObject); diff --git a/dom/events/DOMEventTargetHelper.cpp b/dom/events/DOMEventTargetHelper.cpp index 758852a62e0..503ddd4bb63 100644 --- a/dom/events/DOMEventTargetHelper.cpp +++ b/dom/events/DOMEventTargetHelper.cpp @@ -91,7 +91,7 @@ DOMEventTargetHelper::~DOMEventTargetHelper() void DOMEventTargetHelper::BindToOwner(nsPIDOMWindow* aOwner) { - MOZ_ASSERT(!aOwner || aOwner->IsInnerWindow()); + MOZ_ASSERT_IF(aOwner, aOwner->IsInnerWindow()); nsCOMPtr glob = do_QueryInterface(aOwner); BindToOwner(glob); } @@ -112,6 +112,7 @@ DOMEventTargetHelper::BindToOwner(nsIGlobalObject* aOwner) // Let's cache the result of this QI for fast access and off main thread usage mOwnerWindow = nsCOMPtr(do_QueryInterface(aOwner)).get(); if (mOwnerWindow) { + MOZ_ASSERT(mOwnerWindow->IsInnerWindow()); mHasOrHasHadOwnerWindow = true; static_cast(mOwnerWindow)->AddEventTargetObject(this); } @@ -134,6 +135,7 @@ DOMEventTargetHelper::BindToOwner(DOMEventTargetHelper* aOther) // Let's cache the result of this QI for fast access and off main thread usage mOwnerWindow = nsCOMPtr(do_QueryInterface(mParentObject)).get(); if (mOwnerWindow) { + MOZ_ASSERT(mOwnerWindow->IsInnerWindow()); mHasOrHasHadOwnerWindow = true; static_cast(mOwnerWindow)->AddEventTargetObject(this); } diff --git a/dom/events/DOMEventTargetHelper.h b/dom/events/DOMEventTargetHelper.h index 3c70a0a352e..ef58e5b7d67 100644 --- a/dom/events/DOMEventTargetHelper.h +++ b/dom/events/DOMEventTargetHelper.h @@ -120,12 +120,8 @@ public: nsresult CheckInnerWindowCorrectness() { NS_ENSURE_STATE(!mHasOrHasHadOwnerWindow || mOwnerWindow); - if (mOwnerWindow) { - NS_ASSERTION(mOwnerWindow->IsInnerWindow(), "Should have inner window here!\n"); - nsPIDOMWindow* outer = mOwnerWindow->GetOuterWindow(); - if (!outer || outer->GetCurrentInnerWindow() != mOwnerWindow) { - return NS_ERROR_FAILURE; - } + if (mOwnerWindow && !mOwnerWindow->IsCurrentInnerWindow()) { + return NS_ERROR_FAILURE; } return NS_OK; } @@ -159,7 +155,7 @@ protected: private: // Inner window or sandbox. nsIGlobalObject* mParentObject; - // mParentObject pre QI-ed and cached + // mParentObject pre QI-ed and cached (inner window) // (it is needed for off main thread access) nsPIDOMWindow* mOwnerWindow; bool mHasOrHasHadOwnerWindow;