Move /platform/ios-simulator/accessibility tests to accessibility/ios-simulator/
[WebKit-https.git] / LayoutTests / tiled-drawing / scrolling / fast-scroll-select-latched-mainframe.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <style>
5 .scrollable_region {
6     width: 680px;
7 }
8
9 .table td, .table th {
10     padding: 2px;
11 }
12
13 .table th {
14     height: 20px;
15     text-align: left;
16     font-weight: strong;
17 }
18
19 .table tr:nth-child(odd) {
20     background: #f3f3f3;
21 }
22
23 .scrollable_select option:nth-child(odd) {
24     background: #f3f3f3;
25 }
26
27 </style>
28 <script src="../../resources/js-test-pre.js"></script>
29 <script>
30 function onLoad() {
31     window.addEventListener("scroll", onPageScroll);
32     setupTopLevel();
33 }
34 </script>
35 </head>
36 <body onload="onLoad();">
37 <script>
38
39 var selectTarget;
40 var pageScrollPositionBefore;
41 var selectScrollPositionBefore;
42 var continueCount = 5;
43
44 function onPageScroll()
45 {
46     if (document.body.scrollTop >= 70)
47         checkForScroll();
48 }
49
50 function checkForScroll()
51 {
52     // The select should not have scrolled at all.
53     var pageScrollPositionAfter = document.body.scrollTop;
54     var selectScrollPositionAfter = selectTarget.scrollTop;
55
56     if (selectScrollPositionBefore != selectScrollPositionAfter)
57         testFailed("Select consumed wheel events.");
58     else
59         testPassed("Select did not receive wheel events.");
60
61     if (window.internals) {
62         document.getElementById('layers').innerText = internals.layerTreeAsText(document,
63             internals.LAYER_TREE_INCLUDES_VISIBLE_RECTS | internals.LAYER_TREE_INCLUDES_TILE_CACHES);
64     }
65
66     testRunner.notifyDone();
67 }
68
69 function scrollTest()
70 {
71     pageScrollPositionBefore = document.body.scrollTop;
72
73     selectTarget = document.getElementById('target');
74
75     selectScrollPositionBefore = selectTarget.scrollTop;
76
77     // Scroll the #source until we reach the #target.
78     var startPosX = Math.round(selectTarget.offsetLeft) + 20;
79     var startPosY = Math.round(selectTarget.offsetTop) - 42;
80     eventSender.mouseMoveTo(startPosX, startPosY);
81     eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'began', 'none');
82     eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
83     eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
84     eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
85     eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'none', 'begin');
86     eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'none', 'continue');
87     eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'none', 'continue');
88     eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'none', 'continue');
89     eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'none', 'continue');
90     eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'none', 'end');
91     eventSender.callAfterScrollingCompletes(checkForScroll);
92
93     // We should finish via the scroll event; this will fire in the case of failure when the page doesn't scroll.
94 }
95
96 function setupTopLevel()
97 {
98     if (window.eventSender) {
99         testRunner.dumpAsText();
100         testRunner.waitUntilDone();
101
102         eventSender.monitorWheelEvents();
103         setTimeout(scrollTest, 0);
104     } else {
105         var messageLocation = document.getElementById('parent');
106         var message = document.createElement('div');
107         message.innerHTML = "<p>This test is better run under DumpRenderTree. To manually test it, place the mouse pointer<br/>"
108             + "at the top of the page, and then use the mouse wheel or a two-finger swipe to scroll down<br/>"
109             + "past the selectTarget.<br/><br/>"
110             + "You should not see the 'content21' label if this test is successful.</p>";
111         messageLocation.appendChild(message);
112     }
113 }
114
115 </script>
116 <div id="parent" style="height: 2000px; width: 2000px;">
117     <div id="source" style="height: 100px; width: 500px;">
118         Put mouse here and flick downwards
119     </div>
120         <div class="scrollable_region">
121             <h3>Scrollable Select</h3>
122             <select id="target" class="scrollable_select" size="8">
123                 <option>content1</option>
124                 <option>content2</option>
125                 <option>content3</option>
126                 <option>content4</option>
127                 <option>content5</option>
128                 <option>content6</option>
129                 <option>content7</option>
130                 <option>content8</option>
131                 <option>content9</option>
132                 <option>content10</option>
133                 <option>content11</option>
134                 <option>content12</option>
135                 <option>content13</option>
136                 <option>content14</option>
137                 <option>content15</option>
138                 <option>content16</option>
139                 <option>content17</option>
140                 <option>content18</option>
141                 <option>content19</option>
142                 <option>content20</option>
143                 <option>content21</option>
144             </select>
145         </div>
146     </div>
147 </div>
148 <div id="console"></div>
149 <script>
150 description("Tests that a select doesn't consume wheel events when scroll is latched to main frame.");
151 </script>
152 <pre id="layers">Layer tree goes here</p>
153 <script src="../../resources/js-test-post.js"></script>
154 </body>
155 </html>