Add a test for iOS arrow-key repeat
[WebKit-https.git] / LayoutTests / fast / events / ios / keyboard-scrolling-repeat.html
1 <!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
2
3 <html>
4
5 <head>
6     <script src="../../../resources/js-test-pre.js"></script>
7     <meta name="viewport" content="initial-scale=1.5, user-scalable=no">
8     <script id="ui-script" type="text/plain">
9         (function() {
10             // FIXME (151264): Need to tap to focus so that key events go through.
11             uiController.singleTapAtPoint(50, 25, function() {
12                 uiController.keyDownUsingHardwareKeyboard("downArrow", function() {
13                     uiController.didEndScrollingCallback = function() {
14                         uiController.uiScriptComplete();
15                     };
16                 });
17             });
18         })();
19     </script>
20
21     <script id="ui-script-waitforscroll" type="text/plain">
22         (function() {
23             uiController.didEndScrollingCallback = function() {
24                 uiController.uiScriptComplete();
25             };
26         })();
27     </script>
28
29     <script id="ui-script-keyup" type="text/plain">
30         (function() {
31             uiController.keyUpUsingHardwareKeyboard("downArrow", function() {
32                 uiController.uiScriptComplete();
33             });
34         })();
35     </script>
36
37     <script>
38         if (window.testRunner) {
39             testRunner.dumpAsText();
40             testRunner.waitUntilDone();
41         }
42
43         function getInitialUIScript()
44         {
45             return document.getElementById("ui-script").text;
46         }
47
48         function getWaitForScrollUIScript()
49         {
50             return document.getElementById("ui-script-waitforscroll").text;
51         }
52
53         function getKeyUpUIScript()
54         {
55             return document.getElementById("ui-script-keyup").text;
56         }
57
58         function runTest()
59         {
60             if (!window.testRunner || !testRunner.runUIScript)
61                 return;
62
63             debug("Before starting to hold the down arrow, window.scrollY = " + window.scrollY);
64             testRunner.runUIScript(getInitialUIScript(), function(result) {
65                 debug("After starting to hold the down arrow, window.scrollY = " + window.scrollY);
66                 testRunner.runUIScript(getWaitForScrollUIScript(), function(result) {
67                     debug("After continuing to hold the down arrow, window.scrollY = " + window.scrollY);
68                     testRunner.runUIScript(getKeyUpUIScript(), function(result) {
69                         testRunner.notifyDone();
70                     });
71                 });
72             });
73         }
74     </script>
75     <style>
76     #placeholder {
77         width: 100px;
78         height: 5000px;
79     }
80     </style>
81 </head>
82
83 <body style="margin: 0;" onload="runTest()">
84     <div id="placeholder">
85     <div id="console"></div>
86     <script src="../../../resources/js-test-post.js"></script>
87 </body>
88
89 </html>