Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / touch / gesture / touch-gesture-noscroll-body.html
blob54a500f005abd349e008a016c59f1e1a5a50c43e
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../../../resources/js-test.js"></script>
5 <script src="resources/gesture-helpers.js"></script>
6 <style type="text/css">
7 #touchtarget {
8 width: 100px;
9 height: 100px;
10 background: white;
11 overflow:hidden;
14 ::-webkit-scrollbar {
15 width: 0px;
16 height: 0px;
19 #greenbox {
20 width: 100px;
21 height: 100px;
22 background: green;
23 padding: 0px;
24 margin: 0px;
27 #redbox {
28 width: 100px;
29 height: 100px;
30 background: red;
31 padding: 0px;
32 margin: 0px;
35 td {
36 padding: 0px;
38 </style>
39 </head>
40 <body style="margin:0; overflow:hidden;" onload="runTest();">
42 <table id="horizontal_table_to_fill">
43 <tr id="firstrow">
44 <td><div id="redbox"></div></td>
45 <td><div id="greenbox"></div></td>
46 </tr>
47 </table>
49 <table id="vertical_table_to_fill">
50 <tr><td><div id="greenbox"></div></td></tr>
51 <tr><td><div id="redbox"></div></td></tr>
52 </table>
54 <p id="description"></p>
55 <div id="console"></div>
56 <script type="text/javascript">
58 var expectedGesturesTotal = 2;
59 var gesturesOccurred = 0;
60 var scrollAmountX = ['0', '0'];
61 var scrollAmountY = ['0', '0'];
62 var wheelEventsOccurred = 0;
63 var expectedWheelEventsOccurred = ['0', '0'];
64 var scrollEventsOccurred = 0;
65 var expectedScrollEventsOccurred = '0';
66 var scrolledElement = 'document.documentElement';
68 // Always construct a page larger than the vertical height of the window.
69 function buildPage()
71 // build vertical table
72 var table = document.getElementById('vertical_table_to_fill');
73 var targetHeight = document.body.offsetHeight;
74 var cellPairHeight = table.offsetHeight;
75 var numberOfReps = targetHeight / cellPairHeight * 2;
76 var i;
77 for (i = 0; i < numberOfReps; i++) {
78 var p = document.createElement('tr');
79 p.innerHTML = '<td><div id="greenbox"></div></td>';
80 table.appendChild(p);
81 var p = document.createElement('tr');
82 p.innerHTML = '<td><div id="redbox"></div></td>';
83 table.appendChild(p);
86 // build horizontal table
87 var horizontalTable = document.getElementById('horizontal_table_to_fill');
88 var tableRow = document.getElementById('firstrow');
89 var targetWidth = document.body.offsetWidth;
90 var cellPairWidth = horizontalTable.offsetWidth;
91 numberOfReps = targetWidth / cellPairWidth * 2;
92 for (i = 0; i < numberOfReps; i++) {
93 var p = document.createElement('td');
94 p.innerHTML = '<div id="redbox"></div>';
95 tableRow.appendChild(p);
96 var p = document.createElement('td');
97 p.innerHTML = '<div id="greenbox"></div>';
98 tableRow.appendChild(p);
101 window.addEventListener("scroll", recordScroll);
102 window.addEventListener("mousewheel", recordWheel);
105 function firstGestureScroll()
107 debug("first gesture");
108 eventSender.gestureScrollBegin(95, 12);
109 eventSender.gestureScrollUpdate(-55, -110);
110 eventSender.gestureScrollEnd(0, 0);
112 // Wait for layout.
113 checkScrollOffset();
116 function secondGestureScroll()
118 debug("second gesture");
119 eventSender.gestureScrollBegin(12, 97);
120 eventSender.gestureScrollUpdate(-42, -95);
121 eventSender.gestureScrollEnd(0, 0);
123 // Wait for layout.
124 checkScrollOffset();
126 // In this test we do not expect any scroll events to
127 // be received by the event listener, so we signal
128 // the end of the test by calling this function instead
129 // of relying on recordScroll() to do it.
130 finishTest();
133 if (window.testRunner)
134 testRunner.waitUntilDone();
136 function runTest()
138 buildPage();
139 if (window.eventSender) {
140 description('This tests that a page cannot be scrolled with touch if its body has style overflow:hidden.');
142 if (checkTestDependencies())
143 firstGestureScroll();
144 else
145 exitIfNecessary();
146 } else {
147 debug("This test requires DumpRenderTree. Touch scroll the red rect to log.");
151 function finishTest()
153 if (window.eventSender) {
154 if (gesturesOccurred == expectedGesturesTotal) {
155 shouldBe('scrollEventsOccurred', expectedScrollEventsOccurred);
156 successfullyParsed = true;
157 isSuccessfullyParsed();
158 if (window.testRunner)
159 testRunner.notifyDone();
163 </script>
164 </body>
165 </html>