• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<link rel="stylesheet" href="../../js/resources/js-test-style.css">
2<script src="../../js/resources/js-test-pre.js"></script>
3<style>
4    #pusher {
5        width: 1000px;
6        height: 1000px;
7        outline: 1px solid black;
8    }
9</style>
10<div id="console"></div>
11<div id="testArea">
12    <div id="pusher">This box is here to create scrollbars.</div>
13</div>
14<script src="../../js/resources/js-test-post-function.js"></script>
15<script>
16    var event;
17
18    function sendTouchStart(x, y)
19    {
20        if (window.eventSender) {
21            eventSender.clearTouchPoints();
22            eventSender.addTouchPoint(x, y);
23            eventSender.touchStart();
24        }
25    }
26
27    function zoomPageIn()
28    {
29        if (window.eventSender) {
30            eventSender.zoomPageIn();
31        }
32    }
33
34    function zoomPageOut()
35    {
36        if (window.eventSender) {
37            eventSender.zoomPageOut();
38        }
39    }
40
41    function scrollPage(x, y)
42    {
43        window.scrollTo(x, y);
44    }
45
46    if (window.layoutTestController) {
47        layoutTestController.dumpAsText();
48        layoutTestController.waitUntilDone();
49    }
50
51    // Default.
52    function base(e)
53    {
54        event = e;
55        debug("Base");
56        shouldBe("event.touches[0].clientX", "100");
57        shouldBe("event.touches[0].clientY", "100");
58        shouldBe("event.touches[0].pageX", "100");
59        shouldBe("event.touches[0].pageY", "100");
60    }
61
62    window.addEventListener("touchstart", base, false);
63
64    sendTouchStart(100, 100);
65    window.removeEventListener("touchstart", base, false);
66
67    // Just zoomed.
68    function justZoomed(e)
69    {
70        event = e;
71        debug("\nJust zoomed");
72        shouldBe("event.touches[0].clientX", "83");
73        shouldBe("event.touches[0].clientY", "83");
74        shouldBe("event.touches[0].pageX", "83");
75        shouldBe("event.touches[0].pageY", "83");
76    }
77    window.addEventListener("touchstart", justZoomed, false);
78    zoomPageIn();
79    sendTouchStart(100, 100);
80    zoomPageOut();
81    window.removeEventListener("touchstart", justZoomed, false);
82
83    // Just scrolled.
84    function justScrolled(e)
85    {
86        event = e;
87        debug("\nJust scrolled");
88        shouldBe("event.touches[0].clientX", "100");
89        shouldBe("event.touches[0].clientY", "100");
90        shouldBe("event.touches[0].pageX", "150");
91        shouldBe("event.touches[0].pageY", "150");
92    }
93    window.addEventListener("touchstart", justScrolled, false);
94    scrollPage(50, 50);
95    sendTouchStart(100, 100);
96    scrollPage(0, 0);
97    window.removeEventListener("touchstart", justScrolled, false);
98
99    // Zoomed and scrolled.
100    function zoomedAndScrolled(e)
101    {
102        event = e;
103        debug("\nZoomed and scrolled");
104        shouldBe("event.touches[0].clientX", "84");
105        shouldBe("event.touches[0].clientY", "84");
106        shouldBe("event.touches[0].pageX", "133");
107        shouldBe("event.touches[0].pageY", "133");
108    }
109    window.addEventListener("touchstart", zoomedAndScrolled, false);
110    zoomPageIn();
111    scrollPage(50, 50);
112    sendTouchStart(100, 100);
113    zoomPageOut();
114    scrollPage(0, 0);
115    window.removeEventListener("touchstart", zoomedAndScrolled, false);
116
117    if (window.eventSender) {
118        eventSender.touchEnd();
119        eventSender.clearTouchPoints();
120    }
121
122    if (window.layoutTestController) {
123        var area = document.getElementById('testArea');
124        area.parentNode.removeChild(area);
125        successfullyParsed = true;
126        isSuccessfullyParsed();
127        layoutTestController.notifyDone();
128    }
129</script>
130