Move /platform/ios-simulator/accessibility tests to accessibility/ios-simulator/
[WebKit-https.git] / LayoutTests / tiled-drawing / scrolling / fast-scroll-mainframe-zoom.html
1 <!DOCTYPE html>
2 <html>
3     <head>
4         <script src="../../resources/js-test-pre.js" type="text/javascript"></script>
5     </head>
6     <body>
7         <script type="text/javascript">
8             var pageScrollPositionBefore;
9             var pageScrollHeightBefore;
10             var continueCount = 5;
11
12             function checkForScrollOffset()
13             {
14                 var pageScrollPositionAfter = document.body.scrollTop;
15                 var pageScrollHeightAfter = document.body.scrollHeight;
16
17                 if (pageScrollPositionAfter + 100 >= pageScrollPositionBefore)
18                     testFailed("Page did not properly handle rubber banding state.");
19                 else
20                     testPassed("Page properly handled rubber banding state.");
21
22                 testRunner.notifyDone();
23             }
24
25             var zoomOutCount = 0;
26             function zoomPageOut()
27             {
28                 if (!zoomOutCount) {
29                     pageScrollPositionBefore = document.body.scrollTop;
30                     pageScrollHeightBefore = document.body.scrollHeight;
31                 }
32
33                 eventSender.zoomPageOut();
34                 zoomOutCount = zoomOutCount + 1;
35                 if (zoomOutCount >= 2)
36                     setTimeout(checkForScrollOffset, 100);
37                 else
38                     setTimeout(zoomPageOut, 100);
39             }
40
41             function scrollDown()
42             {
43                 // Scroll the #source until we reach the #target.
44                 var selectTarget = document.getElementById('target');
45                 var startPosX = Math.round(selectTarget.offsetLeft) + 20;
46                 var startPosY = Math.round(selectTarget.offsetTop) - 42; // Slightly more than one wheel scroll away from the target div
47                 eventSender.mouseMoveTo(startPosX, startPosY); // Make sure we are just outside the target div
48                 eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -1, 'began', 'none', true);
49                 for (var i = 0; i < 40; ++i) {
50                     eventSender.mouseScrollByWithWheelAndMomentumPhases(0, -10, 'changed', 'none', true);
51                 }
52                 eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, 'ended', 'none');
53                  
54                 setTimeout(zoomPageOut, 700);
55             }
56
57             var zoomInCount = 0;
58             function zoomPageIn()
59             {
60                 eventSender.zoomPageIn();
61                 zoomInCount = zoomInCount + 1;
62                 if (zoomInCount >= 2)
63                     setTimeout(scrollDown, 100);
64                 else
65                     setTimeout(zoomPageIn, 100);
66             }
67
68             function startTest()
69             {
70                 if (window.eventSender) {
71                     testRunner.dumpAsText();
72                     testRunner.waitUntilDone();
73
74                     setTimeout(zoomPageIn, 0);
75                 } else {
76                     var messageLocation = document.getElementById('parent');
77                     var message = document.createElement('div');
78                     message.innerHTML = "<p>This test is better run under DumpRenderTree. To manually test it, place the mouse pointer<br/>"
79                         + "at the top of the page, perform two text zooms, scroll to the bottom of the page, then zoom back out.<br/>"
80                     + "The bottom of the test page should not be offset from the bottom of the web view.<\/p>";
81                     messageLocation.appendChild(message);
82                 }
83             }
84
85             window.addEventListener('load', startTest, false);
86         </script>
87         <div id="parent" style="height: 2000px;">
88             <div id="source" style="height: 100px">
89                 Put mouse here and do the following:
90                 <ol>
91                     <li>Perform two text zooms (in). (Command+ in Safari)</li>
92                     <li>Scroll down to the bottom. Be sure to scroll far enough that a rubberband animation is triggered.</li>
93                     <li>Perform two text zooms (out).  (Commmand- in Safari)</li>
94                 </ol>
95             </div>
96             <div id="target" style="height: 1000px; position: relative">
97                <div style="position: absolute; top: 0">TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP TOP</div>
98                <div style="position: absolute; bottom: 0">END END END END END END END END END END END END END</div>
99             </div>
100         </div>
101         <div id="console"></div><script type="text/javascript">
102             description("Tests that scroll dimensions return to correct size after rubber banding while zoomed.");
103         </script>
104         <div id="bottom">This should be at the very bottom of the page.</div>
105         <script src="../../resources/js-test-post.js" type="text/javascript"></script>
106     </body>
107 </html>