blob: 9c2aae0afa8863988e1c4fa96b62900ed2a2b33b [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)
window.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: The object is in the wrong document.";
if (e != expected)
log("Error. Exception thrown should have been: " + expected);
}
</script>