a8bbdee0b16234d6c593c33550297650e883aa91
[WebKit-https.git] / LayoutTests / fast / events / touch / gesture / touch-gesture-noscroll-body-propagated.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <link rel="stylesheet" href="../../../js/resources/js-test-style.css">
5 <script src="../../../js/resources/js-test-pre.js"></script>
6 <script src="resources/gesture-helpers.js"></script>
7 <style type="text/css">
8 #touchtarget {
9   width: 100px;
10   height: 100px;
11   background: white;
12   overflow:scroll;
13 }
14
15 ::-webkit-scrollbar {
16     width: 0px;
17     height: 0px;
18 }
19
20 #greenbox {
21   width: 100px;
22   height: 100px;
23   background: green;
24   padding: 0px;
25   margin: 0px;
26 }
27
28 #redbox {
29   width: 100px;
30   height: 100px;
31   background: red;
32   padding: 0px;
33   margin: 0px;
34 }
35
36 td {
37   padding: 0px;
38 }
39 </style>
40 </head>
41 <body style="margin:0; overflow-y:hidden;" onload="runTest();">
42
43 <div id="touchtarget">
44   <table border="0" cellspacing="0px" id="tablefoo">
45     <tr>
46       <td><div id="redbox"></div></td>
47       <td><div id="greenbox"></div></td>
48     </tr>
49     <tr>
50       <td><div id="greenbox"></div></td>
51       <td><div id="greenbox"></div></td>
52     </tr>
53   </table>
54 </div>
55
56 <table id="table_to_fill">
57     <tr><td><div id="greenbox"></div></td></tr>
58     <tr><td><div id="redbox"></div></td></tr>
59 </table>
60
61 <p id="description"></p>
62 <div id="console"></div>
63 <script type="text/javascript">
64
65 var expectedGesturesTotal = 2;
66 var gesturesOccurred = 0;
67 var scrollAmountX = ['0', '0'];
68 var scrollAmountY = ['0', '0'];
69 var wheelEventsOccurred = 0;
70 var expectedWheelEventsOccurred = ['0', '0'];
71 var scrollEventsOccurred = 0;
72 var expectedScrollEventsOccurred = '0';
73 var scrolledElement = 'document.body'
74
75 // Always construct a page larger than the vertical height of the window.
76 function buildPage()
77 {
78     var table = document.getElementById('table_to_fill');
79     var targetHeight = document.body.offsetHeight;
80     var cellPairHeight = table.offsetHeight;
81     var numberOfReps = targetHeight / cellPairHeight * 2;
82     var i;
83     for (i = 0; i < numberOfReps; i++) {
84         var p = document.createElement('tr');
85         p.innerHTML = '<td><div id="greenbox"></div></td>';
86         table.appendChild(p);
87         var p = document.createElement('tr');
88         p.innerHTML = '<td><div id="redbox"></div></td>';
89         table.appendChild(p);
90     }
91
92     window.addEventListener("scroll", recordScroll);
93     window.addEventListener("mousewheel", recordWheel);
94 }
95
96 function firstGestureScroll()
97 {
98     debug("first gesture");
99     eventSender.gestureScrollBegin(95, 12);
100     eventSender.gestureScrollUpdate(0, -100);
101     eventSender.gestureScrollUpdate(0, -10);
102     eventSender.gestureScrollEnd(0, 0);
103
104     // Wait for layout.
105     checkScrollOffset();
106 }
107
108 function secondGestureScroll()
109 {
110     debug("second gesture");
111     eventSender.gestureScrollBegin(12, 97);
112     eventSender.gestureScrollUpdate(0, -95);
113     eventSender.gestureScrollUpdate(0, -200);
114     eventSender.gestureScrollEnd(0, 0);
115
116     // Wait for layout.
117     checkScrollOffset();
118
119     // In this test we do not expect any scroll events to
120     // be received by the event listener, so we signal
121     // the end of the test by calling this function instead
122     // of relying on recordScroll() to do it.
123     finishTest();
124 }
125
126 if (window.testRunner)
127     testRunner.waitUntilDone();
128
129 function runTest()
130 {
131     buildPage();
132     if (window.eventSender) {
133         description('This tests that a page cannot be scrolled vertically with touch if its body has style overflow-y:hidden ' +
134                     'and the scroll event is propogated from a scrollable child div.');
135
136         if (checkTestDependencies())
137             firstGestureScroll();
138         else
139             exitIfNecessary();
140     } else {
141         debug("This test requires DumpRenderTree.  Touch scroll the red rect to log.");
142     }
143 }
144
145 function finishTest()
146 {
147     if (window.eventSender) {
148         if (gesturesOccurred == expectedGesturesTotal) {
149             shouldBe('scrollEventsOccurred', expectedScrollEventsOccurred);
150             successfullyParsed = true;
151             isSuccessfullyParsed();
152             if (window.testRunner)
153                 testRunner.notifyDone();
154         }
155     }
156 }
157 </script>
158 </body>
159 </html>