<!DOCTYPE html>
<body>
<script src="../../../resources/js-test-pre.js"></script>
<script>

function newRange() {
	var range = document.createRange();
	range.selectNodeContents(iframe);
	return range;
}

function checkRange() {
	shouldBe("range.startContainer", "iframe.contentDocument.body");
	shouldBeTrue("range.collapsed");
}

description("Range set* functions should not throw WRONG_DOCUMENT_ERR.");
window.iframe = document.createElement("iframe");
document.body.appendChild(iframe);
iframe.contentDocument.write("<html><head><body>content</body></html>");

// Move range start to the iframe document. According to the DOM
// Range spec, this should collapse the Range to the new boundary.
// http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ranges.html#Level-2-Range-Changing
// http://www.w3.org/TR/dom/#interface-range

window.range = newRange();
shouldNotThrow("range.setStart(iframe.contentDocument.body, 0)");
checkRange();

window.range = newRange();
shouldNotThrow("range.setEnd(iframe.contentDocument.body, 0)");
checkRange();

window.range = newRange();
shouldNotThrow("range.setStartAfter(iframe.contentDocument.body.firstChild)");
checkRange();

window.range = newRange();
shouldNotThrow("range.setStartBefore(iframe.contentDocument.body.firstChild)");
checkRange();

window.range = newRange();
shouldNotThrow("range.setEndAfter(iframe.contentDocument.body.firstChild)");
checkRange();

window.range = newRange();
shouldNotThrow("range.setEndBefore(iframe.contentDocument.body.firstChild)");
checkRange();

iframe.parentNode.removeChild(iframe);
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>
