| <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.selectNode() 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 { |
| // selectNode of a text node |
| textNode = targetParent.firstChild; |
| range = document.createRange(); |
| range.selectNode(textNode); |
| if (range.startContainer != textNode.parentNode) |
| throw("range.startContainer != textNode.parentNode"); |
| if (range.endContainer != textNode.parentNode) |
| throw("range.endContainer != textNode.parentNode"); |
| if (range.startOffset != 0) |
| throw("Incorrect startOffset in div."); |
| if (range.endOffset != 1) |
| throw("Incorrect endOffset in div."); |
| if (range.toString() != "two") |
| throw("Couldn't get the contents of a text node."); |
| |
| brNode = textNode.nextSibling; |
| range.selectNode(brNode); |
| if (range.startContainer != brNode.parentNode) |
| throw("range.startContainer != brNode.parentNode"); |
| if (range.endContainer != brNode.parentNode) |
| throw("range.endContainer != brNode.parentNode"); |
| if (range.startOffset != 1) |
| throw("Incorrect startOffset in br node."); |
| if (range.endOffset != 2) |
| 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> |