46d836c20c1d93b5018c2f5e306fae76248f2639
[WebKit-https.git] / LayoutTests / fast / events / touch / gesture / touch-gesture-scroll-page-not-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 ::-webkit-scrollbar {
9     width: 0px;
10     height: 0px;
11 }
12
13 #greenbox {
14   width: 100px;
15   height: 100px;
16   background: green;
17   padding: 0px;
18   margin: 0px;
19 }
20
21 #redbox {
22   width: 100px;
23   height: 100px;
24   background: red;
25   padding: 0px;
26   margin: 0px;
27 }
28
29 #bluebox {
30   width: 100px;
31   height: 100px;
32   background: blue;
33   padding: 0px;
34   margin: 0px;
35 }
36
37 #yellowbox {
38   width: 100px;
39   height: 100px;
40   background: yellow;
41   padding: 0px;
42   margin: 0px;
43 }
44
45 #touchtargetdiv {
46     width: 200px;
47     height: 200px;
48     overflow-y: scroll;
49     overflow-x: scroll;
50 }
51
52 td {
53   padding: 0px;
54 }
55 </style>
56 </head>
57 <body style="margin:0" onload="runTest();">
58
59 <div id="touchtargetdiv">
60   <table border="0" cellspacing="0px" >
61     <tr><td><div id="yellowbox"></div></td></tr>
62     <tr><td><div id="bluebox"></div></td></tr>
63     <tr><td><div id="yellowbox"></div></td></tr>
64     <tr><td><div id="bluebox"></div></td></tr>
65   </table>
66 </div>
67
68 <table id="table_to_fill" border="0" cellspacing="0px">
69   <tr><td><div id="greenbox"></div></td></tr>
70   <tr><td><div id="redbox"></div></td></tr>
71 </table>
72
73 <p id="description"></p>
74 <div id="console"></div>
75 <script type="text/javascript">
76
77 var touchtarget;
78 var expectedGesturesTotal = 2;
79 var gesturesOccurred = 0;
80 var scrollAmountX = ['0', '0'];
81 var scrollAmountY = ['0', '0'];
82 var wheelEventsOccurred = 0;
83 var expectedWheelEventsOccurred = ['0', '0'];
84 var scrollEventsOccurred = 0;
85 var scrolledElement = 'document.body'
86 var scrollEventsOccurred = 0;
87 var expectedScrollEventsOccurred = '1';
88
89 // Always construct a page larger than the vertical height of the window.
90 function buildPage()
91 {
92     var table = document.getElementById('table_to_fill');
93     var targetHeight = document.body.offsetHeight;
94     var cellPairHeight = table.offsetHeight;
95     var numberOfReps = targetHeight / cellPairHeight * 2;
96     var i;
97     for (i = 0; i < numberOfReps; i++) {
98         var p = document.createElement('tr');
99         p.innerHTML = '<td><div id="greenbox"></div></td>';
100         table.appendChild(p);
101         var p = document.createElement('tr');
102         p.innerHTML = '<td><div id="redbox"></div></td>';
103         table.appendChild(p);
104     }
105 }
106
107 function firstGestureScroll()
108 {
109     debug("first gesture");
110     eventSender.gestureScrollBegin(10, 72);
111     eventSender.gestureScrollUpdateWithoutPropagation(0, -110);
112     eventSender.gestureScrollEnd(0, 0);
113
114     // Wait for layout.
115     checkScrollOffset();
116 }
117
118 function secondGestureScroll()
119 {
120     debug("second gesture");
121     eventSender.gestureScrollBegin(12, 40);
122     eventSender.gestureScrollUpdateWithoutPropagation(0, -200);
123     eventSender.gestureScrollUpdateWithoutPropagation(0, -160);
124     eventSender.gestureScrollEnd(0, 0);
125
126     // Wait for layout.
127     checkScrollOffset();
128 }
129
130 if (window.testRunner)
131     testRunner.waitUntilDone();
132
133 function runTest()
134 {
135     buildPage();
136     touchtarget = document.getElementById('touchtargetdiv');
137     touchtarget.addEventListener("scroll", recordScroll);
138     touchtarget.addEventListener("mousewheel", recordWheel);
139
140     if (window.eventSender) {
141         description('This tests that a gesture scroll is not propagated from a div ' + 
142                 'to the page when the div has no remaining scroll offset when ' +
143                 'the GestureScrollUpdateWithoutPropagation event type is used.');
144         if (checkTestDependencies() && window.eventSender.gestureScrollUpdateWithoutPropagation)
145             firstGestureScroll();
146         else
147             exitIfNecessary();
148     } else {
149         debug("This test requires DumpRenderTree.  Gesture-scroll the page to validate the implementation.");
150     }
151 }
152 </script>
153
154
155
156 </body>
157 </html>