| <p>This tests Selection::rangeCount. You should see "Hello World" selected below. You should not see any failures below.</p> | |
| <div id="div" contenteditable="true">Hello World</div> | |
| <ul id="console"></ul> | |
| <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 div = document.getElementById("div"); | |
| var text = div.firstChild; | |
| var sel = window.getSelection(); | |
| if (sel.rangeCount == undefined) { | |
| log("Selection::rangeCount not implemented."); | |
| return; | |
| } | |
| if (sel.rangeCount != 0) | |
| log("Failure. Expected: rangeCount == 0, Found: " + sel.rangeCount); | |
| sel.setPosition(text, 0); | |
| if (sel.rangeCount != 1) | |
| log("Failure. Expected: rangeCount == 1, Found: " + sel.rangeCount); | |
| document.execCommand("SelectAll"); | |
| if (sel.rangeCount != 1) | |
| log("Failure. Expected: rangeCount == 1, Found: " + sel.rangeCount); | |
| } catch(e) { | |
| log(e); | |
| } | |
| } | |
| runTest(); | |
| </script> |