<!DOCTYPE html>
<html>
<body>
<div id="description">This tests that clicking below a line of editable RTL text correctly places the caret at the end. To run manually, click within the box below but below the text. The caret should appear on the left side of the text.</div>
<div contentEditable="true" dir="rtl" style="height: 3em; border: solid" id="container"><span>&#x05d0;</span><span>&#x05d1;</span><span id="last">&#x05d2;</span></div>
<div id="result"></div>
</body>
<script>
function test() {
    if (!window.testRunner)
        return;
    testRunner.dumpAsText();
    var result = document.getElementById("result");
    var container = document.getElementById("container");
    var middleX = container.offsetLeft + (container.offsetWidth / 2);
    eventSender.mouseMoveTo(middleX, container.offsetTop + container.offsetHeight - 10);
    eventSender.mouseDown();
    eventSender.leapForward(500);
    eventSender.mouseUp();
    var sel = window.getSelection();
    if (sel.anchorNode == document.getElementById("last").firstChild && sel.anchorOffset == 1)
        result.innerText = "PASS";
    else
        result.innerText = "FAIL";
}

test();
</script>
</html>
