Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / selection / selectNodeContents.html
blobf367758a3f086103659531c57e4dbbf409282198
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);
12 </script>
13 <body>
14 <p>This tests Range.selectNodeContents() of a text node and a br.</p>
15 <div>one</div>
16 <div id=targetParent>two<br>three</div>
17 <div>four</div>
18 <ul id="console"></ul>
19 <script>
20 try {
21 textNode = targetParent.firstChild;
22 range = document.createRange();
23 range.selectNodeContents(textNode);
24 if (range.startContainer != textNode)
25 throw("range.startContainer != textNode");
26 if (range.endContainer != textNode)
27 throw("range.endContainer != textNode");
28 if (range.startOffset != 0)
29 throw("Incorrect startOffset in textNode.");
30 if (range.endOffset != 3)
31 throw("Incorrect endOffset in textNode.");
32 if (range.toString() != "two")
33 throw("Couldn't get the contents of a text node.");
35 brNode = textNode.nextSibling;
36 range.selectNodeContents(brNode);
37 if (range.startContainer != brNode)
38 throw("range.startContainer != brNode");
39 if (range.endContainer != brNode)
40 throw("range.endContainer != brNode");
41 if (range.startOffset != 0)
42 throw("Incorrect startOffset in br node.");
43 if (range.endOffset != 0)
44 throw("Incorrect endOffset in br node.");
45 if (range.toString() != "")
46 throw("Found br node with non-empty content.");
48 log("Success.");
49 } catch(e) {
50 log("Test Failed. Error was: " + e);
52 </script>
53 </body>