<!DOCTYPE html>
<html>
<head>
<style>
#textDiv {
    height: 200px;
    width: 200px;
    border: 1px solid black;
    -webkit-writing-mode: vertical-rl;
}
</style>
<script src="../../resources/js-test-pre.js"></script>
<script>
function runTest() {
    description('Testcase for bug <a href="https://bugs.webkit.org/show_bug.cgi?id=106452">106452</a>:  Caret positioned at the end of a text line (followed by an empty block) in vertical writing mode disappears when pressing the right/down arrow key.\nTo manually verify the issue, place the caret at the end of the text line and then press either the down or the right arrow key.');

    if (window.internals) {
        var testDiv = document.getElementById('textDiv');

        eventSender.mouseMoveTo(testDiv.offsetLeft + testDiv.offsetWidth - 5, testDiv.offsetTop);
        eventSender.mouseDown();
        eventSender.mouseUp();
        caretRectAtStart = internals.absoluteCaretBounds(document);

        eventSender.mouseMoveTo(testDiv.offsetLeft + testDiv.offsetWidth - 5, testDiv.offsetTop + testDiv.offsetHeight - 5);
        eventSender.mouseDown();
        eventSender.mouseUp();
        caretRectAtEnd = internals.absoluteCaretBounds(document);

        eventSender.keyDown("rightArrow");
        caretRectRightKey = internals.absoluteCaretBounds(document);

        eventSender.keyDown("downArrow");
        caretRectDownKey = internals.absoluteCaretBounds(document);

        shouldBe("caretRectAtEnd.width", "caretRectAtStart.width");
        shouldBe("caretRectAtEnd.height", "caretRectAtStart.height");
        shouldBe("caretRectRightKey.width", "caretRectAtEnd.width");
        shouldBe("caretRectRightKey.height", "caretRectAtEnd.height");
        shouldBe("caretRectDownKey.width", "caretRectAtEnd.width");
        shouldBe("caretRectDownKey.height", "caretRectAtEnd.height");

        testDiv.style.display = 'none';
    }
}
</script>
</head>
<body onload="runTest();">
<div id="textDiv" contenteditable="true">Some text.<p></p></div>
<div id="description"></div>
<div id="console"></div>
</body>
</html>
