Missing cursor/caret showing in search field on google.com
[WebKit-https.git] / LayoutTests / editing / selection / hit-test-anonymous.html
1 <head>
2 <style>
3 span:before {
4     content: "<before> ";
5 }
6 span:after {
7     content: " <after>";
8 }
9 </style>
10 <script>
11     function nodeAsString(node)
12     {
13         if (node && node.nodeType == Node.TEXT_NODE)
14             return "text in " + nodeAsString(node.parentNode);
15         if (node && node.nodeType == Node.ELEMENT_NODE) {
16             var id;
17             if (id = node.getAttribute("id"))
18                 return id;
19         }
20         return node;
21     }
22     function selectionAsString()
23     {
24         return "(" + nodeAsString(getSelection().anchorNode)
25             + ", " + getSelection().anchorOffset
26             + "), (" + nodeAsString(getSelection().focusNode)
27             + ", " + getSelection().focusOffset + ")";        
28     }
29     function checkSelection(step, expected)
30     {
31         if (selectionAsString() !== expected) {
32             document.getElementById("result").innerHTML = "FAIL: After step " + step + " selection was " + selectionAsString();
33             return true;
34         }
35         return false;
36     }
37     function runTest()
38     {
39         if (window.testRunner)
40             testRunner.dumpAsText();
41
42         var block = document.getElementById("block");
43         var x = block.offsetLeft + 5;
44         var y = block.offsetTop + 5;
45
46         if (window.eventSender) {
47             // Click in the anonymous content, check that cursor goes to
48             // the start of the span.
49             eventSender.mouseMoveTo(x, y);
50             eventSender.mouseDown();
51             eventSender.mouseUp();
52         }
53
54         if (checkSelection(1, "(text in span, 0), (text in span, 0)"))
55             return;
56
57         x = block.offsetLeft + 200;
58
59         if (window.eventSender) {
60             // Click in the regular text, make sure it goes into the span.
61             eventSender.mouseMoveTo(x, y);
62             eventSender.mouseDown();
63             eventSender.mouseUp();
64         }
65
66         if (checkSelection(2, "(text in span, 7), (text in span, 7)"))
67             return;
68
69         document.getElementById("result").innerHTML = "SUCCESS";
70     }
71 </script>
72 </head>
73 <body onload="runTest()">
74 <p>This tests clicking in anonymous content to see if a selection is successfully created.</p>
75 <p id="block" contentEditable style="border: 1px solid blue; font-size:30px"><span id="span">This is the selectable text.</span></div>
76 <p id="result">TEST DID NOT RUN</div>
77 </body>