OLD | NEW |
1 <script src="../../../resources/js-test.js"></script> | 1 <script src="../../../resources/js-test.js"></script> |
2 <style> | 2 <style> |
3 #pusher { | 3 #pusher { |
4 width: 1000px; | 4 width: 1000px; |
5 height: 1000px; | 5 height: 1000px; |
6 outline: 1px solid black; | 6 outline: 1px solid black; |
7 } | 7 } |
8 </style> | 8 </style> |
9 <div id="console"></div> | 9 <div id="console"></div> |
10 <div id="testArea"> | 10 <div id="testArea"> |
11 <div id="pusher">This box is here to create scrollbars.</div> | 11 <div id="pusher">This box is here to create scrollbars.</div> |
12 </div> | 12 </div> |
13 <script> | 13 <script> |
14 var event; | 14 var event; |
| 15 var floatPrecision = 0.00001; |
15 | 16 |
16 function sendTouchStart(x, y) | 17 function sendTouchStart(x, y) |
17 { | 18 { |
18 if (window.eventSender) { | 19 if (window.eventSender) { |
19 eventSender.clearTouchPoints(); | 20 eventSender.clearTouchPoints(); |
20 eventSender.addTouchPoint(x, y); | 21 eventSender.addTouchPoint(x, y); |
21 eventSender.touchStart(); | 22 eventSender.touchStart(); |
22 } | 23 } |
23 } | 24 } |
24 | 25 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 window.addEventListener("touchstart", base, false); | 61 window.addEventListener("touchstart", base, false); |
61 | 62 |
62 sendTouchStart(100, 100); | 63 sendTouchStart(100, 100); |
63 window.removeEventListener("touchstart", base, false); | 64 window.removeEventListener("touchstart", base, false); |
64 | 65 |
65 // Just zoomed. | 66 // Just zoomed. |
66 function justZoomed(e) | 67 function justZoomed(e) |
67 { | 68 { |
68 event = e; | 69 event = e; |
69 debug("\nJust zoomed"); | 70 debug("\nJust zoomed"); |
70 shouldBe("event.touches[0].clientX", "83"); | 71 shouldBeCloseTo("event.touches[0].clientX", 83.33333, floatPrecision); |
71 shouldBe("event.touches[0].clientY", "83"); | 72 shouldBeCloseTo("event.touches[0].clientY", 83.33333, floatPrecision); |
72 shouldBe("event.touches[0].pageX", "83"); | 73 shouldBeCloseTo("event.touches[0].pageX", 83.33333, floatPrecision); |
73 shouldBe("event.touches[0].pageY", "83"); | 74 shouldBeCloseTo("event.touches[0].pageY", 83.33333, floatPrecision); |
74 } | 75 } |
75 window.addEventListener("touchstart", justZoomed, false); | 76 window.addEventListener("touchstart", justZoomed, false); |
76 zoomPageIn(); | 77 zoomPageIn(); |
77 sendTouchStart(100, 100); | 78 sendTouchStart(100, 100); |
78 zoomPageOut(); | 79 zoomPageOut(); |
79 window.removeEventListener("touchstart", justZoomed, false); | 80 window.removeEventListener("touchstart", justZoomed, false); |
80 | 81 |
81 // Just scrolled. | 82 // Just scrolled. |
82 function justScrolled(e) | 83 function justScrolled(e) |
83 { | 84 { |
84 event = e; | 85 event = e; |
85 debug("\nJust scrolled"); | 86 debug("\nJust scrolled"); |
86 shouldBe("event.touches[0].clientX", "100"); | 87 shouldBe("event.touches[0].clientX", "100"); |
87 shouldBe("event.touches[0].clientY", "100"); | 88 shouldBe("event.touches[0].clientY", "100"); |
88 shouldBe("event.touches[0].pageX", "150"); | 89 shouldBe("event.touches[0].pageX", "150"); |
89 shouldBe("event.touches[0].pageY", "150"); | 90 shouldBe("event.touches[0].pageY", "150"); |
90 } | 91 } |
91 window.addEventListener("touchstart", justScrolled, false); | 92 window.addEventListener("touchstart", justScrolled, false); |
92 scrollPage(50, 50); | 93 scrollPage(50, 50); |
93 sendTouchStart(100, 100); | 94 sendTouchStart(100, 100); |
94 scrollPage(0, 0); | 95 scrollPage(0, 0); |
95 window.removeEventListener("touchstart", justScrolled, false); | 96 window.removeEventListener("touchstart", justScrolled, false); |
96 | 97 |
97 // Zoomed and scrolled. | 98 // Zoomed and scrolled. |
98 function zoomedAndScrolled(e) | 99 function zoomedAndScrolled(e) |
99 { | 100 { |
100 event = e; | 101 event = e; |
101 debug("\nZoomed and scrolled"); | 102 debug("\nZoomed and scrolled"); |
102 shouldBe("event.touches[0].clientX", "84"); | 103 shouldBeCloseTo("event.touches[0].clientX", 83.33333, floatPrecision); |
103 shouldBe("event.touches[0].clientY", "84"); | 104 shouldBeCloseTo("event.touches[0].clientY", 83.33333, floatPrecision); |
104 shouldBe("event.touches[0].pageX", "133"); | 105 shouldBeCloseTo("event.touches[0].pageX", 133.33333, floatPrecision); |
105 shouldBe("event.touches[0].pageY", "133"); | 106 shouldBeCloseTo("event.touches[0].pageY", 133.33333, floatPrecision); |
106 } | 107 } |
107 window.addEventListener("touchstart", zoomedAndScrolled, false); | 108 window.addEventListener("touchstart", zoomedAndScrolled, false); |
108 zoomPageIn(); | 109 zoomPageIn(); |
109 scrollPage(50, 50); | 110 scrollPage(50, 50); |
110 sendTouchStart(100, 100); | 111 sendTouchStart(100, 100); |
111 zoomPageOut(); | 112 zoomPageOut(); |
112 scrollPage(0, 0); | 113 scrollPage(0, 0); |
113 window.removeEventListener("touchstart", zoomedAndScrolled, false); | 114 window.removeEventListener("touchstart", zoomedAndScrolled, false); |
114 | 115 |
115 if (window.eventSender) { | 116 if (window.eventSender) { |
116 eventSender.touchEnd(); | 117 eventSender.touchEnd(); |
117 eventSender.clearTouchPoints(); | 118 eventSender.clearTouchPoints(); |
118 } | 119 } |
119 | 120 |
120 if (window.testRunner) { | 121 if (window.testRunner) { |
121 var area = document.getElementById('testArea'); | 122 var area = document.getElementById('testArea'); |
122 area.parentNode.removeChild(area); | 123 area.parentNode.removeChild(area); |
123 isSuccessfullyParsed(); | 124 isSuccessfullyParsed(); |
124 testRunner.notifyDone(); | 125 testRunner.notifyDone(); |
125 } | 126 } |
126 </script> | 127 </script> |
OLD | NEW |