| 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 // The current behavior is wrong. The correct expectation should be | |
| 10 // 'hello |world' on Windows and 'hello| world' on other platforms. | |
| 11 test(() => assert_selection( | 9 test(() => assert_selection( |
| 12 [ | 10 [ |
| 13 '<style>:first-letter{color:red;}</style>', | 11 '<style>:first-letter{color:red;}</style>', |
| 14 '<div contenteditable> hel|lo world\'</div>' | 12 '<div contenteditable> hel|lo world\'</div>' |
| 15 ].join(''), | 13 ].join(''), |
| 16 selection => selection.modify('move', 'forward', 'word'), | 14 selection => selection.modify('move', 'forward', 'word'), |
| 17 [ | 15 [ |
| 18 '<style>:first-letter{color:red;}</style>', | 16 '<style>:first-letter{color:red;}</style>', |
| 19 isMac ? '<div contenteditable> hello wor|ld\'</div>' | 17 isMac ? '<div contenteditable> hello| world\'</div>' |
| 20 : '<div contenteditable> hello world\'|</div>' | 18 // The current non-Mac behavior is wrong. The correct expectation |
| 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>' |
| 21 ].join('')), 'Move forward by word'); | 23 ].join('')), 'Move forward by word'); |
| 22 | 24 |
| 23 test(() => assert_selection( | 25 test(() => assert_selection( |
| 24 [ | 26 [ |
| 25 '<style>:first-letter{color:red;}</style>', | 27 '<style>:first-letter{color:red;}</style>', |
| 26 '<div contenteditable> hel|lo world\'</div>' | 28 '<div contenteditable> hel|lo world\'</div>' |
| 27 ].join(''), | 29 ].join(''), |
| 28 selection => selection.modify('move', 'backward', 'word'), | 30 selection => selection.modify('move', 'backward', 'word'), |
| 29 [ | 31 [ |
| 30 '<style>:first-letter{color:red;}</style>', | 32 '<style>:first-letter{color:red;}</style>', |
| 31 '<div contenteditable> |hello world\'</div>' | 33 '<div contenteditable> |hello world\'</div>' |
| 32 ].join('')), 'Move backward by word'); | 34 ].join('')), 'Move backward by word'); |
| 33 | 35 |
| 34 // The current behavior is wrong. The correct expectation should be | |
| 35 // 'hello |world' on Windows and 'hello| world' on other platforms. | |
| 36 test(() => assert_selection( | 36 test(() => assert_selection( |
| 37 [ | 37 [ |
| 38 '<style>:first-letter{color:red;}</style>', | 38 '<style>:first-letter{color:red;}</style>', |
| 39 '<div contenteditable style="white-space:pre"> hel|lo world\'</div>' | 39 '<div contenteditable style="white-space:pre"> hel|lo world\'</div>' |
| 40 ].join(''), | 40 ].join(''), |
| 41 selection => selection.modify('move', 'forward', 'word'), | 41 selection => selection.modify('move', 'forward', 'word'), |
| 42 [ | 42 [ |
| 43 '<style>:first-letter{color:red;}</style>', | 43 '<style>:first-letter{color:red;}</style>', |
| 44 isMac ? '<div contenteditable style="white-space:pre"> hello wor|ld\'</div
>' | 44 isMac ? '<div contenteditable style="white-space:pre"> hello| world\'</div
>' |
| 45 : '<div contenteditable style="white-space:pre"> hello world\'|</div
>' | 45 // The current non-Mac behavior is wrong. The correct expectation |
| 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
>' |
| 46 ].join('')), 'Move forward by word with white-space:pre'); | 50 ].join('')), 'Move forward by word with white-space:pre'); |
| 47 | 51 |
| 48 test(() => assert_selection( | 52 test(() => assert_selection( |
| 49 [ | 53 [ |
| 50 '<style>:first-letter{color:red;}</style>', | 54 '<style>:first-letter{color:red;}</style>', |
| 51 '<div contenteditable style="white-space:pre"> hel|lo world\'</div>' | 55 '<div contenteditable style="white-space:pre"> hel|lo world\'</div>' |
| 52 ].join(''), | 56 ].join(''), |
| 53 selection => selection.modify('move', 'backward', 'word'), | 57 selection => selection.modify('move', 'backward', 'word'), |
| 54 [ | 58 [ |
| 55 '<style>:first-letter{color:red;}</style>', | 59 '<style>:first-letter{color:red;}</style>', |
| 56 '<div contenteditable style="white-space:pre"> |hello world\'</div>' | 60 '<div contenteditable style="white-space:pre"> |hello world\'</div>' |
| 57 ].join('')), 'Move backward by word with white-space:pre'); | 61 ].join('')), 'Move backward by word with white-space:pre'); |
| 58 </script> | 62 </script> |
| OLD | NEW |