Bug 1313170 - Ensure that the touchend events in helper_bug1162771 are sent with the correct coordinates. r?dvander draft
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 31 Oct 2016 10:05:18 -0400
changeset 431739 7ad2090067297b453de79f23c3589bb243a4df87
parent 431738 cb6356e71c6726f1778d38f5cfa7959388d64f6f
child 535456 156e5a2b5f72b2921b7d20e0e22288d7a6e18c24
push id34099
push userkgupta@mozilla.com
push dateMon, 31 Oct 2016 14:05:58 +0000
reviewersdvander
bugs1313170, 1162771
milestone52.0a1
Bug 1313170 - Ensure that the touchend events in helper_bug1162771 are sent with the correct coordinates. r?dvander The test in helper_bug1162771 dispatches a touchstart on an element, and then inside the touchstart handler makes that element display:none. It then sends a touchend at what should be the same position. However, since the position of the touch is calculated from the position of the element, the touchend position can be wrong because the element is set to display:none in between. This patch saves the position before sending the touchstart, and makes sure to use the same position for the touchend. MozReview-Commit-ID: GoyQvNJ1wRZ
gfx/layers/apz/test/mochitest/helper_bug1162771.html
--- a/gfx/layers/apz/test/mochitest/helper_bug1162771.html
+++ b/gfx/layers/apz/test/mochitest/helper_bug1162771.html
@@ -27,26 +27,31 @@ function* test(testDriver) {
   document.body.ontouchend = function(e) {
     if (e.target === v || e.target === a || e.target === d) {
       e.target._gotTouchend = true;
       ok(true, 'Got touchend event on #' + e.target.id);
     }
     testDriver();
   };
 
-  yield synthesizeNativeTouch(v, 25, 5, SpecialPowers.DOMWindowUtils.TOUCH_CONTACT);
-  yield synthesizeNativeTouch(v, 25, 5, SpecialPowers.DOMWindowUtils.TOUCH_REMOVE);
+  var utils = SpecialPowers.getDOMWindowUtils(window);
+
+  var pt = coordinatesRelativeToScreen(25, 5, v);
+  yield utils.sendNativeTouchPoint(0, SpecialPowers.DOMWindowUtils.TOUCH_CONTACT, pt.x, pt.y, 1, 90, null);
+  yield utils.sendNativeTouchPoint(0, SpecialPowers.DOMWindowUtils.TOUCH_REMOVE, pt.x, pt.y, 1, 90, null);
   ok(v._gotTouchend, 'Touchend was received on video element');
 
-  yield synthesizeNativeTouch(a, 5, 5, SpecialPowers.DOMWindowUtils.TOUCH_CONTACT);
-  yield synthesizeNativeTouch(a, 5, 5, SpecialPowers.DOMWindowUtils.TOUCH_REMOVE);
+  pt = coordinatesRelativeToScreen(25, 5, a);
+  yield utils.sendNativeTouchPoint(0, SpecialPowers.DOMWindowUtils.TOUCH_CONTACT, pt.x, pt.y, 1, 90, null);
+  yield utils.sendNativeTouchPoint(0, SpecialPowers.DOMWindowUtils.TOUCH_REMOVE, pt.x, pt.y, 1, 90, null);
   ok(a._gotTouchend, 'Touchend was received on audio element');
 
-  yield synthesizeNativeTouch(d, 5, 5, SpecialPowers.DOMWindowUtils.TOUCH_CONTACT);
-  yield synthesizeNativeTouch(d, 5, 5, SpecialPowers.DOMWindowUtils.TOUCH_REMOVE);
+  pt = coordinatesRelativeToScreen(25, 5, d);
+  yield utils.sendNativeTouchPoint(0, SpecialPowers.DOMWindowUtils.TOUCH_CONTACT, pt.x, pt.y, 1, 90, null);
+  yield utils.sendNativeTouchPoint(0, SpecialPowers.DOMWindowUtils.TOUCH_REMOVE, pt.x, pt.y, 1, 90, null);
   ok(d._gotTouchend, 'Touchend was received on div element');
 }
 
 waitUntilApzStable()
 .then(runContinuation(test))
 .then(subtestDone);
 
   </script>