| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <script src="../../resources/testharness.js"></script> | 2 <script src="../../resources/testharness.js"></script> |
| 3 <script src="../../resources/testharnessreport.js"></script> | 3 <script src="../../resources/testharnessreport.js"></script> |
| 4 <script src="../assert_selection.js"></script> | 4 <script src="../assert_selection.js"></script> |
| 5 | 5 |
| 6 <script> | 6 <script> |
| 7 const isMac = navigator.platform.indexOf('Mac') !== -1; | 7 const isMac = navigator.platform.indexOf('Mac') !== -1; |
| 8 | 8 |
| 9 test(() => assert_selection( | 9 test(() => assert_selection( |
| 10 [ | 10 [ |
| 11 '<style>:first-letter{color:red;}</style>', | 11 '<style>:first-letter{color:red;}</style>', |
| 12 '<div contenteditable> hel|lo world\'</div>' | 12 '<div contenteditable> hel|lo world\'</div>' |
| 13 ].join(''), | 13 ].join(''), |
| 14 selection => selection.modify('move', 'forward', 'word'), | 14 selection => selection.modify('move', 'forward', 'word'), |
| 15 [ | 15 [ |
| 16 '<style>:first-letter{color:red;}</style>', | 16 '<style>:first-letter{color:red;}</style>', |
| 17 isMac ? '<div contenteditable> hello| world\'</div>' | 17 isMac ? '<div contenteditable> hello| world\'</div>' |
| 18 // The current non-Mac behavior is wrong. The correct expectation | 18 : '<div contenteditable> hello |world\'</div>' |
| 19 // should be 'hello |world'. A deeper reason is that Blink performs | |
| 20 // backward word boundary searches to refine the final selection, | |
| 21 // which doesn't work with first-letter (crbug.com/671104). | |
| 22 : '<div contenteditable> hell|o world\'</div>' | |
| 23 ].join('')), 'Move forward by word'); | 19 ].join('')), 'Move forward by word'); |
| 24 | 20 |
| 25 test(() => assert_selection( | 21 test(() => assert_selection( |
| 26 [ | 22 [ |
| 27 '<style>:first-letter{color:red;}</style>', | 23 '<style>:first-letter{color:red;}</style>', |
| 28 '<div contenteditable> hel|lo world\'</div>' | 24 '<div contenteditable> hel|lo world\'</div>' |
| 29 ].join(''), | 25 ].join(''), |
| 30 selection => selection.modify('move', 'backward', 'word'), | 26 selection => selection.modify('move', 'backward', 'word'), |
| 31 [ | 27 [ |
| 32 '<style>:first-letter{color:red;}</style>', | 28 '<style>:first-letter{color:red;}</style>', |
| 33 '<div contenteditable> |hello world\'</div>' | 29 '<div contenteditable> |hello world\'</div>' |
| 34 ].join('')), 'Move backward by word'); | 30 ].join('')), 'Move backward by word'); |
| 35 | 31 |
| 36 test(() => assert_selection( | 32 test(() => assert_selection( |
| 37 [ | 33 [ |
| 38 '<style>:first-letter{color:red;}</style>', | 34 '<style>:first-letter{color:red;}</style>', |
| 39 '<div contenteditable style="white-space:pre"> hel|lo world\'</div>' | 35 '<div contenteditable style="white-space:pre"> hel|lo world\'</div>' |
| 40 ].join(''), | 36 ].join(''), |
| 41 selection => selection.modify('move', 'forward', 'word'), | 37 selection => selection.modify('move', 'forward', 'word'), |
| 42 [ | 38 [ |
| 43 '<style>:first-letter{color:red;}</style>', | 39 '<style>:first-letter{color:red;}</style>', |
| 44 isMac ? '<div contenteditable style="white-space:pre"> hello| world\'</div
>' | 40 isMac ? '<div contenteditable style="white-space:pre"> hello| world\'</div
>' |
| 45 // The current non-Mac behavior is wrong. The correct expectation | 41 : '<div contenteditable style="white-space:pre"> hello |world\'</div
>' |
| 46 // should be 'hello |world'. A deeper reason is that Blink performs | |
| 47 // backward word boundary searches to refine the final selection, | |
| 48 // which doesn't work with first-letter (crbug.com/671104). | |
| 49 : '<div contenteditable style="white-space:pre"> hell|o world\'</div
>' | |
| 50 ].join('')), 'Move forward by word with white-space:pre'); | 42 ].join('')), 'Move forward by word with white-space:pre'); |
| 51 | 43 |
| 52 test(() => assert_selection( | 44 test(() => assert_selection( |
| 53 [ | 45 [ |
| 54 '<style>:first-letter{color:red;}</style>', | 46 '<style>:first-letter{color:red;}</style>', |
| 55 '<div contenteditable style="white-space:pre"> hel|lo world\'</div>' | 47 '<div contenteditable style="white-space:pre"> hel|lo world\'</div>' |
| 56 ].join(''), | 48 ].join(''), |
| 57 selection => selection.modify('move', 'backward', 'word'), | 49 selection => selection.modify('move', 'backward', 'word'), |
| 58 [ | 50 [ |
| 59 '<style>:first-letter{color:red;}</style>', | 51 '<style>:first-letter{color:red;}</style>', |
| 60 '<div contenteditable style="white-space:pre"> |hello world\'</div>' | 52 '<div contenteditable style="white-space:pre"> |hello world\'</div>' |
| 61 ].join('')), 'Move backward by word with white-space:pre'); | 53 ].join('')), 'Move backward by word with white-space:pre'); |
| 62 </script> | 54 </script> |
| OLD | NEW |