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