OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <title>InputEvent: beforeinput data</title> |
| 5 <script src="../../../resources/testharness.js"></script> |
| 6 <script src="../../../resources/testharnessreport.js"></script> |
| 7 </head> |
| 8 <body> |
| 9 <input type="text" id="txt"> |
| 10 <script> |
| 11 test(function() { |
| 12 var lastData = ''; |
| 13 var txt = document.getElementById('txt'); |
| 14 txt.addEventListener('beforeinput', function(event) { |
| 15 lastData = event.data; |
| 16 }); |
| 17 if (!window.eventSender) { |
| 18 document.write('This test requires eventSender'); |
| 19 } else { |
| 20 function testKeyDownData(key, modifiers, data) { |
| 21 eventSender.keyDown(key, modifiers); |
| 22 assert_equals(lastData, data, `${modifiers.toString()}+${key} should
produce data: ${data}`); |
| 23 } |
| 24 |
| 25 txt.focus(); |
| 26 // Typing |
| 27 testKeyDownData('a', [], 'a'); |
| 28 testKeyDownData('4', [], '4'); |
| 29 testKeyDownData('backspace', [], ''); |
| 30 // TODO(chongz): eventSender.keyDown('a', ['shiftKey']) should produce s
hifted character. |
| 31 // https://crbug.com/604488 |
| 32 // testKeyDownData('l', ['shiftKey'], 'L'); |
| 33 // testKeyDownData('6', ['shiftKey'], '^'); |
| 34 testKeyDownData(' ', [], ' '); |
| 35 } |
| 36 }, 'Testing beforeinput data'); |
| 37 </script> |
| 38 </body> |
| 39 </html> |
OLD | NEW |