Missing cursor/caret showing in search field on google.com
[WebKit-https.git] / LayoutTests / editing / selection / character-granularity-rect.html
1 <!-- webkit-test-runner [ useCharacterSelectionGranularity=true ] -->
2 <meta name=viewport content="width=device-width">
3 <style>
4     #target {
5         height: 100px;
6         width: 200px;
7         background-color: silver;
8     }
9 </style>
10 <div id="target">
11         <p style="font-family: ahem;">PressMe</p>
12     This test requires UIScriptController to run.
13 </div>
14 <script>
15     if (window.testRunner) {
16         testRunner.dumpAsText();
17         testRunner.waitUntilDone();
18     }
19
20     function getUIScript()
21     {
22         return `
23         (function() {
24             uiController.longPressAtPoint(30, 20, function() {
25                 uiController.uiScriptComplete(JSON.stringify(uiController.textSelectionRangeRects));
26             });
27         })();`
28     }
29
30     function runTest()
31     {
32         if (!testRunner.runUIScript)
33             return;
34
35         var target = document.getElementById('target');
36         if (testRunner.runUIScript) {
37             testRunner.runUIScript(getUIScript(), function(result) {
38                 var textSelectionRangeRects = JSON.parse(result);
39                 var output;
40                 if (textSelectionRangeRects.length !== 1)
41                     output = 'FAIL: Unexpected number of selection range views: ' + result;
42                 else {
43                     var rect = textSelectionRangeRects[0];
44                     if (rect.left != 8 || rect.top != 8 || rect.width != 112 || rect.height != 17 )
45                         output = 'FAIL: Unexpected selection range view frame: ' + result;
46                     else
47                         output = 'PASS';
48                 }
49                 document.getElementById('target').innerText = output;
50                 testRunner.notifyDone();
51             });
52         }
53     }
54
55     runTest();
56 </script>