73fcbeb4a5877e6b7e87b4fcb9a84ee50104b66a
[WebKit-https.git] / LayoutTests / editing / selection / ios / selection-extends-into-overflow-area.html
1 <!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
2 <html>
3 <head>
4     <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no">
5     <title></title>
6     <style>
7         #editable {
8             width: 300px;
9             height: 300px;
10             border: 1px solid black;
11             font-family: monospace;
12             line-height: 1.5em;
13         }
14         
15         .output {
16             margin-left: 60px;
17         }
18     </style>
19     <script src="../../../resources/ui-helper.js"></script>
20     <script>
21         if (window.testRunner) {
22             testRunner.dumpAsText();
23             testRunner.waitUntilDone();
24         }
25
26         function selectTextAt(tapX, tapY)
27         {
28             return new Promise(resolve => {
29                 testRunner.runUIScript(`
30                     (function() {
31                         uiController.longPressAtPoint(${tapX}, ${tapY}, function() {
32                             uiController.uiScriptComplete("Done");
33                         });
34                     })();`, resolve);
35             });
36         }
37
38         function rectToString(rect)
39         {
40             return `(left = ${Math.round(rect.left)}, top = ${Math.round(rect.top)}, width = ${Math.round(rect.width)}, height = ${Math.round(rect.height)})`;
41         }
42
43         async function runTest()
44         {
45             let container = document.getElementById('editable');
46             await UIHelper.activateAndWaitForInputSessionAt(25, 25);
47
48             await selectTextAt(25, 400)
49             const selectionRects = await UIHelper.getUISelectionRects();
50             let rectsString = "";
51             for (let rect of selectionRects)
52                 rectsString += rectToString(rect) + ' ';
53
54             document.querySelector("#selection-rects").textContent = rectsString;
55             if (window.testRunner)
56                 testRunner.notifyDone();
57         }
58         
59         window.addEventListener('load', runTest, false);
60     </script>
61 </head>
62 <body>
63     <div id="editable" contenteditable>
64         line<br>
65         line<br>
66         line<br>
67         line<br>
68         line<br>
69         line<br>
70         line<br>
71         line<br>
72         line<br>
73         line<br>
74         line<br>
75         line<br>
76         line<br>
77         line<br>
78         line<br>
79         line<br>
80         line<br>
81         line<br>
82         line<br>
83         line<br>
84         line<br>
85         line<br>
86         line<br>
87         line<br>
88         line<br>
89         line<br>
90     </div>
91
92 <div class="output">Selection rects: <span id="selection-rects"></span></div>
93
94 </body>
95 </html>