1 <!DOCTYPE html> 2 <html> 3 <body> 4 <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> 5 <textarea cols="20" rows="20"></textarea> 6 <button id="button" onclick="verify()">verify</button> 7 <div id="console"></div> 8 <script> 9 10 function verify() { 11 var console = document.getElementById('console'); 12 if (textarea.value.match(/[^\n]/)) 13 console.innerHTML = 'textarea contains unexpected character. You can only type LF in this test.'; 14 else if (textarea.selectionStart != textarea.value.length) 15 console.innerHTML = 'FAIL: expected ' + textarea.value.length + ' but got ' + textarea.selectionStart; 16 else 17 console.innerHTML = 'PASS: ' + textarea.value.length + ' LFs'; 18 } 19 20 var textarea = document.getElementsByTagName('textarea')[0]; 21 textarea.focus(); 22 23 </script> 24 </body> 25 </html> 26