<!DOCTYPE html>
<html>
<body style="white-space: nowrap; margin:100px; border: solid 1px black;" contenteditable>
<span id="firstLine">Click on the right of this line outside the black box.</span><br>
<span id="longLine">The caret should be placed on the right of the first line, NOT on the right of this line.
<span></span></span>
<pre><script>

var longLine = document.getElementById('longLine');
while (longLine.offsetWidth < document.body.offsetWidth + 200)
    longLine.lastChild.textContent += ' some text';

if (window.testRunner) {
    testRunner.dumpAsText();

    var firstLine = document.getElementById('firstLine');
    eventSender.mouseMoveTo(firstLine.offsetLeft + document.body.offsetWidth + 10,
        firstLine.offsetTop + firstLine.offsetHeight / 2);
    eventSender.mouseDown();
    eventSender.mouseUp();

    if (!getSelection().isCollapsed)
        document.writeln('FAIL - selection was not collapsed');
    else if (getSelection().baseNode != firstLine.firstChild)
        document.writeln('FAIL - caret was not in the first line');
    else if (getSelection().baseOffset != firstLine.textContent.length)
        document.writeln('FAIL - caret was not on the right edge');
    else
        document.writeln('PASS');

    longLine.lastChild.style.display = 'none';
}

</script></pre>
</body>
</html>
