blob: 013619e897c4a35bb530a813550159041c3d29bf [file] [log] [blame]
<div>Test that Range manipulations work with ProcessingInstruction nodes.</div>
<script>
if (window.layoutTestController)
layoutTestController.dumpAsText();
function dumpRange(range) {
if (range.startContainer == range.endContainer)
return range.startContainer.nodeName + " " + range.startOffset + " - " + range.endOffset;
else
return range.startContainer.nodeName + " " + range.startOffset + " - " + range.endContainer.nodeName + " " + range.endOffset;
}
var docString = "<foo><" + "?pi SUCC_FAILURE_ESS?><" + "?pi SUCC_FAILURE_ESS?></foo>";
try {
var doc = (new DOMParser).parseFromString(docString, "application/xml");
var foo = doc.getElementsByTagName("foo")[0];
var range = doc.createRange();
range.setStart(foo.firstChild, 4);
range.setEnd(foo.firstChild, 13);
range.deleteContents();
document.write("Test 1: " + foo.firstChild.data);
} catch (ex) {
document.write("Test 1: " + ex);
}
document.write("<br>");
try {
var doc = (new DOMParser).parseFromString(docString, "application/xml");
var foo = doc.getElementsByTagName("foo")[0];
var range = doc.createRange();
range.setStart(foo.firstChild, 4);
range.setEnd(foo.firstChild.nextSibling, 13);
range.deleteContents();
document.write("Test 2: " + foo.firstChild.data + foo.firstChild.nextSibling.data);
} catch (ex) {
document.write("Test 2: " + ex);
}
document.write("<br>");
try {
var doc = (new DOMParser).parseFromString(docString, "application/xml");
var foo = doc.getElementsByTagName("foo")[0];
var range = doc.createRange();
range.setStart(foo, 0);
range.setEnd(foo.firstChild, 2);
var data1 = range.cloneContents().firstChild.data;
range.setStart(foo.firstChild, 2);
range.setEnd(foo.firstChild, 4);
var data2 = range.cloneContents().firstChild.data;
range.setStart(foo.firstChild.nextSibling, 13);
range.setEnd(foo, 2);
var data3 = range.cloneContents().firstChild.data;
document.write("Test 3: " + data1 + data2 + data3);
} catch (ex) {
document.write("Test 3: " + ex);
}
</script>