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 test(() => { | 6 test(() => { |
7 if (!window.eventSender) { | 7 if (!window.eventSender) { |
8 assert_unreached('This test requires eventSender.'); | 8 assert_unreached('This test requires eventSender.'); |
9 return; | 9 return; |
10 } | 10 } |
11 | 11 |
12 assert_selection( | 12 assert_selection( |
13 '<input value="x"><input type="checkbox">', | 13 '<input value="x"><input type="checkbox">', |
14 selection => { | 14 selection => { |
15 const document = selection.document; | 15 const document = selection.document; |
16 const textField = document.querySelector('input'); | 16 const textField = document.querySelector('input'); |
17 textField.select(); | 17 textField.select(); |
18 document.querySelector('input[type=checkbox]').focus(); | 18 document.querySelector('input[type=checkbox]').focus(); |
19 eventSender.keyDown('a'); | 19 eventSender.keyDown('a'); |
20 // Insert |textField.value| to HTML for verification | 20 // Insert |textField.value| to HTML for verification |
21 textField.appendChild(document.createTextNode(textField.value)); | 21 textField.appendChild(document.createTextNode(textField.value)); |
22 }, | 22 }, |
23 '<input value="x">x</input><input type="checkbox">', | 23 '|<input value="x">x</input><input type="checkbox">', |
24 'unfocused text field should not insert a charcter by keyboard event'); | 24 'unfocused text field should not insert a charcter by keyboard event'); |
25 | 25 |
26 assert_selection( | 26 assert_selection( |
27 '<div contenteditable>|</div><input type="checkbox">', | 27 '<div contenteditable>|</div><input type="checkbox">', |
28 selection => { | 28 selection => { |
29 const document = selection.document; | 29 const document = selection.document; |
30 document.querySelector('input[type=checkbox]').focus(); | 30 document.querySelector('input[type=checkbox]').focus(); |
31 eventSender.keyDown('a'); | 31 eventSender.keyDown('a'); |
32 }, | 32 }, |
33 '<div contenteditable>|</div><input type="checkbox">', | 33 '<div contenteditable>|</div><input type="checkbox">', |
34 'unfocused content editable should not insert a charcter by keyboard event')
; | 34 'unfocused content editable should not insert a charcter by keyboard event')
; |
35 }, 'Keyboard event without focus should not insert a character.'); | 35 }, 'Keyboard event without focus should not insert a character.'); |
36 </script> | 36 </script> |
OLD | NEW |