Bug 1044586 - fix propagating document events to the window when the inner window has changed, r?smaug
MozReview-Commit-ID: G6yPBwbITvG
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -7632,19 +7632,22 @@ nsDocument::GetEventTargetParent(EventCh
{
aVisitor.mCanHandle = true;
// FIXME! This is a hack to make middle mouse paste working also in Editor.
// Bug 329119
aVisitor.mForceContentDispatch = true;
// Load events must not propagate to |window| object, see bug 335251.
if (aVisitor.mEvent->mMessage != eLoad) {
- nsGlobalWindow* window = nsGlobalWindow::Cast(GetWindow());
- aVisitor.mParentTarget =
- window ? window->GetTargetForEventTargetChain() : nullptr;
+ nsPIDOMWindowInner* innerWindow = GetInnerWindow();
+ if (innerWindow && innerWindow->IsCurrentInnerWindow()) {
+ nsGlobalWindow* window = nsGlobalWindow::Cast(GetWindow());
+ aVisitor.mParentTarget =
+ window ? window->GetTargetForEventTargetChain() : nullptr;
+ }
}
return NS_OK;
}
NS_IMETHODIMP
nsDocument::CreateEvent(const nsAString& aEventType, nsIDOMEvent** aReturn)
{
NS_ENSURE_ARG_POINTER(aReturn);