Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / touch / touch-coords-in-zoom-and-scroll.html
blob4aabc58638242d7f2557514afddd8e1a4e44f955
1 <script src="../../../resources/js-test.js"></script>
2 <style>
3 #pusher {
4 width: 1000px;
5 height: 1000px;
6 outline: 1px solid black;
8 </style>
9 <div id="console"></div>
10 <div id="testArea">
11 <div id="pusher">This box is here to create scrollbars.</div>
12 </div>
13 <script>
14 var event;
15 var floatPrecision = 0.00001;
17 function sendTouchStart(x, y)
19 if (window.eventSender) {
20 eventSender.clearTouchPoints();
21 eventSender.addTouchPoint(x, y);
22 eventSender.touchStart();
26 function zoomPageIn()
28 if (window.eventSender) {
29 eventSender.zoomPageIn();
33 function zoomPageOut()
35 if (window.eventSender) {
36 eventSender.zoomPageOut();
40 function scrollPage(x, y)
42 window.scrollTo(x, y);
45 if (window.testRunner) {
46 testRunner.dumpAsText();
47 testRunner.waitUntilDone();
50 // Default.
51 function base(e)
53 event = e;
54 debug("Base");
55 shouldBe("event.touches[0].clientX", "100");
56 shouldBe("event.touches[0].clientY", "100");
57 shouldBe("event.touches[0].pageX", "100");
58 shouldBe("event.touches[0].pageY", "100");
61 window.addEventListener("touchstart", base, false);
63 sendTouchStart(100, 100);
64 window.removeEventListener("touchstart", base, false);
66 // Just zoomed.
67 function justZoomed(e)
69 event = e;
70 debug("\nJust zoomed");
71 shouldBeCloseTo("event.touches[0].clientX", 83.33333, floatPrecision);
72 shouldBeCloseTo("event.touches[0].clientY", 83.33333, floatPrecision);
73 shouldBeCloseTo("event.touches[0].pageX", 83.33333, floatPrecision);
74 shouldBeCloseTo("event.touches[0].pageY", 83.33333, floatPrecision);
76 window.addEventListener("touchstart", justZoomed, false);
77 zoomPageIn();
78 sendTouchStart(100, 100);
79 zoomPageOut();
80 window.removeEventListener("touchstart", justZoomed, false);
82 // Just scrolled.
83 function justScrolled(e)
85 event = e;
86 debug("\nJust scrolled");
87 shouldBe("event.touches[0].clientX", "100");
88 shouldBe("event.touches[0].clientY", "100");
89 shouldBe("event.touches[0].pageX", "150");
90 shouldBe("event.touches[0].pageY", "150");
92 window.addEventListener("touchstart", justScrolled, false);
93 scrollPage(50, 50);
94 sendTouchStart(100, 100);
95 scrollPage(0, 0);
96 window.removeEventListener("touchstart", justScrolled, false);
98 // Zoomed and scrolled.
99 function zoomedAndScrolled(e)
101 event = e;
102 debug("\nZoomed and scrolled");
103 shouldBeCloseTo("event.touches[0].clientX", 83.33333, floatPrecision);
104 shouldBeCloseTo("event.touches[0].clientY", 83.33333, floatPrecision);
105 shouldBeCloseTo("event.touches[0].pageX", 133.33333, floatPrecision);
106 shouldBeCloseTo("event.touches[0].pageY", 133.33333, floatPrecision);
108 window.addEventListener("touchstart", zoomedAndScrolled, false);
109 zoomPageIn();
110 scrollPage(50, 50);
111 sendTouchStart(100, 100);
112 zoomPageOut();
113 scrollPage(0, 0);
114 window.removeEventListener("touchstart", zoomedAndScrolled, false);
116 if (window.eventSender) {
117 eventSender.touchEnd();
118 eventSender.clearTouchPoints();
121 if (window.testRunner) {
122 var area = document.getElementById('testArea');
123 area.parentNode.removeChild(area);
124 isSuccessfullyParsed();
125 testRunner.notifyDone();
127 </script>