| <script> | |
| if (window.testRunner) | |
| testRunner.dumpEditingCallbacks(); | |
| </script> | |
| <script> | |
| function log(str) { | |
| var li = document.createElement("li"); | |
| li.appendChild(document.createTextNode(str)); | |
| var console = document.getElementById("console"); | |
| console.appendChild(li); | |
| } | |
| function runTest() { | |
| try { | |
| if (window.testRunner) | |
| window.testRunner.dumpAsText(); | |
| var selection = window.getSelection(); | |
| var element = document.getElementById("test"); | |
| if (selection.setBaseAndExtent) | |
| selection.setBaseAndExtent(element, 0, element, 1); | |
| else if (selection.selectAllChildren) | |
| selection.selectAllChildren(element); | |
| else | |
| throw("Couldn't set a selection."); | |
| if (selection.toString) { | |
| var string = selection.toString(); | |
| if (string != selection) | |
| throw("Implicit toString call did not match explicit call"); | |
| if (string != "hello world") | |
| throw("Selection::toString() returned incorrect results."); | |
| log("Success"); | |
| } else | |
| throw("Selection::toString() not supported"); | |
| } catch(e) { | |
| log("Test Failed. Error was: " + e); | |
| } | |
| } | |
| </script> | |
| <body> | |
| <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> | |
| <div id="test" style="border: 1px solid black;">hello world</div> | |
| <ul id="console"></ul> | |
| <script>runTest();</script> | |
| </body> |