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 <script> | 5 <script> |
6 const isMac = navigator.platform.indexOf('Mac') === 0; | 6 const isMac = navigator.platform.indexOf('Mac') === 0; |
7 const kDeleteWordModifiers = isMac ? ['altKey'] : ['ctrlKey']; | 7 const kDeleteWordModifiers = isMac ? ['altKey'] : ['ctrlKey']; |
8 | 8 |
9 test(() => { | 9 test(() => { |
10 assert_not_equals(window.eventSender, undefined, 'This test requires eve
ntSender.'); | 10 assert_not_equals(window.eventSender, undefined, 'This test requires eve
ntSender.'); |
11 assert_selection( | 11 assert_selection( |
12 [ | 12 [ |
13 '<div contenteditable>', | 13 '<div contenteditable>', |
14 'one two |cha cha three four cha cha cha', | 14 'one two |cha cha three four cha cha cha', |
15 '</div>', | 15 '</div>', |
16 ].join(''), | 16 ].join(''), |
17 selection => { | 17 selection => { |
18 selection.document.execCommand('insertText', false, ' abc'); | 18 selection.document.execCommand('insertText', false, ' abc'); |
19 eventSender.keyDown('Backspace', kDeleteWordModifiers); | 19 eventSender.keyDown('Backspace', kDeleteWordModifiers); |
20 selection.document.execCommand('insertText', false, ' cha'); | 20 selection.document.execCommand('insertText', false, ' cha'); |
21 }, | 21 }, |
22 // BR is a placeholder. | |
23 [ | 22 [ |
24 '<div contenteditable>', | 23 '<div contenteditable>', |
25 'one two \u{00A0}abc cha|cha cha three four cha cha cha', | 24 'one two \u{00A0} cha|cha cha three four cha cha cha', |
26 '</div>', | 25 '</div>', |
27 ].join('')); | 26 ].join('')); |
28 }, 'Delete word'); | 27 }, 'Delete word'); |
29 | 28 |
30 test(() => { | 29 test(() => { |
31 assert_not_equals(window.eventSender, undefined, 'This test requires eve
ntSender.'); | 30 assert_not_equals(window.eventSender, undefined, 'This test requires eve
ntSender.'); |
32 assert_selection( | 31 assert_selection( |
33 [ | 32 [ |
34 '<div contenteditable>', | 33 '<div contenteditable>', |
35 'one two |three four', | 34 'one two |three four', |
36 '</div>', | 35 '</div>', |
37 ].join(''), | 36 ].join(''), |
38 selection => { | 37 selection => { |
39 eventSender.keyDown('Backspace', kDeleteWordModifiers); | 38 eventSender.keyDown('Backspace', kDeleteWordModifiers); |
40 selection.document.execCommand('undo'); | 39 selection.document.execCommand('undo'); |
41 }, | 40 }, |
42 // BR is a placeholder. | |
43 [ | 41 [ |
44 '<div contenteditable>', | 42 '<div contenteditable>', |
45 'one two |three four', | 43 isMac |
| 44 ? 'one |two ^three four' |
| 45 : 'one two |three four', |
46 '</div>', | 46 '</div>', |
47 ].join('')); | 47 ].join('')); |
48 }, 'Delete word then undo'); | 48 }, 'Delete word then undo'); |
49 </script> | 49 </script> |
OLD | NEW |