blob: 2cf7227a545a56f52ed2c96c01fe31560dd66f61 [file] [log] [blame]
<!doctype html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../assert_selection.js"></script>
<script>
// Soft line break before white space
const kStyle = 'line-break:before-white-space; width: 100px; font: 20px monospace;';
const isMac = navigator.platform.indexOf('Mac') === 0;
const kBehaviors = window.internals ? ['mac', 'win'] : isMac ? ['mac'] : ['win'];
for (const behavior of kBehaviors) {
if (window.internals) {
internals.settings.setEditingBehavior(behavior);
internals.settings.setSelectTrailingWhitespaceEnabled(behavior !== 'mac');
}
selection_test(
`<div contenteditable dir="rtl" style="${kStyle}">|line1 line2 a line3</div>`,
selection => selection.modify('extend', 'left', 'word'),
behavior === 'mac'
? `<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">^line1| line2 a line3</div>`
: `<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">^line1 |line2 a line3</div>`,
`${behavior} 21-0 rtl left word`);
selection_test(
`<div contenteditable dir="rtl" style="${kStyle}">l|ine1 line2 a line3</div>`,
selection => selection.modify('extend', 'left', 'word'),
behavior === 'mac'
? `<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">l^ine1| line2 a line3</div>`
: `<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">l^ine1 |line2 a line3</div>`,
`${behavior} 21-1 rtl left word`);
selection_test(
`<div contenteditable dir="rtl" style="${kStyle}">li|ne1 line2 a line3</div>`,
selection => selection.modify('extend', 'left', 'word'),
behavior === 'mac'
? `<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">li^ne1| line2 a line3</div>`
: `<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">li^ne1 |line2 a line3</div>`,
`${behavior} 21-2 rtl left word`);
selection_test(
`<div contenteditable dir="rtl" style="${kStyle}">lin|e1 line2 a line3</div>`,
selection => selection.modify('extend', 'left', 'word'),
behavior === 'mac'
? `<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">lin^e1| line2 a line3</div>`
: `<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">lin^e1 |line2 a line3</div>`,
`${behavior} 21-3 rtl left word`);
selection_test(
`<div contenteditable dir="rtl" style="${kStyle}">line|1 line2 a line3</div>`,
selection => selection.modify('extend', 'left', 'word'),
behavior === 'mac'
? `<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">line^1| line2 a line3</div>`
: `<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">line^1 |line2 a line3</div>`,
`${behavior} 21-4 rtl left word`);
selection_test(
`<div contenteditable dir="rtl" style="${kStyle}">line1| line2 a line3</div>`,
selection => selection.modify('extend', 'left', 'word'),
behavior === 'mac'
? `<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">line1^ line2| a line3</div>`
: `<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">line1^ |line2 a line3</div>`,
`${behavior} 21-5 rtl left word`);
selection_test(
`<div contenteditable dir="rtl" style="${kStyle}">line1 |line2 a line3</div>`,
selection => selection.modify('extend', 'left', 'word'),
behavior === 'mac'
? `<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">line1 ^line2| a line3</div>`
: `<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">line1 ^line2 |a line3</div>`,
`${behavior} 21-6 rtl left word`);
selection_test(
`<div contenteditable dir="rtl" style="${kStyle}">line1 l|ine2 a line3</div>`,
selection => selection.modify('extend', 'left', 'word'),
behavior === 'mac'
? `<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">line1 l^ine2| a line3</div>`
: `<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">line1 l^ine2 |a line3</div>`,
`${behavior} 21-7 rtl left word`);
selection_test(
`<div contenteditable dir="rtl" style="${kStyle}">line1 li|ne2 a line3</div>`,
selection => selection.modify('extend', 'left', 'word'),
behavior === 'mac'
? `<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">line1 li^ne2| a line3</div>`
: `<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">line1 li^ne2 |a line3</div>`,
`${behavior} 21-8 rtl left word`);
selection_test(
`<div contenteditable dir="rtl" style="${kStyle}">line1 lin|e2 a line3</div>`,
selection => selection.modify('extend', 'left', 'word'),
behavior === 'mac'
? `<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">line1 lin^e2| a line3</div>`
: `<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">line1 lin^e2 |a line3</div>`,
`${behavior} 21-9 rtl left word`);
selection_test(
`<div contenteditable dir="rtl" style="${kStyle}">line1 line|2 a line3</div>`,
selection => selection.modify('extend', 'left', 'word'),
behavior === 'mac'
? `<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">line1 line^2| a line3</div>`
: `<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">line1 line^2 |a line3</div>`,
`${behavior} 21-10 rtl left word`);
selection_test(
`<div contenteditable dir="rtl" style="${kStyle}">line1 line2| a line3</div>`,
selection => selection.modify('extend', 'left', 'word'),
behavior === 'mac'
? `<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">line1 line2^ a| line3</div>`
: `<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">line1 line2^ |a line3</div>`,
`${behavior} 21-11 rtl left word`);
selection_test(
`<div contenteditable dir="rtl" style="${kStyle}">line1 line2 |a line3</div>`,
selection => selection.modify('extend', 'left', 'word'),
behavior === 'mac'
? `<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">line1 line2 ^a| line3</div>`
: `<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">line1 line2 ^a |line3</div>`,
`${behavior} 21-12 rtl left word`);
selection_test(
`<div contenteditable dir="rtl" style="${kStyle}">line1 line2 a| line3</div>`,
selection => selection.modify('extend', 'left', 'word'),
behavior === 'mac'
? `<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">line1 line2 a^ line3|</div>`
: `<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">line1 line2 a^ |line3</div>`,
`${behavior} 21-13 rtl left word`);
selection_test(
`<div contenteditable dir="rtl" style="${kStyle}">line1 line2 a |line3</div>`,
selection => selection.modify('extend', 'left', 'word'),
`<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">line1 line2 a ^line3|</div>`,
`${behavior} 21-14 rtl left word`);
selection_test(
`<div contenteditable dir="rtl" style="${kStyle}">line1 line2 a l|ine3</div>`,
selection => selection.modify('extend', 'left', 'word'),
`<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">line1 line2 a l^ine3|</div>`,
`${behavior} 21-15 rtl left word`);
selection_test(
`<div contenteditable dir="rtl" style="${kStyle}">line1 line2 a li|ne3</div>`,
selection => selection.modify('extend', 'left', 'word'),
`<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">line1 line2 a li^ne3|</div>`,
`${behavior} 21-16 rtl left word`);
selection_test(
`<div contenteditable dir="rtl" style="${kStyle}">line1 line2 a lin|e3</div>`,
selection => selection.modify('extend', 'left', 'word'),
`<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">line1 line2 a lin^e3|</div>`,
`${behavior} 21-17 rtl left word`);
selection_test(
`<div contenteditable dir="rtl" style="${kStyle}">line1 line2 a line|3</div>`,
selection => selection.modify('extend', 'left', 'word'),
`<div contenteditable dir="rtl" style="line-break:before-white-space; width: 100px; font: 20px monospace;">line1 line2 a line^3|</div>`,
`${behavior} 21-18 rtl left word`);
}
</script>