| Index: LayoutTests/fast/events/touch/touch-fractional-coordinates.html
|
| diff --git a/LayoutTests/fast/events/touch/touch-fractional-coordinates.html b/LayoutTests/fast/events/touch/touch-fractional-coordinates.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..32d4d952955f4ca8b5bdf6b48254ff2ee595d99e
|
| --- /dev/null
|
| +++ b/LayoutTests/fast/events/touch/touch-fractional-coordinates.html
|
| @@ -0,0 +1,140 @@
|
| +<!DOCTYPE html>
|
| +<script src='../../../resources/js-test.js'></script>
|
| +<style>
|
| +#spacer {
|
| + height: 1000px;
|
| + width: 1000px;
|
| +}
|
| +iframe {
|
| + width: 100px;
|
| + height: 100px;
|
| + border: 0;
|
| +}
|
| +#rotatedFrame {
|
| + transform: rotate(180deg);
|
| +}
|
| +#scaledFrame {
|
| + transform: scale(2);
|
| + width: 50px;
|
| + height: 50px;
|
| + margin-left: 50px;
|
| + margin-bottom: 20px;
|
| +}
|
| +#container {
|
| + /* Want this at a stable place across platforms so the output co-ords are stable */
|
| + position: absolute;
|
| + top: 100px;
|
| + left: 10px;
|
| +}
|
| +#console {
|
| + margin-top: 200px;
|
| +}
|
| +</style>
|
| +<p id='description'></p>
|
| +<div id='container'>
|
| + <iframe id=simpleFrame src='resources/frame-touchevent-forwarder.html'></iframe>
|
| + <iframe id=rotatedFrame src='resources/frame-touchevent-forwarder.html'></iframe>
|
| + <iframe id=scaledFrame src='resources/frame-touchevent-forwarder.html'></iframe>
|
| +</div>
|
| +<div id='console'></div>
|
| +<div id='spacer'></div>
|
| +<script>
|
| + description('Tests non-integer TouchEvent co-ordinates and radii');
|
| +
|
| + var scrollX = 3;
|
| + var scrollY = 10;
|
| + scrollTo(scrollX, scrollY);
|
| +
|
| + eventCount = 0;
|
| + function onTouchStart(e) {
|
| + eventCount++;
|
| + lastEvent = e;
|
| + }
|
| + function expectEvent(eventName) {
|
| + shouldBeEqualToNumber('eventCount', 1);
|
| + var origEventCount = eventCount;
|
| + eventCount = 0;
|
| + if (origEventCount > 0) {
|
| + shouldBeEqualToString('lastEvent.type', eventName);
|
| + return true;
|
| + }
|
| + return false;
|
| + }
|
| +
|
| + document.addEventListener('touchstart', onTouchStart);
|
| + var floatPrecision = 0.00001;
|
| +
|
| + function runTest() {
|
| + if (!eventSender) {
|
| + debug('This test requires eventSender.');
|
| + return;
|
| + }
|
| +
|
| + debug('Testing simple fractional touch');
|
| + eventSender.addTouchPoint(30.33, 4.5, 5.2, 6.3);
|
| + eventSender.touchStart();
|
| + if (expectEvent('touchstart')) {
|
| + shouldBeCloseTo('lastEvent.changedTouches[0].screenX', 30.33, floatPrecision);
|
| + shouldBeCloseTo('lastEvent.changedTouches[0].screenY', 4.5, floatPrecision);
|
| + shouldBeCloseTo('lastEvent.changedTouches[0].clientX', 30.33, floatPrecision);
|
| + shouldBeCloseTo('lastEvent.changedTouches[0].clientY', 4.5, floatPrecision);
|
| + shouldBeCloseTo('lastEvent.changedTouches[0].pageX', 30.33 + scrollX, floatPrecision);
|
| + shouldBeCloseTo('lastEvent.changedTouches[0].pageY', 4.5 + scrollY, floatPrecision);
|
| + shouldBeCloseTo('lastEvent.changedTouches[0].webkitRadiusX', 5.2, floatPrecision);
|
| + shouldBeCloseTo('lastEvent.changedTouches[0].webkitRadiusY', 6.3, floatPrecision);
|
| + }
|
| + eventSender.releaseTouchPoint(0);
|
| + eventSender.touchEnd();
|
| + debug('');
|
| +
|
| + debug('Testing fractional touch inside simple iframe');
|
| + frameRect = document.getElementById('simpleFrame').getBoundingClientRect();
|
| + eventSender.addTouchPoint(frameRect.left + 4.5, frameRect.top + 2.2);
|
| + eventSender.touchStart();
|
| + if (expectEvent('touchstart')) {
|
| + shouldBeCloseTo('lastEvent.changedTouches[0].screenX', frameRect.left + 4.5, floatPrecision);
|
| + shouldBeCloseTo('lastEvent.changedTouches[0].screenY', frameRect.top + 2.2, floatPrecision);
|
| + shouldBeCloseTo('lastEvent.changedTouches[0].clientX', 4.5, floatPrecision);
|
| + shouldBeCloseTo('lastEvent.changedTouches[0].clientY', 2.2, floatPrecision);
|
| + shouldBeCloseTo('lastEvent.changedTouches[0].pageX', 4.5, floatPrecision);
|
| + shouldBeCloseTo('lastEvent.changedTouches[0].pageY', 2.2, floatPrecision);
|
| + }
|
| + eventSender.releaseTouchPoint(0);
|
| + eventSender.touchEnd();
|
| + debug('');
|
| +
|
| + debug('Testing fractional touch inside rotated iframe');
|
| + frameRect = document.getElementById('rotatedFrame').getBoundingClientRect();
|
| + eventSender.addTouchPoint(frameRect.left + 4.5, frameRect.top + 2.2);
|
| + eventSender.touchStart();
|
| + if (expectEvent('touchstart')) {
|
| + shouldBeCloseTo('lastEvent.changedTouches[0].screenX', frameRect.left + 4.5, floatPrecision);
|
| + shouldBeCloseTo('lastEvent.changedTouches[0].screenY', frameRect.top + 2.2, floatPrecision);
|
| + shouldBeCloseTo('lastEvent.changedTouches[0].clientX', 100 - 4.5, floatPrecision);
|
| + shouldBeCloseTo('lastEvent.changedTouches[0].clientY', 100 - 2.2, floatPrecision);
|
| + shouldBeCloseTo('lastEvent.changedTouches[0].pageX', 100 - 4.5, floatPrecision);
|
| + shouldBeCloseTo('lastEvent.changedTouches[0].pageY', 100 - 2.2, floatPrecision);
|
| + }
|
| + eventSender.releaseTouchPoint(0);
|
| + eventSender.touchEnd();
|
| + debug('');
|
| +
|
| + debug('Testing fractional touch inside scaled iframe');
|
| + frameRect = document.getElementById('scaledFrame').getBoundingClientRect();
|
| + eventSender.addTouchPoint(frameRect.left + 4.5, frameRect.top + 2.2);
|
| + eventSender.touchStart();
|
| + if (expectEvent('touchstart')) {
|
| + shouldBeCloseTo('lastEvent.changedTouches[0].screenX', frameRect.left + 4.5, floatPrecision);
|
| + shouldBeCloseTo('lastEvent.changedTouches[0].screenY', frameRect.top + 2.2, floatPrecision);
|
| + shouldBeCloseTo('lastEvent.changedTouches[0].clientX', 4.5 / 2, floatPrecision);
|
| + shouldBeCloseTo('lastEvent.changedTouches[0].clientY', 2.2 / 2, floatPrecision);
|
| + shouldBeCloseTo('lastEvent.changedTouches[0].pageX', 4.5 / 2, floatPrecision);
|
| + shouldBeCloseTo('lastEvent.changedTouches[0].pageY', 2.2 / 2, floatPrecision);
|
| + }
|
| + eventSender.releaseTouchPoint(0);
|
| + eventSender.touchEnd();
|
| + debug('');
|
| + }
|
| +
|
| + addEventListener('load', runTest);
|
| +</script>
|
|
|