Bug 1304308: Investigate failure of test_pointerevent_setpointercapture_inactive_button_mouse-manual.html. r=masayuki
authorStone Shih <sshih@mozilla.com>
Tue, 24 Jan 2017 13:03:21 +0800
changeset 332324 d02bf33a50fb56f2714fc84c8d52443670d14a96
parent 332323 16560a1d12f154585269dc7e51ebbfd55921696b
child 332325 268fa5f3bc259f210dec6ac5fa6863c9f8add855
push id31303
push usercbook@mozilla.com
push dateFri, 03 Feb 2017 12:23:51 +0000
treeherdermozilla-central@28bb04d0338d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1304308
milestone54.0a1
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
Bug 1304308: Investigate failure of test_pointerevent_setpointercapture_inactive_button_mouse-manual.html. r=masayuki This test case should be triggered by pointerover and pointerout. Add new test API to fire mouse event at the specified position and refine the synthesized events fired to the test case to trigger it correctly. MozReview-Commit-ID: DkLYrD6MwYc
dom/events/test/pointerevents/mochitest.ini
dom/events/test/pointerevents/mochitest_support_external.js
dom/events/test/pointerevents/test_pointerevent_setpointercapture_inactive_button_mouse-manual.html
--- a/dom/events/test/pointerevents/mochitest.ini
+++ b/dom/events/test/pointerevents/mochitest.ini
@@ -77,17 +77,16 @@ support-files =
 [test_pointerevent_releasepointercapture_onpointerup_mouse-manual.html]
   support-files = pointerevent_releasepointercapture_onpointerup_mouse-manual.html
 [test_pointerevent_releasepointercapture_release_right_after_capture-manual.html]
   support-files = pointerevent_releasepointercapture_release_right_after_capture-manual.html
 [test_pointerevent_setpointercapture_disconnected-manual.html]
   support-files = pointerevent_setpointercapture_disconnected-manual.html
 [test_pointerevent_setpointercapture_inactive_button_mouse-manual.html]
   support-files = pointerevent_setpointercapture_inactive_button_mouse-manual.html
-  disabled = should be investigated
 [test_pointerevent_setpointercapture_invalid_pointerid-manual.html]
   support-files = pointerevent_setpointercapture_invalid_pointerid-manual.html
 [test_pointerevent_setpointercapture_override_pending_capture_element-manual.html]
   support-files = pointerevent_setpointercapture_override_pending_capture_element-manual.html
 [test_pointerevent_setpointercapture_relatedtarget-manual.html]
   support-files = pointerevent_setpointercapture_relatedtarget-manual.html
   disabled = should be investigated
 [test_pointerevent_setpointercapture_to_same_element_twice-manual.html]
--- a/dom/events/test/pointerevents/mochitest_support_external.js
+++ b/dom/events/test/pointerevents/mochitest_support_external.js
@@ -76,80 +76,91 @@ var MouseEventHelper = (function() {
     },
 
     checkExitState: function() {
       ok(!this.BUTTONS_STATE, "Mismatched mousedown/mouseup caught.");
     }
   };
 }) ();
 
