textareaOffset = nodeIndex(textarea); textarea.setSelectionRange(0, 0); textarea.parentNode.removeChild(textarea); PASS getSelection().type is 'Caret' PASS getSelection().getRangeAt(0).startContainer is document.body PASS getSelection().getRangeAt(0).startOffset is textareaOffset PASS successfullyParsed is true TEST COMPLETE This tests to make sure that a selection inside a textarea is updated when the textarea is removed from the document.