| <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); | |
| } | |
| </script> | |
| <body> | |
| <p>This tests Range.selectNodeContents() of a text node and a br.</p> | |
| <div>one</div> | |
| <div id=targetParent>two<br>three</div> | |
| <div>four</div> | |
| <ul id="console"></ul> | |
| <script> | |
| try { | |
| textNode = targetParent.firstChild; | |
| range = document.createRange(); | |
| range.selectNodeContents(textNode); | |
| if (range.startContainer != textNode) | |
| throw("range.startContainer != textNode"); | |
| if (range.endContainer != textNode) | |
| throw("range.endContainer != textNode"); | |
| if (range.startOffset != 0) | |
| throw("Incorrect startOffset in textNode."); | |
| if (range.endOffset != 3) | |
| throw("Incorrect endOffset in textNode."); | |
| if (range.toString() != "two") | |
| throw("Couldn't get the contents of a text node."); | |
| brNode = textNode.nextSibling; | |
| range.selectNodeContents(brNode); | |
| if (range.startContainer != brNode) | |
| throw("range.startContainer != brNode"); | |
| if (range.endContainer != brNode) | |
| throw("range.endContainer != brNode"); | |
| if (range.startOffset != 0) | |
| throw("Incorrect startOffset in br node."); | |
| if (range.endOffset != 0) | |
| throw("Incorrect endOffset in br node."); | |
| if (range.toString() != "") | |
| throw("Found br node with non-empty content."); | |
| log("Success."); | |
| } catch(e) { | |
| log("Test Failed. Error was: " + e); | |
| } | |
| </script> | |
| </body> |