blob: 26c025324e1a6cb31b057caf28c41df1c9ee5b01 [file] [log] [blame]
<!doctype HTML>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<p>This tests for a bug when moving the caret forward/backward by a
line/paragraph. The horizontal position of the caret would be lost when moving
the caret into an empty paragraph, when it should be preserved. The caret
should be between the first and second 'x's in the third paragraph.</p>
<div id="sample" contenteditable>
xxx<br>
xxx<br>
<br>
xxx<br id="afterAnchor">
</div>
<div id="log"></div>
<script>
test(function() {
var selection = window.getSelection();
var sample = document.getElementById('sample');
selection.collapse(sample, 0);
selection.modify('move', 'forward', 'character');
selection.modify('move', 'forward', 'line');
selection.modify('move', 'forward', 'line');
selection.modify('move', 'forward', 'line');
var anchor = document.getElementById('afterAnchor').previousSibling;
assert_equals(selection.anchorNode, anchor, 'anchorNode');
assert_equals(selection.anchorOffset, 2, 'anchorOffset');
assert_equals(selection.focusNode, anchor, 'focusNode');
assert_equals(selection.focusOffset, 2, 'focusOffset');
});
</script>