<div>Test that Range manipulations work with ProcessingInstruction nodes.</div>
<script>
if (window.testRunner)
testRunner.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>