<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<script>
function runTest() {
    description('To manually verify the issue, place the caret somewhere in between the first line and then press the up arrow key. This should move the caret to the start of the first line. Next press the down arrow key. This should result in the caret being placed on the next line offset by an amount equivalent to the start "x" position of the caret on the previous line.\nSimilarly, forward caret movement too can be verified.');

    if (window.internals) {
        var selection = window.getSelection();

        selection.collapse(document.getElementById('second'), 1);
        selection.modify("move", "backward", "word");
        startCaretRectOnSecondLine = internals.absoluteCaretBounds(document);

        eventSender.keyDown("upArrow");
        eventSender.keyDown("upArrow");
        eventSender.keyDown("downArrow");        
        caretRectAfterDownArrowKey = internals.absoluteCaretBounds(document);
  
        shouldBe("caretRectAfterDownArrowKey.left", "startCaretRectOnSecondLine.left");
        shouldBe("caretRectAfterDownArrowKey.top", "startCaretRectOnSecondLine.top");

        selection.collapse(document.getElementById('first'), 1);
        for (i = 0; i < 3; i++)
            selection.modify("move", "backward", "word");
        startCaretRectOnFirstLine = internals.absoluteCaretBounds(document);

        eventSender.keyDown("downArrow");
        eventSender.keyDown("downArrow");
        eventSender.keyDown("upArrow");
        caretRectAfterUpArrowKey = internals.absoluteCaretBounds(document);
 
        shouldBe("caretRectAfterUpArrowKey.left", "startCaretRectOnFirstLine.left");
        shouldBe("caretRectAfterUpArrowKey.top", "startCaretRectOnFirstLine.top");

        document.getElementById('testDiv').style.display = 'none';
    }
}
</script>
</head>
<body onload="runTest();">
<div>When moving the caret up/down between lines, our editing behavior is similar to that of the text editors on various platforms such as mac, windows and linux. When no further up/down movement is possible, the caret is moved either to the start (for up) or end (for down) of the line. This should not reset the "x" co-ordinate maintained for the start caret position and moving the caret down from the start of a line (or vice-versa) should bring it to a position which is offset by this "x" amount on the adjacent line.</div><br>
<div contenteditable=true id="testDiv">
<p id="first">First text line for verifying editing behavior. Slightly longer.</p>
<p id="second">Second text line for verifying editing behavior.</p>
</div>
<div id="description"></div>
<div id="console"></div>
</body>
</html>
