Move /platform/ios-simulator/accessibility tests to accessibility/ios-simulator/
[WebKit-https.git] / LayoutTests / platform / mac-wk2 / tiled-drawing / scrolling / fast-scroll-select-latched-select-with-handler.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 var wheelCount = 0;
31 function onScrollWheel(evt) {
32     wheelCount = wheelCount + 1;
33 }
34
35 function onLoad() {
36     document.addEventListener("mousewheel", onScrollWheel);
37     setupTopLevel();
38 }
39 </script>
40 </head>
41 <body onload="onLoad();">
42 <script>
43
44 var selectTarget;
45 var pageScrollPositionBefore;
46 var selectScrollPositionBefore;
47 var continueCount = 5;
48
49 function checkForScroll()
50 {
51     // The page should not have scrolled at all.
52     var pageScrollPositionAfter = document.body.scrollTop;
53     var selectScrollPositionAfter = selectTarget.scrollTop;
54
55     if (pageScrollPositionBefore != pageScrollPositionAfter)
56         testFailed("Page received wheel events.");
57     else
58         testPassed("Page did not receive wheel events.");
59
60     debug("Document was initial target for " + wheelCount + " of the wheel events.");
61
62     if (window.internals) {
63         document.getElementById('layers').innerText = internals.layerTreeAsText(document,
64             internals.LAYER_TREE_INCLUDES_VISIBLE_RECTS | internals.LAYER_TREE_INCLUDES_TILE_CACHES);
65     }
66
67     testRunner.notifyDone();
68 }
69
70 function scrollTest()
71 {
72     pageScrollPositionBefore = document.body.scrollTop;
73
74     selectTarget = document.getElementById('target');
75     selectTarget.scrollTop = selectTarget.scrollHeight - selectTarget.clientHeight - 100;
76
77     selectScrollPositionBefore = selectTarget.scrollTop;
78
79     // Scroll the #source until we reach the #target.
80     var startPosX = Math.round(selectTarget.offsetLeft) + 20;
81     debug("div display height = " + Math.round(selectTarget.clientHeight));
82     var startPosY = Math.round(selectTarget.offsetTop) + Math.round(selectTarget.clientHeight) - 42;
83     eventSender.mouseMoveTo(startPosX, startPosY);
84     debug("Mouse moved to (" + startPosX + ", " + startPosY + ")");
85     eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'began', 'none');
86     eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
87     eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'changed', 'none');
88     eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
89     eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'none', 'begin');
90     eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'none', 'continue');
91     eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'none', 'continue');
92     eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'none', 'continue');
93     eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'none', 'continue');
94     eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'none', 'end');
95     eventSender.callAfterScrollingCompletes(checkForScroll);
96 }
97
98 function setupTopLevel()
99 {
100     if (window.eventSender) {
101         testRunner.dumpAsText();
102         testRunner.waitUntilDone();
103
104         eventSender.monitorWheelEvents();
105         setTimeout(scrollTest, 0);
106     } else {
107         var messageLocation = document.getElementById('parent');
108         var message = document.createElement('div');
109         message.innerHTML = "<p>This test is better run under DumpRenderTree. To manually test it, place the mouse pointer<br/>"
110             + "inside the select box, and scroll near (but not AT) the bottom of the range. Use the mouse wheel or a two-finger<br/>"
111             + "swipe to scroll through the rest of the select options.<br/><br/>"
112             + "You should not see the page position change if this test is successful.</p>";
113         messageLocation.appendChild(message);
114     }
115 }
116
117 </script>
118 <div id="parent" style="height: 2000px; width: 2000px;">
119     <div id="source" style="height: 100px; width: 500px;">
120         Put mouse near the bottom of the select and scroll downwards.
121     </div>
122         <div class="scrollable_region">
123             <h3>Scrollable Select</h3>
124             <select id="target" class="scrollable_select" size="8">
125                 <option>content1</option>
126                 <option>content2</option>
127                 <option>content3</option>
128                 <option>content4</option>
129                 <option>content5</option>
130                 <option>content6</option>
131                 <option>content7</option>
132                 <option>content8</option>
133                 <option>content9</option>
134                 <option>content10</option>
135                 <option>content11</option>
136                 <option>content12</option>
137                 <option>content13</option>
138                 <option>content14</option>
139                 <option>content15</option>
140                 <option>content16</option>
141                 <option>content17</option>
142                 <option>content18</option>
143                 <option>content19</option>
144                 <option>content20</option>
145                 <option>content21</option>
146             </select>
147         </div>
148     </div>
149 </div>
150 <div id="console"></div>
151 <script>
152 description("Tests that a select doesn't pass wheel events to main frame when scrolling at bottom");
153 </script>
154 <pre id="layers">Layer tree goes here</p>
155 <script src="../../../../resources/js-test-post.js"></script>
156 </body>
157 </html>