2 <script src='../../../resources/js-test.js'
></script>
14 transform: rotate(
180deg);
24 /* Want this at a stable place across platforms so the output co-ords are stable */
33 <p id='description'
></p>
35 <iframe id=simpleFrame src='resources/frame-touchevent-forwarder.html'
></iframe>
36 <iframe id=rotatedFrame src='resources/frame-touchevent-forwarder.html'
></iframe>
37 <iframe id=scaledFrame src='resources/frame-touchevent-forwarder.html'
></iframe>
39 <div id='console'
></div>
40 <div id='spacer'
></div>
42 description('Tests non-integer TouchEvent co-ordinates and radii');
46 scrollTo(scrollX
, scrollY
);
49 function onTouchStart(e
) {
53 function expectEvent(eventName
) {
54 shouldBeEqualToNumber('eventCount', 1);
55 var origEventCount
= eventCount
;
57 if (origEventCount
> 0) {
58 shouldBeEqualToString('lastEvent.type', eventName
);
64 document
.addEventListener('touchstart', onTouchStart
);
65 var floatPrecision
= 0.00001;
69 debug('This test requires eventSender.');
73 debug('Testing simple fractional touch');
74 eventSender
.addTouchPoint(30.33, 4.5, 5.2, 6.3);
75 eventSender
.touchStart();
76 if (expectEvent('touchstart')) {
77 shouldBeCloseTo('lastEvent.changedTouches[0].screenX', 30.33, floatPrecision
);
78 shouldBeCloseTo('lastEvent.changedTouches[0].screenY', 4.5, floatPrecision
);
79 shouldBeCloseTo('lastEvent.changedTouches[0].clientX', 30.33, floatPrecision
);
80 shouldBeCloseTo('lastEvent.changedTouches[0].clientY', 4.5, floatPrecision
);
81 shouldBeCloseTo('lastEvent.changedTouches[0].pageX', 30.33 + scrollX
, floatPrecision
);
82 shouldBeCloseTo('lastEvent.changedTouches[0].pageY', 4.5 + scrollY
, floatPrecision
);
83 shouldBeCloseTo('lastEvent.changedTouches[0].radiusX', 5.2, floatPrecision
);
84 shouldBeCloseTo('lastEvent.changedTouches[0].radiusY', 6.3, floatPrecision
);
86 eventSender
.releaseTouchPoint(0);
87 eventSender
.touchEnd();
90 debug('Testing fractional touch inside simple iframe');
91 frameRect
= document
.getElementById('simpleFrame').getBoundingClientRect();
92 eventSender
.addTouchPoint(frameRect
.left
+ 4.5, frameRect
.top
+ 2.2);
93 eventSender
.touchStart();
94 if (expectEvent('touchstart')) {
95 shouldBeCloseTo('lastEvent.changedTouches[0].screenX', frameRect
.left
+ 4.5, floatPrecision
);
96 shouldBeCloseTo('lastEvent.changedTouches[0].screenY', frameRect
.top
+ 2.2, floatPrecision
);
97 shouldBeCloseTo('lastEvent.changedTouches[0].clientX', 4.5, floatPrecision
);
98 shouldBeCloseTo('lastEvent.changedTouches[0].clientY', 2.2, floatPrecision
);
99 shouldBeCloseTo('lastEvent.changedTouches[0].pageX', 4.5, floatPrecision
);
100 shouldBeCloseTo('lastEvent.changedTouches[0].pageY', 2.2, floatPrecision
);
102 eventSender
.releaseTouchPoint(0);
103 eventSender
.touchEnd();
106 debug('Testing fractional touch inside rotated iframe');
107 frameRect
= document
.getElementById('rotatedFrame').getBoundingClientRect();
108 eventSender
.addTouchPoint(frameRect
.left
+ 4.5, frameRect
.top
+ 2.2);
109 eventSender
.touchStart();
110 if (expectEvent('touchstart')) {
111 shouldBeCloseTo('lastEvent.changedTouches[0].screenX', frameRect
.left
+ 4.5, floatPrecision
);
112 shouldBeCloseTo('lastEvent.changedTouches[0].screenY', frameRect
.top
+ 2.2, floatPrecision
);
113 shouldBeCloseTo('lastEvent.changedTouches[0].clientX', 100 - 4.5, floatPrecision
);
114 shouldBeCloseTo('lastEvent.changedTouches[0].clientY', 100 - 2.2, floatPrecision
);
115 shouldBeCloseTo('lastEvent.changedTouches[0].pageX', 100 - 4.5, floatPrecision
);
116 shouldBeCloseTo('lastEvent.changedTouches[0].pageY', 100 - 2.2, floatPrecision
);
118 eventSender
.releaseTouchPoint(0);
119 eventSender
.touchEnd();
122 debug('Testing fractional touch inside scaled iframe');
123 frameRect
= document
.getElementById('scaledFrame').getBoundingClientRect();
124 eventSender
.addTouchPoint(frameRect
.left
+ 4.5, frameRect
.top
+ 2.2);
125 eventSender
.touchStart();
126 if (expectEvent('touchstart')) {
127 shouldBeCloseTo('lastEvent.changedTouches[0].screenX', frameRect
.left
+ 4.5, floatPrecision
);
128 shouldBeCloseTo('lastEvent.changedTouches[0].screenY', frameRect
.top
+ 2.2, floatPrecision
);
129 shouldBeCloseTo('lastEvent.changedTouches[0].clientX', 4.5 / 2, floatPrecision
);
130 shouldBeCloseTo('lastEvent.changedTouches[0].clientY', 2.2 / 2, floatPrecision
);
131 shouldBeCloseTo('lastEvent.changedTouches[0].pageX', 4.5 / 2, floatPrecision
);
132 shouldBeCloseTo('lastEvent.changedTouches[0].pageY', 2.2 / 2, floatPrecision
);
134 eventSender
.releaseTouchPoint(0);
135 eventSender
.touchEnd();
139 addEventListener('load', runTest
);