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

--HG--
extra : rebase_source : 10fbd5d306aa36b46196758d672fce72347ca638
This commit is contained in:
Kartikaya Gupta 2016-10-31 10:05:18 -04:00
parent cb026d2536
commit 1320e96e69

View File

@ -32,16 +32,21 @@ function* test(testDriver) {
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');
}