chromium/third_party/blink/web_tests/editing/selection/modify-up-on-rtl-wrapping-text.html

<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
// This tests clicking on the left of RTL text puts the caret at the end of the
// line.
const kStyle = [
    'font-family: monospace;',
    'width: 2ch',
].join(' ');

// 2 lines
selection_test(
    [
        `<div contenteditable dir="rtl" style="${kStyle}">`,
            '<bdo dir="rtl">A BC|</bdo>',
        '</div>',
    ],
    selection => selection.modify('move', 'backward', 'line'),
    [
        `<div contenteditable dir="rtl" style="${kStyle}">`,
            '<bdo dir="rtl">A| BC</bdo>',
        '</div>',
    ], '2 lines');

// 3 lines
selection_test(
    [
        `<div contenteditable dir="rtl" style="${kStyle}">`,
            '<bdo dir="rtl">A BC DE|</bdo>',
        '</div>',
    ],
    selection => selection.modify('move', 'backward', 'line'),
    [
        `<div contenteditable dir="rtl" style="${kStyle}">`,
            '<bdo dir="rtl">A BC| DE</bdo>',
        '</div>',
    ], '3 lines-1');
selection_test(
    [
        `<div contenteditable dir="rtl" style="${kStyle}">`,
            '<bdo dir="rtl">A BC |DE</bdo>',
        '</div>',
    ],
    selection => selection.modify('move', 'backward', 'line'),
    [
        `<div contenteditable dir="rtl" style="${kStyle}">`,
            '<bdo dir="rtl">A |BC DE</bdo>',
        '</div>',
    ], '3 lines-2');

// 5 lines
selection_test(
    [
        `<div contenteditable dir="rtl" style="${kStyle}">`,
            '<bdo dir="rtl">A BC DE FG HI|</bdo>',
        '</div>',
    ],
    selection => selection.modify('move', 'backward', 'line'),
    [
        `<div contenteditable dir="rtl" style="${kStyle}">`,
            '<bdo dir="rtl">A BC DE FG| HI</bdo>',
        '</div>',
    ], '5 lines-1');
selection_test(
    [
        `<div contenteditable dir="rtl" style="${kStyle}">`,
            '<bdo dir="rtl">A BC DE FG |HI</bdo>',
        '</div>',
    ],
    selection => selection.modify('move', 'backward', 'line'),
    [
        `<div contenteditable dir="rtl" style="${kStyle}">`,
            '<bdo dir="rtl">A BC DE |FG HI</bdo>',
        '</div>',
    ], '5 lines-2');
selection_test(
    [
        `<div contenteditable dir="rtl" style="${kStyle}">`,
            '<bdo dir="rtl">A BC DE |FG HI</bdo>',
        '</div>',
    ],
    selection => selection.modify('move', 'backward', 'line'),
    [
        `<div contenteditable dir="rtl" style="${kStyle}">`,
            '<bdo dir="rtl">A BC |DE FG HI</bdo>',
        '</div>',
    ], '5 lines-3');
selection_test(
    [
        `<div contenteditable dir="rtl" style="${kStyle}">`,
            '<bdo dir="rtl">A BC |DE FG HI</bdo>',
        '</div>',
    ],
    selection => selection.modify('move', 'backward', 'line'),
    [
        `<div contenteditable dir="rtl" style="${kStyle}">`,
            '<bdo dir="rtl">A |BC DE FG HI</bdo>',
        '</div>',
    ], '5 lines-4');
</script>