| <!doctype html> |
| <script src="../../resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| <script src="../assert_selection.js"></script> |
| <script> |
| test(() => { |
| if (!window.eventSender) { |
| assert_unreached('This test requires eventSender.'); |
| return; |
| } |
| |
| assert_selection( |
| '<input value="x"><input type="checkbox">', |
| selection => { |
| const document = selection.document; |
| const textField = document.querySelector('input'); |
| textField.select(); |
| document.querySelector('input[type=checkbox]').focus(); |
| eventSender.keyDown('a'); |
| // Insert |textField.value| to HTML for verification |
| textField.appendChild(document.createTextNode(textField.value)); |
| }, |
| '|<input value="x">x</input><input type="checkbox">', |
| 'unfocused text field should not insert a charcter by keyboard event'); |
| |
| assert_selection( |
| '<div contenteditable>|</div><input type="checkbox">', |
| selection => { |
| const document = selection.document; |
| document.querySelector('input[type=checkbox]').focus(); |
| eventSender.keyDown('a'); |
| }, |
| '<div contenteditable>|</div><input type="checkbox">', |
| 'unfocused content editable should not insert a charcter by keyboard event'); |
| }, 'Keyboard event without focus should not insert a character.'); |
| </script> |