8f4d1bf2fd9d451e756d7706a57bd4ddaf8fccaf
[WebKit-https.git] / LayoutTests / platform / mac-wk2 / tiled-drawing / fast-scroll-div-latched-div-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 divTarget;
45 var pageScrollPositionBefore;
46 var divScrollPositionBefore;
47 var continueCount = 5;
48
49 function checkForScroll() {
50
51     // The div should not have scrolled at all.
52     var pageScrollPositionAfter = document.body.scrollTop;
53     var divScrollPositionAfter = divTarget.scrollTop;
54
55     debug("Page before: " + pageScrollPositionBefore + ", div before: " + divScrollPositionBefore);
56     debug("Page after:  " + pageScrollPositionAfter + ", div after: " + divScrollPositionAfter);
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     divTarget = document.getElementById('target');
78     divTarget.scrollTop = divTarget.scrollHeight - divTarget.clientHeight - 100;
79
80     divScrollPositionBefore = divTarget.scrollTop;
81
82     // Scroll the #source until we reach the #target.
83     var startPosX = Math.round(divTarget.offsetLeft) + 20;
84     debug("div display height = " + Math.round(divTarget.clientHeight));
85     var startPosY = Math.round(divTarget.offsetTop) + Math.round(divTarget.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             + "at the top of the page, and then use the mouse wheel or a two-finger swipe to scroll the<br/>"
113             + "down past the div.<br/><br/>"
114             + "You should not see the row of END labels 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 Region</h3>
126         <div id="target" style='overflow-y: auto; overflow-x: hidden; max-height: 485px;'>
127             <table class="table" style='width: 99%'>
128                 <tr><th>Count</th><th>DATA</th><th>Rev Count</th></tr>
129                 <tr><td>TOP TOP TOP TOP TOP</td><td>TOP TOP TOP TOP TOP</td><td>TOP TOP TOP TOP TOP</td></tr>
130                 <tr><td>1</td><td>0.1100</td><td>40</td></tr>
131                 <tr><td>2</td><td>0.1155</td><td>39</td></tr>
132                 <tr><td>3</td><td>0.2200</td><td>38</td></tr>
133                 <tr><td>4</td><td>0.2255</td><td>37</td></tr>
134                 <tr><td>5</td><td>0.3300</td><td>36</td></tr>
135                 <tr><td>6</td><td>0.3355</td><td>35</td></tr>
136                 <tr><td>7</td><td>0.4400</td><td>34</td></tr>
137                 <tr><td>8</td><td>0.4455</td><td>33</td></tr>
138                 <tr><td>9</td><td>0.5500</td><td>32</td></tr>
139                 <tr><td>10</td><td>0.5555</td><td>31</td></tr>
140                 <tr><td>11</td><td>0.6600</td><td>30</td></tr>
141                 <tr><td>12</td><td>0.6655</td><td>29</td></tr>
142                 <tr><td>13</td><td>0.7700</td><td>28</td></tr>
143                 <tr><td>14</td><td>0.7755</td><td>27</td></tr>
144                 <tr><td>15</td><td>0.8800</td><td>26</td></tr>
145                 <tr><td>16</td><td>0.8855</td><td>25</td></tr>
146                 <tr><td>17</td><td>0.9900</td><td>24</td></tr>
147                 <tr><td>18</td><td>0.9955</td><td>23</td></tr>
148                 <tr><td>19</td><td>0.9999</td><td>22</td></tr>
149                 <tr><td>20</td><td>1.0000</td><td>21</td></tr>
150                 <tr><td>21</td><td>1.0000</td><td>20</td></tr>
151                 <tr><td>22</td><td>0.9999</td><td>19</td></tr>
152                 <tr><td>23</td><td>0.9955</td><td>18</td></tr>
153                 <tr><td>24</td><td>0.9900</td><td>17</td></tr>
154                 <tr><td>25</td><td>0.8855</td><td>16</td></tr>
155                 <tr><td>26</td><td>0.8800</td><td>15</td></tr>
156                 <tr><td>27</td><td>0.7755</td><td>14</td></tr>
157                 <tr><td>28</td><td>0.7700</td><td>13</td></tr>
158                 <tr><td>29</td><td>0.6655</td><td>12</td></tr>
159                 <tr><td>30</td><td>0.6600</td><td>11</td></tr>
160                 <tr><td>31</td><td>0.5555</td><td>10</td></tr>
161                 <tr><td>32</td><td>0.5500</td><td>9</td></tr>
162                 <tr><td>33</td><td>0.4455</td><td>8</td></tr>
163                 <tr><td>34</td><td>0.4400</td><td>7</td></tr>
164                 <tr><td>35</td><td>0.3355</td><td>6</td></tr>
165                 <tr><td>36</td><td>0.3300</td><td>5</td></tr>
166                 <tr><td>37</td><td>0.2255</td><td>4</td></tr>
167                 <tr><td>38</td><td>0.2200</td><td>3</td></tr>
168                 <tr><td>39</td><td>0.1155</td><td>2</td></tr>
169                 <tr><td>40</td><td>0.1100</td><td>1</td></tr>
170                 <tr><td>END END END END END</td><td>END END END END END</td><td>END END END END END</td></tr>
171             </table>
172         </div>
173     </div>
174 </div>
175 <div id="console"></div>
176 <script>
177 description("Tests that a scrollable div doesn't pass wheel events to main frame when scrolling at bottom");
178 </script>
179 <pre id="layers">Layer tree goes here</p>
180 <script src="../../../resources/js-test-post.js"></script>
181 </body>
182 </html>