Bootlin logo

Elixir Cross Referencer

<!DOCTYPE html>
<p>This tests selectionStart is updated properly when inserting LF into textarea. To test, press Enter several times inside textarea and click the log button. This bug does not reproduce when new lines are added by execCommand or eventSender.</p>
<textarea cols="20" rows="20"></textarea>
<button id="button" onclick="verify()">verify</button>
<div id="console"></div>

function verify() {
    var console = document.getElementById('console');
    if (textarea.value.match(/[^\n]/))
        console.innerHTML = 'textarea contains unexpected character. You can only type LF in this test.';
    else if (textarea.selectionStart != textarea.value.length)
        console.innerHTML = 'FAIL: expected ' + textarea.value.length + ' but got ' + textarea.selectionStart;
        console.innerHTML = 'PASS: ' + textarea.value.length + ' LFs';

var textarea = document.getElementsByTagName('textarea')[0];