blob: ec7dfc9611d5dd4c5c5eebdbfcc7aaf58083f70e [file] [log] [blame]
<html>
<head>
<script src="../../../resources/js-test-pre.js"></script>
</head>
<body>
<script>
description('Test Range.insertNode(fragment) when the fragment is empty and the range is collapsed');
var p = document.createElement('p');
var t1 = document.createTextNode('12345');
p.appendChild(t1);
var t2 = document.createTextNode('ABCDE');
p.appendChild(t2);
document.body.appendChild(p);
var r = document.createRange();
r.setStart(p, 1);
r.setEnd(p, 1);
shouldBeEqualToString("r.toString()", "");
var df = document.createDocumentFragment();
r.insertNode(df);
shouldBe("p.childNodes.length", "2");
shouldBe("p.childNodes[0]", "t1");
shouldBe("p.childNodes[1]", "t2");
shouldBeTrue("r.collapsed");
shouldBe("r.startContainer", "p");
shouldBe("r.startOffset", "1");
shouldBe("r.endContainer", "p");
shouldBe("r.endOffset", "1");
shouldBeEqualToString("r.toString()", "")
document.body.removeChild(p);
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>