Missing cursor/caret showing in search field on google.com
[WebKit-https.git] / LayoutTests / editing / selection / toString.html
1 <script>
2 if (window.testRunner)
3      testRunner.dumpEditingCallbacks();
4 </script>
5 <script>
6 function log(str) {
7     var li = document.createElement("li");
8     li.appendChild(document.createTextNode(str));
9     var console = document.getElementById("console");
10     console.appendChild(li);
11 }
12
13 function runTest() {
14     try {
15         if (window.testRunner)
16             window.testRunner.dumpAsText();
17             
18         var selection = window.getSelection();
19         var element = document.getElementById("test");
20         
21         if (selection.setBaseAndExtent)
22             selection.setBaseAndExtent(element, 0, element, 1);
23         else if (selection.selectAllChildren)
24             selection.selectAllChildren(element);
25         else
26             throw("Couldn't set a selection.");
27         
28         if (selection.toString) {
29             var string = selection.toString();
30             if (string != selection)
31                 throw("Implicit toString call did not match explicit call");
32             if (string != "hello world")
33                 throw("Selection::toString() returned incorrect results.");
34             log("Success");
35         } else
36             throw("Selection::toString() not supported");
37     } catch(e) {
38         log("Test Failed.  Error was: " + e);
39     }
40 }
41 </script>
42 <body>
43 <p>This tests Selection::toString(): that it exists, that it returns the same result as the implicit toString call, and that it returns the correct results.</p>
44 <div id="test" style="border: 1px solid black;">hello world</div>
45 <ul id="console"></ul>
46 <script>runTest();</script>
47 </body>