Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / touch / gesture / touch-gesture-scroll-page.html
blobf09245e5bd17f4a0abd6a8ad92bf00931a2c4a2a
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 ::-webkit-scrollbar {
8 width: 0px;
9 height: 0px;
12 #greenbox {
13 width: 100px;
14 height: 100px;
15 background: green;
16 padding: 0px;
17 margin: 0px;
19 #redbox {
20 width: 100px;
21 height: 100px;
22 background: red;
23 padding: 0px;
24 margin: 0px;
27 td {
28 padding: 0px;
30 </style>
31 </head>
32 <body style="margin:0" onload="runTest();">
34 <table id="table_to_fill">
35 <tr><td><div id="greenbox"></div></td></tr>
36 <tr><td><div id="redbox"></div></td></tr>
37 </table>
39 <p id="description"></p>
40 <div id="console"></div>
41 <script type="text/javascript">
43 var expectedGesturesTotal = 2;
44 var gesturesOccurred = 0;
45 var scrollAmountX = ['0', '0'];
46 var scrollAmountY = ['70', '130'];
47 var wheelEventsOccurred = 0;
48 var expectedWheelEventsOccurred = ['0', '0'];
49 var scrollEventsOccurred = 0;
50 var scrolledElement = 'document.scrollingElement'
51 var scrollEventsOccurred = 0;
52 var expectedScrollEventsOccurred = '1';
54 function recordScroll(event) {
55 debug('scroll event ' + scrollEventsOccurred + '+> ' + event.target);
56 scrollEventsOccurred++;
58 if (window.eventSender) {
59 // Because scroll events arrive asynchronously, only one will arrive.
60 if (gesturesOccurred == expectedGesturesTotal) {
61 shouldBe('scrollEventsOccurred', expectedScrollEventsOccurred);
62 // If we've got here, we've passed.
63 successfullyParsed = true;
64 isSuccessfullyParsed();
65 if (window.testRunner)
66 testRunner.notifyDone();
71 // Always construct a page larger than the vertical height of the window.
72 function buildPage()
74 var table = document.getElementById('table_to_fill');
75 var targetHeight = document.body.offsetHeight;
76 var cellPairHeight = table.offsetHeight;
77 var numberOfReps = targetHeight / cellPairHeight * 2;
78 var i;
79 for (i = 0; i < numberOfReps; i++) {
80 var p = document.createElement('tr');
81 p.innerHTML = '<td><div id="greenbox"></div></td>';
82 table.appendChild(p);
83 var p = document.createElement('tr');
84 p.innerHTML = '<td><div id="redbox"></div></td>';
85 table.appendChild(p);
88 window.addEventListener("scroll", recordScroll);
89 window.addEventListener("mousewheel", recordWheel);
92 function firstGestureScroll()
94 debug("first gesture");
95 eventSender.gestureScrollBegin(10, 72);
96 eventSender.gestureScrollUpdate(0, -30);
97 eventSender.gestureScrollUpdate(0, -40);
98 eventSender.gestureScrollEnd(0, 0);
100 // Wait for layout.
101 checkScrollOffset();
104 function secondGestureScroll()
106 debug("second gesture");
107 eventSender.gestureScrollBegin(800, 40);
108 eventSender.gestureScrollUpdate(0, -30);
109 eventSender.gestureScrollUpdate(0, -30);
110 eventSender.gestureScrollEnd(0, 0);
112 // Wait for layout.
113 checkScrollOffset();
116 if (window.testRunner)
117 testRunner.waitUntilDone();
119 function runTest()
121 buildPage();
122 if (window.eventSender) {
123 description('This tests scroll gesture event scrolling on a whole page.');
124 if (checkTestDependencies())
125 firstGestureScroll();
126 else
127 exitIfNecessary();
128 } else {
129 debug("This test requires DumpRenderTree. Gesture-scroll the page to validate the implementation.");
132 </script>
136 </body>
137 </html>