Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / Range / script-tests / range-insertNode-separate-endContainer.js
blob1afa86ce2052beb69c07a27369cf2e956cba2680
1 description('Test for proper behavior of Range.insertNode(documentFragment) when startContainer != endContainer');
3 var p = document.createElement('p');
4 var t1 = document.createTextNode('12345');
5 p.appendChild(t1);
6 var t2 = document.createTextNode('ABCDE');
7 p.appendChild(t2);
8 document.body.appendChild(p);
9 var r = document.createRange();
10 r.setStart(p, 1);
11 r.setEnd(t2, 3);
12 shouldBeEqualToString("r.toString()", "ABC");
14 var df = document.createDocumentFragment();
15 var t3 = document.createTextNode("PQR");
16 var t4 = document.createTextNode("XYZ");
17 df.appendChild(t3);
18 df.appendChild(t4);
19 r.insertNode(df);
21 shouldBe("p.childNodes.length", "4");
22 shouldBe("p.childNodes[0]", "t1");
23 shouldBe("p.childNodes[1]", "t3");
24 shouldBe("p.childNodes[2]", "t4");
25 shouldBe("p.childNodes[3]", "t2");
27 shouldBeFalse("r.collapsed");
28 shouldBe("r.commonAncestorContainer", "p");
29 shouldBe("r.startContainer", "p");
30 shouldBe("r.startOffset", "1");
31 shouldBe("r.endContainer", "t2");
32 shouldBe("r.endOffset", "3");
33 shouldBeEqualToString("r.toString()", "PQRXYZABC")
35 // clean up after ourselves
36 document.body.removeChild(p);