chromium/third_party/blink/web_tests/fast/forms/textarea/onselect-textarea.html

<html>
<head>
<style>
textarea { -webkit-appearance: textarea;}
</style>
<script>
    function log(msg) {
        document.getElementById('res').innerHTML = document.getElementById('res').innerHTML + msg + "<br>";
    }
    
    function test() {
        if (window.testRunner)
            testRunner.dumpAsText();
        var ta = document.getElementById('ta');

        log('Calling focus on textarea');
        ta.focus();
        log('After focus: textarea selection start: ' + ta.selectionStart + ' end: ' + ta.selectionEnd + '<br>');

        log('Calling setSelectionRange on textarea');
        ta.setSelectionRange(5, 10);
        log('After setSelectionRange(5, 10): textarea selection start: ' + ta.selectionStart + ' end: ' + ta.selectionEnd + '<br>');

        log('Double clicking to make selection for textarea');
        if (window.eventSender) {           
            eventSender.mouseMoveTo(75, 55);
            eventSender.mouseDown();
            eventSender.mouseUp();
            eventSender.mouseDown();
            eventSender.mouseUp();
        }
        log('After double clicking: textarea selection start: ' + ta.selectionStart + ' end: ' + ta.selectionEnd + '<br>');

        log('Calling blur on textarea');
        ta.blur();
        log('After blur: textarea selection start: ' + ta.selectionStart + ' end: ' + ta.selectionEnd + '<br>');
    
        log('Calling focus on textarea');
        ta.focus();
        log('After focus: textarea selection start: ' + ta.selectionStart + ' end: ' + ta.selectionEnd);
    }
</script>
</head>
<body onload="test()">
<br>
This tests onSelect for textareas.  <br>
This also makes sure that the correct selection is restored when the element regains focus.<br><br>
<textarea id="ta" onselect="log('onselect fired for textarea');" style="position: absolute; top: 50; left: 10;">textarea with lots of fun content!</textarea>
<div id="res" style="position: absolute; top: 100; left: 10;"></div>
</body>
</html>