blob: 28abb2da54bea401303b8b87989ea12ac439e88f [file] [log] [blame]
<p>This tests to see that Range::compareBoundaryPoints throws a WrongDocumentError exception if the two ranges are in different documents, or if one is detached.</p>
<div id="div" contenteditable="true">dog<a href="http://www.google.com/">food</a></div>
<ul id="console"></ul>
<script>
function log(str) {
var console = document.getElementById("console");
var li = document.createElement("li");
li.appendChild(document.createTextNode(str));
console.appendChild(li);
}
if (window.testRunner)
testRunner.dumpAsText();
var div = document.getElementById("div");
var text = div.firstChild;
var link = div.lastChild;
div.focus();
text.parentNode.removeChild(text);
var r1 = document.createRange();
r1.setStart(link, 0);
r1.setEnd(link, 0);
var r2 = document.createRange();
r2.setStart(text, 0);
r2.setEnd(text, 0);
try {
var compare = r1.compareBoundaryPoints(Range.START_TO_START, r2);
log("Error. compareBoundaryPoints should have thrown an exception.");
} catch (e) {
var expected = "WrongDocumentError: Failed to execute 'compareBoundaryPoints' on 'Range': The source range is in a different document than this range.";
if (e != expected)
log("Error. Exception thrown should have been: " + expected);
}
</script>