<!DOCTYPE html>
<html>
<head>
<script src="../../resources/ui-helper.js"></script>
<script>
async function test()
{
    if (window.testRunner)
        testRunner.dumpAsText();

    var ta = document.getElementById('ta')
    var res = document.getElementById('res');

    // Send caret to bottom of textarea
    ta.focus();
    ta.setSelectionRange(ta.value.length, ta.value.length);
    ta.blur();

    ta.focus();

    // click
    if (window.eventSender) {

        testRunner.waitUntilDone();
        await UIHelper.renderingUpdate();

        eventSender.mouseMoveTo(90, 20);
        eventSender.mouseDown();
        eventSender.mouseUp();

        if (ta.selectionEnd == 17)
            res.innerHTML = "Test Succeeded";
        else
            res.innerHTML = "Test Failed: caret is at " + ta.selectionEnd;

        testRunner.notifyDone();
    } else {
        res.innerHTML = "Test can't run without event sender (part of DumpRenderTree). "
            + "To test manually, click at the middle of the line marked 9 and check that the caret appears after the 9.";
    }
}
</script>
</head>
<body onload="test()">
<textarea id="ta">
1
2
3
4
5
6
7
8
9
10</textarea>
<div id="res"></div>
</body>
</html>