e883cb0358653674cac1c4ba71be16f4113b837e
[WebKit-https.git] / LayoutTests / fast / events / touch / touch-coords-in-zoom-and-scroll.html
1 <script src="../../js/resources/js-test-pre.js"></script>
2 <style>
3     #pusher {
4         width: 1000px;
5         height: 1000px;
6         outline: 1px solid black;
7     }
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
16     function sendTouchStart(x, y)
17     {
18         if (window.eventSender) {
19             eventSender.clearTouchPoints();
20             eventSender.addTouchPoint(x, y);
21             eventSender.touchStart();
22         }
23     }
24
25     function zoomPageIn()
26     {
27         if (window.eventSender) {
28             eventSender.zoomPageIn();
29         }
30     }
31
32     function zoomPageOut()
33     {
34         if (window.eventSender) {
35             eventSender.zoomPageOut();
36         }
37     }
38
39     function scrollPage(x, y)
40     {
41         window.scrollTo(x, y);
42     }
43
44     if (window.testRunner) {
45         testRunner.dumpAsText();
46         testRunner.waitUntilDone();
47     }
48
49     // Default.
50     function base(e)
51     {
52         event = e;
53         debug("Base");
54         shouldBe("event.touches[0].clientX", "100");
55         shouldBe("event.touches[0].clientY", "100");
56         shouldBe("event.touches[0].pageX", "100");
57         shouldBe("event.touches[0].pageY", "100");
58     }
59
60     window.addEventListener("touchstart", base, false);
61     
62     sendTouchStart(100, 100);
63     window.removeEventListener("touchstart", base, false);
64     
65     // Just zoomed.
66     function justZoomed(e)
67     {
68         event = e;
69         debug("\nJust zoomed");
70         shouldBe("event.touches[0].clientX", "83");
71         shouldBe("event.touches[0].clientY", "83");
72         shouldBe("event.touches[0].pageX", "83");
73         shouldBe("event.touches[0].pageY", "83");
74     }
75     window.addEventListener("touchstart", justZoomed, false);
76     zoomPageIn();
77     sendTouchStart(100, 100);
78     zoomPageOut();
79     window.removeEventListener("touchstart", justZoomed, false);
80
81     // Just scrolled.
82     function justScrolled(e)
83     {
84         event = e;
85         debug("\nJust scrolled");
86         shouldBe("event.touches[0].clientX", "100");
87         shouldBe("event.touches[0].clientY", "100");
88         shouldBe("event.touches[0].pageX", "150");
89         shouldBe("event.touches[0].pageY", "150");
90     }
91     window.addEventListener("touchstart", justScrolled, false);
92     scrollPage(50, 50);
93     sendTouchStart(100, 100);
94     scrollPage(0, 0);
95     window.removeEventListener("touchstart", justScrolled, false);
96
97     // Zoomed and scrolled.
98     function zoomedAndScrolled(e)
99     {
100         event = e;
101         debug("\nZoomed and scrolled");
102         shouldBe("event.touches[0].clientX", "84");
103         shouldBe("event.touches[0].clientY", "84");
104         shouldBe("event.touches[0].pageX", "133");
105         shouldBe("event.touches[0].pageY", "133");
106     }
107     window.addEventListener("touchstart", zoomedAndScrolled, false);
108     zoomPageIn();
109     scrollPage(50, 50);
110     sendTouchStart(100, 100);
111     zoomPageOut();
112     scrollPage(0, 0);
113     window.removeEventListener("touchstart", zoomedAndScrolled, false);
114
115     if (window.eventSender) {
116         eventSender.touchEnd();
117         eventSender.clearTouchPoints();
118     }
119     
120     if (window.testRunner) {
121         var area = document.getElementById('testArea');
122         area.parentNode.removeChild(area);
123         isSuccessfullyParsed();
124         testRunner.notifyDone();
125     }
126 </script>