chromium/third_party/blink/web_tests/editing/selection/thai-word-at-document-end.html

<!DOCTYPE HTML>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
// Thai word selection misbehaves for the last sentence in the document.
// rdar://problem/6764359
const isMac = navigator.platform.indexOf('Mac') === 0;

const kSegment0 = '\u0E04\u0E27\u0E32\u0E21';
const kSegment1 = '\u0E2B\u0E21\u0E32\u0E22';
const kSegment2 = '\u0E02\u0E2D\u0E07';
const kSegment3 = '\u0E2B\u0E19\u0E31\u0E07\u0E2A\u0E37\u0E2D\u0E1E\u0E34\u0E21\u0E1E\u0E4C';
const kSegment4 = '\u0E41\u0E25\u0E30';
const kSegment5 = '\u0E01\u0E49\u0E32\u0E27';
const kSegment6 = `\u0E43\u0E2B\u0E21\u0E48${kSegment2}`;
const kSegment7 = '\u0E2D\u0E34\u0E19\u0E40\u0E15\u0E2D\u0E23\u0E4C\u0E44\u0E17\u0E22';
const kSentence0 = `${kSegment0}${kSegment1}${kSegment2}${kSegment3}`;
const kSentence1 = `${kSegment4}${kSegment5}${kSegment6}${kSegment7}`;

// End with period
selection_test(
  `<div conntenteditable>|${kSentence0} ${kSentence1}.</div>`,
  selection => selection.modify('move', 'forward', 'word'),
  `<div conntenteditable>${kSegment0}|${kSegment1}${kSegment2}${kSegment3} ${kSentence1}.</div>`,
  '1 Move forward word with period');

selection_test(
  `<div conntenteditable>${kSegment0}|${kSegment1}${kSegment2}${kSegment3} ${kSentence1}.</div>`,
  selection => selection.modify('move', 'forward', 'word'),
  `<div conntenteditable>${kSegment0}${kSegment1}|${kSegment2}${kSegment3} ${kSentence1}.</div>`,
  '2 Move forward word with period');

selection_test(
  `<div conntenteditable>${kSegment0}${kSegment1}|${kSegment2}${kSegment3} ${kSentence1}.</div>`,
  selection => selection.modify('move', 'forward', 'word'),
  `<div conntenteditable>${kSegment0}${kSegment1}${kSegment2}|${kSegment3} ${kSentence1}.</div>`,
  '3 Move forward word with period');

selection_test(
  `<div conntenteditable>${kSegment0}${kSegment1}${kSegment2}|${kSegment3} ${kSentence1}.</div>`,
  selection => selection.modify('move', 'forward', 'word'),
  isMac
      ? `<div conntenteditable>${kSentence0}| ${kSegment4}${kSegment5}${kSegment6}${kSegment7}.</div>`
      : `<div conntenteditable>${kSentence0} |${kSegment4}${kSegment5}${kSegment6}${kSegment7}.</div>`,
  '4 Move forward word with period');

selection_test(
  `<div conntenteditable>${kSentence0} ${kSegment4}|${kSegment5}${kSegment6}${kSegment7}.</div>`,
  selection => selection.modify('move', 'forward', 'word'),
  `<div conntenteditable>${kSentence0} ${kSegment4}${kSegment5}|${kSegment6}${kSegment7}.</div>`,
  '5 Move forward word with period');

selection_test(
  `<div conntenteditable>${kSentence0} ${kSegment4}${kSegment5}|${kSegment6}${kSegment7}.</div>`,
  selection => selection.modify('move', 'forward', 'word'),
  `<div conntenteditable>${kSentence0} ${kSegment4}${kSegment5}\u0E43\u0E2B\u0E21\u0E48|${kSegment2}${kSegment7}.</div>`,
  '6 Move forward word with period');

selection_test(
  `<div conntenteditable>${kSentence0} ${kSegment4}${kSegment5}\u0E43\u0E2B\u0E21\u0E48|${kSegment2}${kSegment7}.</div>`,
  selection => selection.modify('move', 'forward', 'word'),
  `<div conntenteditable>${kSentence0} ${kSegment4}${kSegment5}\u0E43\u0E2B\u0E21\u0E48${kSegment2}|${kSegment7}.</div>`,
  '7 Move forward word with period');

