OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src='../../../resources/js-test.js'></script> |
| 3 <style> |
| 4 #spacer { |
| 5 height: 1000px; |
| 6 width: 1000px; |
| 7 } |
| 8 iframe { |
| 9 width: 100px; |
| 10 height: 100px; |
| 11 border: 0; |
| 12 } |
| 13 #rotatedFrame { |
| 14 transform: rotate(180deg); |
| 15 } |
| 16 #scaledFrame { |
| 17 transform: scale(2); |
| 18 width: 50px; |
| 19 height: 50px; |
| 20 margin-left: 50px; |
| 21 margin-bottom: 20px; |
| 22 } |
| 23 #container { |
| 24 /* Want this at a stable place across platforms so the output co-ords are stab
le */ |
| 25 position: absolute; |
| 26 top: 100px; |
| 27 left: 10px; |
| 28 } |
| 29 #console { |
| 30 margin-top: 200px; |
| 31 } |
| 32 </style> |
| 33 <p id='description'></p> |
| 34 <div id='container'> |
| 35 <iframe id=simpleFrame src='resources/frame-touchevent-forwarder.html'></ifram
e> |
| 36 <iframe id=rotatedFrame src='resources/frame-touchevent-forwarder.html'></ifra
me> |
| 37 <iframe id=scaledFrame src='resources/frame-touchevent-forwarder.html'></ifram
e> |
| 38 </div> |
| 39 <div id='console'></div> |
| 40 <div id='spacer'></div> |
| 41 <script> |
| 42 description('Tests non-integer TouchEvent co-ordinates and radii'); |
| 43 |
| 44 var scrollX = 3; |
| 45 var scrollY = 10; |
| 46 scrollTo(scrollX, scrollY); |
| 47 |
| 48 eventCount = 0; |
| 49 function onTouchStart(e) { |
| 50 eventCount++; |
| 51 lastEvent = e; |
| 52 } |
| 53 function expectEvent(eventName) { |
| 54 shouldBeEqualToNumber('eventCount', 1); |
| 55 var origEventCount = eventCount; |
| 56 eventCount = 0; |
| 57 if (origEventCount > 0) { |
| 58 shouldBeEqualToString('lastEvent.type', eventName); |
| 59 return true; |
| 60 } |
| 61 return false; |
| 62 } |
| 63 |
| 64 document.addEventListener('touchstart', onTouchStart); |
| 65 var floatPrecision = 0.00001; |
| 66 |
| 67 function runTest() { |
| 68 if (!eventSender) { |
| 69 debug('This test requires eventSender.'); |
| 70 return; |
| 71 } |
| 72 |
| 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, floatP
recision); |
| 78 shouldBeCloseTo('lastEvent.changedTouches[0].screenY', 4.5, floatPre
cision); |
| 79 shouldBeCloseTo('lastEvent.changedTouches[0].clientX', 30.33, floatP
recision); |
| 80 shouldBeCloseTo('lastEvent.changedTouches[0].clientY', 4.5, floatPre
cision); |
| 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].webkitRadiusX', 5.2, fl
oatPrecision); |
| 84 shouldBeCloseTo('lastEvent.changedTouches[0].webkitRadiusY', 6.3, fl
oatPrecision); |
| 85 } |
| 86 eventSender.releaseTouchPoint(0); |
| 87 eventSender.touchEnd(); |
| 88 debug(''); |
| 89 |
| 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.lef
t + 4.5, floatPrecision); |
| 96 shouldBeCloseTo('lastEvent.changedTouches[0].screenY', frameRect.top
+ 2.2, floatPrecision); |
| 97 shouldBeCloseTo('lastEvent.changedTouches[0].clientX', 4.5, floatPre
cision); |
| 98 shouldBeCloseTo('lastEvent.changedTouches[0].clientY', 2.2, floatPre
cision); |
| 99 shouldBeCloseTo('lastEvent.changedTouches[0].pageX', 4.5, floatPreci
sion); |
| 100 shouldBeCloseTo('lastEvent.changedTouches[0].pageY', 2.2, floatPreci
sion); |
| 101 } |
| 102 eventSender.releaseTouchPoint(0); |
| 103 eventSender.touchEnd(); |
| 104 debug(''); |
| 105 |
| 106 debug('Testing fractional touch inside rotated iframe'); |
| 107 frameRect = document.getElementById('rotatedFrame').getBoundingClientRec
t(); |
| 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.lef
t + 4.5, floatPrecision); |
| 112 shouldBeCloseTo('lastEvent.changedTouches[0].screenY', frameRect.top
+ 2.2, floatPrecision); |
| 113 shouldBeCloseTo('lastEvent.changedTouches[0].clientX', 100 - 4.5, fl
oatPrecision); |
| 114 shouldBeCloseTo('lastEvent.changedTouches[0].clientY', 100 - 2.2, fl
oatPrecision); |
| 115 shouldBeCloseTo('lastEvent.changedTouches[0].pageX', 100 - 4.5, floa
tPrecision); |
| 116 shouldBeCloseTo('lastEvent.changedTouches[0].pageY', 100 - 2.2, floa
tPrecision); |
| 117 } |
| 118 eventSender.releaseTouchPoint(0); |
| 119 eventSender.touchEnd(); |
| 120 debug(''); |
| 121 |
| 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.lef
t + 4.5, floatPrecision); |
| 128 shouldBeCloseTo('lastEvent.changedTouches[0].screenY', frameRect.top
+ 2.2, floatPrecision); |
| 129 shouldBeCloseTo('lastEvent.changedTouches[0].clientX', 4.5 / 2, floa
tPrecision); |
| 130 shouldBeCloseTo('lastEvent.changedTouches[0].clientY', 2.2 / 2, floa
tPrecision); |
| 131 shouldBeCloseTo('lastEvent.changedTouches[0].pageX', 4.5 / 2, floatP
recision); |
| 132 shouldBeCloseTo('lastEvent.changedTouches[0].pageY', 2.2 / 2, floatP
recision); |
| 133 } |
| 134 eventSender.releaseTouchPoint(0); |
| 135 eventSender.touchEnd(); |
| 136 debug(''); |
| 137 } |
| 138 |
| 139 addEventListener('load', runTest); |
| 140 </script> |
OLD | NEW |