Backed out changeset b4f1e88f8b6e (bug 1447196) for 2 failures in dom/events/test/pointerevents/test_bug1303704.html
authorMargareta Eliza Balazs <ebalazs@mozilla.com>
Fri, 23 Mar 2018 05:37:20 +0200
changeset 465722 7ce6b5f442f03c0f6fc886a8543ef823061c745b
parent 465721 366fd2db317e5a5243b8d82c49ec6e0df41b5805
child 465723 9cb650de48f9339b8b1499aeb9fe68f15f122aa2
child 465770 6e032627821402c26a1cacf6043ba48c260b409c
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1447196, 1303704
milestone61.0a1
backs outb4f1e88f8b6e7f15c37990722d7e8491a74b729f
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset b4f1e88f8b6e (bug 1447196) for 2 failures in dom/events/test/pointerevents/test_bug1303704.html
dom/events/PointerEventHandler.cpp
dom/events/test/pointerevents/test_bug1303704.html
widget/WidgetEventImpl.cpp
--- a/dom/events/PointerEventHandler.cpp
+++ b/dom/events/PointerEventHandler.cpp
@@ -383,17 +383,16 @@ PointerEventHandler::PreHandlePointerEve
     // In these cases, we could ignore them because they are not the events
     // between a DefaultPrevented pointerdown and the corresponding pointerup.
     return;
   }
   if (!pointerInfo->mPreventMouseEventByContent) {
     return;
   }
   aMouseOrTouchEvent->PreventDefault(false);
-  aMouseOrTouchEvent->mFlags.mOnlyChromeDispatch = true;
   if (aPointerEvent->mMessage == ePointerUp) {
     pointerInfo->mPreventMouseEventByContent = false;
   }
 }
 
 /* static */ void
 PointerEventHandler::PostHandlePointerEventsPreventDefault(
                        WidgetPointerEvent* aPointerEvent,
@@ -413,17 +412,16 @@ PointerEventHandler::PostHandlePointerEv
 #endif // #ifdef DEBUG
     return;
   }
   // PreventDefault only applied for active pointers.
   if (!pointerInfo->mActiveState) {
     return;
   }
   aMouseOrTouchEvent->PreventDefault(false);
-  aMouseOrTouchEvent->mFlags.mOnlyChromeDispatch = true;
   pointerInfo->mPreventMouseEventByContent = true;
 }
 
 /* static */ void
 PointerEventHandler::InitPointerEventFromMouse(
                        WidgetPointerEvent* aPointerEvent,
                        WidgetMouseEvent* aMouseEvent,
                        EventMessage aMessage)
--- a/dom/events/test/pointerevents/test_bug1303704.html
+++ b/dom/events/test/pointerevents/test_bug1303704.html
@@ -4,54 +4,21 @@
 https://bugzilla.mozilla.org/show_bug.cgi?id=1303704
 -->
 <head>
   <meta charset="utf-8">
   <title>Test for Bug 1303704</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-  <style>
-    #scrollable {
-      height: 100px;
-      width: 300px;
-      overflow-y: scroll;
-      margin-bottom: 50px;
-      scroll-behavior: auto;
-    }
-  </style>
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1303704">Mozilla Bug 1303704</a>
 <p id="display"></p>
 <a id="link1" href="http://www.google.com">Link 1</a>
-<div id="scrollable">
-<pre>
-scroll
-scroll
-scroll
-scroll
-scroll
-scroll
-scroll
-scroll
-scroll
-scroll
-scroll
-scroll
-scroll
-scroll
-scroll
-scroll
-scroll
-scroll
-scroll
-scroll
-</pre>
-</div>
 <script type="text/javascript">
 
 /** Test for Bug 1303704 **/
 SimpleTest.waitForExplicitFinish();
 
 function runTests() {
   let link1 = window.document.getElementById("link1");
   let mouseEvents = ["mousedown", "mouseup", "mousemove"];
@@ -64,60 +31,25 @@ function runTests() {
   mouseEvents.forEach((elm, index, arr) => {
     link1.addEventListener(elm, () => {
       ok(false, "Should not receive " + elm + " after preventDefault on pointerdown");
     });
   });
 
   link1.addEventListener("click", (e) => {
     e.preventDefault();
+    SimpleTest.finish();
   });
 
   synthesizeMouseAtCenter(link1, { type: "mousedown",
                                    inputSource: MouseEvent.MOZ_SOURCE_MOUSE });
   synthesizeMouseAtCenter(link1, { type: "mousemove",
                                    inputSource: MouseEvent.MOZ_SOURCE_MOUSE });
   synthesizeMouseAtCenter(link1, { type: "mouseup",
                                    inputSource: MouseEvent.MOZ_SOURCE_MOUSE });
-
-  if (navigator.userAgent.includes("Android") ||
-      navigator.userAgent.includes("Mac") ||
-      SpecialPowers.Cc["@mozilla.org/gfx/info;1"].
-        getService(SpecialPowers.Ci.nsIGfxInfo).isHeadless) {
-    SimpleTest.finish();
-    return;
-  }
-
-  var scrollable = document.getElementById("scrollable");
-  scrollable.addEventListener('pointerdown', function(ev) {
-    ev.preventDefault();
-  });
-  is(scrollable.scrollTop, 0,
-     "Scrollable element shouldn't be scrolled initially");
-  var rect = scrollable.getBoundingClientRect();
-  var offsetX = rect.width - 4;
-  var offsetY = rect.height - 4
-  synthesizeMouse(scrollable, offsetX, offsetY,
-                  { type: "mousedown",
-                    inputSource: MouseEvent.MOZ_SOURCE_MOUSE });
-
-  synthesizeMouse(scrollable, offsetX, offsetY,
-                  { type: "mousemove",
-                    inputSource: MouseEvent.MOZ_SOURCE_MOUSE });
-
-  synthesizeMouse(scrollable, offsetX, offsetY,
-                  { type: "mouseup",
-                    inputSource: MouseEvent.MOZ_SOURCE_MOUSE });
-  requestAnimationFrame(function() {
-    setTimeout(function() {
-      isnot(scrollable.scrollTop, 0,
-            "Scrollable element should have been scrolled.");
-      SimpleTest.finish();
-    });
-  });
 }
 
 SimpleTest.waitForFocus(() => {
   SpecialPowers.pushPrefEnv({"set": [["dom.w3c_pointer_events.enabled", true]]}, runTests);
 });
 
 </script>
 </body>
--- a/widget/WidgetEventImpl.cpp
+++ b/widget/WidgetEventImpl.cpp
@@ -454,16 +454,26 @@ WidgetEvent::IsTargetedAtFocusedContent(
          IsRetargetedNativeEventDelivererForPlugin();
 }
 
 bool
 WidgetEvent::IsAllowedToDispatchDOMEvent() const
 {
   switch (mClass) {
     case eMouseEventClass:
+      // When content PreventDefault on ePointerDown, we will stop dispatching
+      // the subsequent mouse events (eMouseDown, eMouseUp, eMouseMove). But we
+      // still need the mouse events to be handled in EventStateManager to
+      // generate other events (e.g. eMouseClick). So we only stop dispatching
+      // them to DOM.
+      if (DefaultPreventedByContent() &&
+          (mMessage == eMouseMove || mMessage == eMouseDown ||
+           mMessage == eMouseUp)) {
+        return false;
+      }
       if (mMessage == eMouseTouchDrag) {
         return false;
       }
       MOZ_FALLTHROUGH;
     case ePointerEventClass:
       // We want synthesized mouse moves to cause mouseover and mouseout
       // DOM events (EventStateManager::PreHandleEvent), but not mousemove
       // DOM events.