OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <title>InputEvent: beforeinput inputType</title> |
| 5 <script src="../../../resources/testharness.js"></script> |
| 6 <script src="../../../resources/testharnessreport.js"></script> |
| 7 </head> |
| 8 <body> |
| 9 <div id="log"></div> |
| 10 <input type="text" id="txt"> |
| 11 |
| 12 <script> |
| 13 test(function() { |
| 14 var lastInputType = ""; |
| 15 var txt = document.getElementById('txt'); |
| 16 txt.addEventListener('beforeinput', function(e) { |
| 17 lastInputType = e.inputType; |
| 18 }); |
| 19 if (!window.eventSender) { |
| 20 document.write('This test requires eventSender'); |
| 21 } else { |
| 22 function testKeyDownInputType(key, modifiers, inputType) { |
| 23 eventSender.keyDown(key, modifiers); |
| 24 assert_equals(lastInputType, inputType, modifiers.toString() + "+" +
key + " should produce inputType:" + inputType); |
| 25 } |
| 26 |
| 27 txt.focus(); |
| 28 // Typing |
| 29 testKeyDownInputType('a', [], 'insertText'); |
| 30 testKeyDownInputType('6', [], 'insertText'); |
| 31 testKeyDownInputType('backspace', [], 'DeleteBackward'); |
| 32 testKeyDownInputType('l', ['shiftKey'], 'insertText'); |
| 33 testKeyDownInputType('w', ['shiftKey'], 'insertText'); |
| 34 |
| 35 // Keyboard commands |
| 36 var ctrlKey = (navigator.userAgent.indexOf('Mac OS X') != -1) ? 'metaKey
' : 'ctrlKey'; |
| 37 testKeyDownInputType('z', [ctrlKey], 'Undo'); |
| 38 testKeyDownInputType('z', [ctrlKey, 'shiftKey'], 'Redo'); |
| 39 testKeyDownInputType('leftArrow', [], 'MoveLeft'); |
| 40 testKeyDownInputType('leftArrow', ['shiftKey'], 'MoveLeftAndModifySelect
ion'); |
| 41 testKeyDownInputType('c', [ctrlKey], 'Copy'); |
| 42 testKeyDownInputType('v', [ctrlKey], 'Paste'); |
| 43 testKeyDownInputType('home', [], 'MoveToBeginningOfLine'); |
| 44 } |
| 45 }, "Testing beforeinput inputType"); |
| 46 </script> |
| 47 |
| 48 </body> |
| 49 </html> |
OLD | NEW |