chromium/third_party/blink/web_tests/editing/selection/modify_move/move_forward_line_table_row.html

<!doctype html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<div id="sample" contenteditable>
<table border="1">
<tr><td id="one">one</td></tr>
<tr><td id="two"></td></tr>
<tr><td id="three">three</td></tr>
</table>
</div>
<div id="log"></div>
<script>
test(function() {
    var selection = window.getSelection();
    var start = document.getElementById('sample');
    selection.collapse(start, 1);
    selection.modify('move', 'forward', 'line');

    var anchor = document.getElementById('one').firstChild;
    assert_equals(selection.anchorNode, anchor, 'anchorNode');
    assert_equals(selection.anchorOffset, 0, 'anchorOffset');
    assert_equals(selection.focusNode, anchor, 'focusNode');
    assert_equals(selection.focusOffset, 0, 'focusOffset');
}, 'from outside of table');

test(function() {
    var selection = window.getSelection();
    var start = document.getElementById('one').firstChild;
    selection.collapse(start, 0);
    selection.modify('move', 'forward', 'line');

    var anchor = document.getElementById('two');
    assert_equals(selection.anchorNode, anchor, 'anchorNode');
    assert_equals(selection.anchorOffset, 0, 'anchorOffset');
    assert_equals(selection.focusNode, anchor, 'focusNode');
    assert_equals(selection.focusOffset, 0, 'focusOffset');
}, 'row to empty row');

test(function() {
    var selection = window.getSelection();
    var start = document.getElementById('two');
    selection.collapse(start, 0);
    selection.modify('move', 'forward', 'line');

    var anchor = document.getElementById('three').firstChild;
    assert_equals(selection.anchorNode, anchor, 'anchorNode');
    assert_equals(selection.anchorOffset, 0, 'anchorOffset');
    assert_equals(selection.focusNode, anchor, 'focusNode');
    assert_equals(selection.focusOffset, 0, 'focusOffset');
}, 'empty row to row');

test(function() {
    var selection = window.getSelection();
    var start = document.getElementById('three');
    selection.collapse(start, 0);
    selection.modify('move', 'forward', 'line');

    var anchor = document.getElementById('sample');
    assert_equals(selection.anchorNode, anchor, 'anchorNode');
    assert_equals(selection.anchorOffset, 2, 'anchorOffset');
    assert_equals(selection.focusNode, anchor, 'focusNode');
    assert_equals(selection.focusOffset, 2, 'focusOffset');
}, 'to outside table');
</script>