Bug 1044586 - fix propagating document events to the window when the inner window has changed, r=smaug
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 30 Nov 2016 18:33:55 +0000
changeset 324870 512d5944a602d037a7c3455190a41f39aab37c9a
parent 324869 800a887c705e02042a53d9093e9c4feb4a4c97cb
child 324871 c396937ada0f756403e473b580c36a05eedf2231
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewerssmaug
bugs1044586
milestone53.0a1
Bug 1044586 - fix propagating document events to the window when the inner window has changed, r=smaug MozReview-Commit-ID: G6yPBwbITvG
dom/base/nsDocument.cpp
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -7615,19 +7615,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);