+function createMouseEvent(aEventType, aParams) {
+  var eventObj = {type: aEventType};
+
+  // Default to mouse.
+  eventObj.inputSource =
+    (aParams && "inputSource" in aParams) ? aParams.inputSource :
+                                          MouseEvent.MOZ_SOURCE_MOUSE;
+  // Compute pointerId
+  eventObj.id =
+    (eventObj.inputSource === MouseEvent.MOZ_SOURCE_MOUSE) ? MouseEventHelper.MOUSE_ID :
+                                                             MouseEventHelper.PEN_ID;
+  // Check or generate a |button| value.
+  var isButtonEvent = aEventType === "mouseup" || aEventType === "mousedown";
+
+  // Set |button| to the default value first.
+  eventObj.button = isButtonEvent ? MouseEventHelper.BUTTON_LEFT
+                                  : MouseEventHelper.BUTTON_NONE;
+
+  // |button| is passed, use and check it.
+  if (aParams && "button" in aParams) {
+    var hasButtonValue = (aParams.button !== MouseEventHelper.BUTTON_NONE);
+    ok(!isButtonEvent || hasButtonValue,
+       "Inappropriate |button| value caught.");
+    eventObj.button = aParams.button;
+  }
+
+  // Generate a |buttons| value and update buttons state
+  var buttonsMask = MouseEventHelper.computeButtonsMaskFromButton(eventObj.button);
+  switch(aEventType) {
+    case "mousedown":
+      MouseEventHelper.BUTTONS_STATE |= buttonsMask; // Set button flag.
+      break;
+    case "mouseup":
+      MouseEventHelper.BUTTONS_STATE &= ~buttonsMask; // Clear button flag.
+      break;
+  }
+  eventObj.buttons = MouseEventHelper.BUTTONS_STATE;
+
+  // Replace the button value for mousemove events.
+  // Since in widget level design, even when no button is pressed at all, the
+  // value of WidgetMouseEvent.button is still 0, which is the same value as
+  // the one for mouse left button.
+  if (aEventType === "mousemove") {
+    eventObj.button = MouseEventHelper.BUTTON_LEFT;
+  }
+  return eventObj;
+}
+
 // Helper function to send MouseEvent with different parameters
 function sendMouseEvent(int_win, elemId, mouseEventType, params) {
   var elem = int_win.document.getElementById(elemId);
-  if(!!elem) {
+  if (elem) {
     var rect = elem.getBoundingClientRect();
-    var eventObj = {type: mouseEventType};
-
-    // Default to mouse.
-    eventObj.inputSource =
-      (params && "inputSource" in params) ? params.inputSource :
-                                            MouseEvent.MOZ_SOURCE_MOUSE;
-    // Compute pointerId
-    eventObj.id =
-      (eventObj.inputSource === MouseEvent.MOZ_SOURCE_MOUSE) ? MouseEventHelper.MOUSE_ID :
-                                                               MouseEventHelper.PEN_ID;
-    // Check or generate a |button| value.
-    var isButtonEvent = mouseEventType === "mouseup" ||
-                        mouseEventType === "mousedown";
-
-    // Set |button| to the default value first.
-    eventObj.button = isButtonEvent ? MouseEventHelper.BUTTON_LEFT
-                                    : MouseEventHelper.BUTTON_NONE;
-
-    // |button| is passed, use and check it.
-    if (params && "button" in params) {
-      var hasButtonValue = (params.button !== MouseEventHelper.BUTTON_NONE);
-      ok(!isButtonEvent || hasButtonValue,
-         "Inappropriate |button| value caught.");
-      eventObj.button = params.button;
-    }
-
-    // Generate a |buttons| value and update buttons state
-    var buttonsMask = MouseEventHelper.computeButtonsMaskFromButton(eventObj.button);
-    switch(mouseEventType) {
-      case "mousedown":
-        MouseEventHelper.BUTTONS_STATE |= buttonsMask; // Set button flag.
-        break;
-      case "mouseup":
-        MouseEventHelper.BUTTONS_STATE &= ~buttonsMask; // Clear button flag.
-        break;
-    }
-    eventObj.buttons = MouseEventHelper.BUTTONS_STATE;
-
-    // Replace the button value for mousemove events.
-    // Since in widget level design, even when no button is pressed at all, the
-    // value of WidgetMouseEvent.button is still 0, which is the same value as
-    // the one for mouse left button.
-    if (mouseEventType === "mousemove") {
-      eventObj.button = MouseEventHelper.BUTTON_LEFT;
-    }
+    var eventObj = createMouseEvent(mouseEventType, params);
 
     // Default to the center of the target element but we can still send to a
     // position outside of the target element.
     var offsetX = params && "offsetX" in params ? params.offsetX : rect.width / 2;
     var offsetY = params && "offsetY" in params ? params.offsetY : rect.height / 2;
 
     console.log(elemId, eventObj);
     synthesizeMouse(elem, offsetX, offsetY, eventObj, int_win);
 
   } else {
     is(!!elem, true, "Document should have element with id: " + elemId);
   }
 }
 
+// Helper function to send MouseEvent with position
+function sendMouseEventAtPoint(aWindow, aLeft, aTop, aMouseEventType, aParams) {
+  var eventObj = createMouseEvent(aMouseEventType, aParams);
+  console.log(eventObj);
+  synthesizeMouseAtPoint(aLeft, aTop, eventObj, aWindow);
+}
+
 // Touch Event Helper Object
 var TouchEventHelper = {
   // State
   TOUCH_ID: utils.DEFAULT_TOUCH_POINTER_ID,
   TOUCH_STATE: false,
 
   // Utils
   checkExitState: function() {
--- a/dom/events/test/pointerevents/test_pointerevent_setpointercapture_inactive_button_mouse-manual.html
+++ b/dom/events/test/pointerevents/test_pointerevent_setpointercapture_inactive_button_mouse-manual.html
@@ -12,17 +12,18 @@ https://bugzilla.mozilla.org/show_bug.cg
     <script type="text/javascript" src="mochitest_support_external.js"></script>
     <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     <script type="text/javascript">
       SimpleTest.waitForExplicitFinish();
       function startTest() {
         runTestInNewWindow("pointerevent_setpointercapture_inactive_button_mouse-manual.html");
       }
       function executeTest(int_win) {
-        sendMouseEvent(int_win, "target1", "mousemove");
-        sendMouseEvent(int_win, "target0", "mousemove");
-        sendMouseEvent(int_win, "target1", "mousemove");
+        let target0 = int_win.document.getElementById("target0");
+        let rect = target0.getBoundingClientRect();
+        sendMouseEventAtPoint(int_win, rect.left + 1, rect.top + 1, "mousemove");
+        sendMouseEventAtPoint(int_win, rect.left - 1, rect.top - 1, "mousemove");
       }
     </script>
   </head>
   <body>
   </body>
 </html>