blob: 7059a98b350761b00b22c133387cab81057bb5fd [file] [log] [blame] [edit]
<!DOCTYPE html>
<html>
<body>
<p>This tests to make sure that a selection inside a textarea is updated when the textarea is removed from the document.</p>
<textarea id="textarea"></textarea>
<script src="../../resources/js-test.js"></script>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
function nodeIndex(node) {
return Array.prototype.slice.call(node.parentNode.childNodes).indexOf(node);
}
window.onload = () => {
textarea = document.getElementById("textarea");
evalAndLog("textareaOffset = nodeIndex(textarea); textarea.focus(); textarea.setSelectionRange(0, 0); textarea.parentNode.removeChild(textarea);");
shouldBe("getSelection().type", "'Caret'");
shouldBe("getSelection().getRangeAt(0).startContainer", "document.body");
shouldBe("getSelection().getRangeAt(0).startOffset", "textareaOffset");
if (window.testRunner)
testRunner.notifyDone();
};
</script>
</body>
</html>