selection_test(
  `<div conntenteditable>${kSentence0} ${kSentence1}|.</div>`,
  selection => selection.modify('move', 'forward', 'word'),
  `<div conntenteditable>${kSentence0} ${kSentence1}.|</div>`,
  '8 Move forward word with period');

selection_test(
  `<div conntenteditable>${kSentence0} ${kSentence1}.|</div>`,
  selection => selection.modify('move', 'forward', 'word'),
  `<div conntenteditable>${kSentence0} ${kSentence1}.|</div>`,
  '9 Move forward word with period');

// End withoutout period
selection_test(
  `<div conntenteditable>|${kSentence0} ${kSentence1}</div>`,
  selection => selection.modify('move', 'forward', 'word'),
  `<div conntenteditable>${kSegment0}|${kSegment1}${kSegment2}${kSegment3} ${kSentence1}</div>`,
  '1 Move forward word without period');

selection_test(
  `<div conntenteditable>${kSegment0}|${kSegment1}${kSegment2}${kSegment3} ${kSentence1}</div>`,
  selection => selection.modify('move', 'forward', 'word'),
  `<div conntenteditable>${kSegment0}${kSegment1}|${kSegment2}${kSegment3} ${kSentence1}</div>`,
  '2 Move forward word without period');

selection_test(
  `<div conntenteditable>${kSegment0}${kSegment1}|${kSegment2}${kSegment3} ${kSentence1}</div>`,
  selection => selection.modify('move', 'forward', 'word'),
  `<div conntenteditable>${kSegment0}${kSegment1}${kSegment2}|${kSegment3} ${kSentence1}</div>`,
  '3 Move forward word without period');

selection_test(
  `<div conntenteditable>${kSegment0}${kSegment1}${kSegment2}|${kSegment3} ${kSentence1}</div>`,
  selection => selection.modify('move', 'forward', 'word'),
  isMac
      ? `<div conntenteditable>${kSentence0}| ${kSegment4}${kSegment5}${kSegment6}${kSegment7}</div>`
      : `<div conntenteditable>${kSentence0} |${kSegment4}${kSegment5}${kSegment6}${kSegment7}</div>`,
  '4 Move forward word without period');

selection_test(
  `<div conntenteditable>${kSentence0} ${kSegment4}|${kSegment5}${kSegment6}${kSegment7}</div>`,
  selection => selection.modify('move', 'forward', 'word'),
  `<div conntenteditable>${kSentence0} ${kSegment4}${kSegment5}|${kSegment6}${kSegment7}</div>`,
  '5 Move forward word without period');

selection_test(
  `<div conntenteditable>${kSentence0} ${kSegment4}${kSegment5}\u0E43\u0E2B\u0E21\u0E48|${kSegment2}${kSegment7}</div>`,
  selection => selection.modify('move', 'forward', 'word'),
  `<div conntenteditable>${kSentence0} ${kSegment4}${kSegment5}\u0E43\u0E2B\u0E21\u0E48${kSegment2}|${kSegment7}</div>`,
  '6 Move forward word without period');

selection_test(
  `<div conntenteditable>${kSentence0} ${kSegment4}${kSegment5}\u0E43\u0E2B\u0E21\u0E48|${kSegment2}${kSegment7}</div>`,
  selection => selection.modify('move', 'forward', 'word'),
  `<div conntenteditable>${kSentence0} ${kSegment4}${kSegment5}\u0E43\u0E2B\u0E21\u0E48${kSegment2}|${kSegment7}</div>`,
  '7 Move forward word without period');

selection_test(
  `<div conntenteditable>${kSentence0} ${kSentence1}|</div>`,
  selection => selection.modify('move', 'forward', 'word'),
  `<div conntenteditable>${kSentence0} ${kSentence1}|</div>`,
  '8 Move forward word without period');
</script>