| <!doctype HTML> |
| <script src="../../../resources/testharness.js"></script> |
| <script src="../../../resources/testharnessreport.js"></script> |
| <script src="../../assert_selection.js"></script> |
| <script> |
| const kAllPlatforms = ['android', 'mac', 'unix', 'win']; |
| const platforms = window.internals |
| ? kAllPlatforms |
| : [navigator.platform.indexOf('Win') === 0 ? 'win' : navigator.platform]; |
| for (const platform of platforms) { |
| if (window.internals) |
| internals.settings.setEditingBehavior(platform); |
| const isWin = platform === 'win'; |
| |
| // TDOO(editing-dev): All of expectations are different from Firefox, we |
| // should study differences. |
| |
| // TODO(editing-dev): As of [1], Blink paints caret in wrong position for |
| // Latin alphabet in RTL. |
| // For "def ghi" offset 0 paints caret after "ghi", |
| // For "def ghi" offset 7 paints caret before "def". |
| // See [2] for manual checking. |
| // [1] http://crbug.com/702049 Ctrl+Right from LTR to RTL makes infinite loop |
| // [2] https://jsfiddle.net/3pykkjzd/ |
| |
| // Extend left character |
| test(() => { |
| assert_selection( |
| '<div contenteditable>abc <div dir="rtl">|def ghi</div> jkl</div>', |
| selection => selection.modify('extend', 'left', 'character'), |
| '<div contenteditable>abc <div dir="rtl">^d|ef ghi</div> jkl</div>'); |
| }, `${platform}: extend character left: ltr <- rtl`); |
| |
| test(() => { |
| assert_selection( |
| '<div contenteditable>abc <div dir="rtl">def ghi</div> |jkl</div>', |
| selection => selection.modify('extend', 'left', 'character'), |
| '<div contenteditable>abc <div dir="rtl">def ghi|</div>^ jkl</div>'); |
| }, `${platform}: extend character left: rtl <- ltr`); |
| |
| // Extend left word |
| test(() => { |
| assert_selection( |
| '<div contenteditable>abc <div dir="rtl">|def ghi</div> jkl</div>', |
| selection => selection.modify('extend', 'left', 'word'), |
| isWin |
| ? '<div contenteditable>abc <div dir="rtl">^def |ghi</div> jkl</div>' |
| : '<div contenteditable>abc <div dir="rtl">^def| ghi</div> jkl</div>'); |
| }, `${platform}: extend word left: ltr <- rtl`); |
| |
| test(() => { |
| assert_selection( |
| '<div contenteditable>abc <div dir="rtl">def ghi</div> |jkl</div>', |
| selection => selection.modify('extend', 'left', 'word'), |
| '<div contenteditable>abc <div dir="rtl">def ghi|</div>^ jkl</div>'); |
| }, `${platform}: extend word left: rtl <- ltr`); |
| |
| // Extend right character |
| test(() => { |
| assert_selection( |
| '<div contenteditable>abc |<div dir="rtl">def ghi</div> jkl</div>', |
| selection => selection.modify('extend', 'right', 'character'), |
| '<div contenteditable>abc ^<div dir="rtl">|def ghi</div> jkl</div>'); |
| }, `${platform}: extend character right: ltr -> rtl`); |
| |
| test(() => { |
| assert_selection( |
| '<div contenteditable>abc <div dir="rtl">def ghi|</div> jkl</div>', |
| selection => selection.modify('extend', 'right', 'character'), |
| '<div contenteditable>abc <div dir="rtl">def gh|i^</div> jkl</div>'); |
| }, `${platform}: extend character right: rtl -> ltr`); |
| |
| // Extend right word |
| test(() => { |
| assert_selection( |
| '<div contenteditable>abc |<div dir="rtl">def ghi</div> jkl</div>', |
| selection => selection.modify('extend', 'right', 'word'), |
| isWin |
| ? '<div contenteditable>abc ^<div dir="rtl">|def ghi</div> jkl</div>' |
| : '<div contenteditable>abc ^<div dir="rtl">|def ghi</div> jkl</div>'); |
| }, `${platform}: extend word right: ltr -> rtl`); |
| |
| test(() => { |
| assert_selection( |
| '<div contenteditable>abc <div dir="rtl">def ghi|</div> jkl</div>', |
| selection => selection.modify('extend', 'right', 'word'), |
| '<div contenteditable>abc <div dir="rtl">def |ghi^</div> jkl</div>'); |
| }, `${platform}: extend word right: rtr -> ltr`); |
| } |
| </script> |