| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>InputEvent: beforeinput inputType</title> | 4 <title>InputEvent: beforeinput inputType</title> |
| 5 <script src="../../../resources/testharness.js"></script> | 5 <script src="../../../resources/testharness.js"></script> |
| 6 <script src="../../../resources/testharnessreport.js"></script> | 6 <script src="../../../resources/testharnessreport.js"></script> |
| 7 </head> | 7 </head> |
| 8 <body> | 8 <body> |
| 9 <input type="text" id="input"> | 9 <input type="text" id="input"> |
| 10 <textarea id="textarea"></textarea> | 10 <textarea id="textarea"></textarea> |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 assert_false(event.isComposing); | 26 assert_false(event.isComposing); |
| 27 lastInputType = event.inputType; | 27 lastInputType = event.inputType; |
| 28 }); | 28 }); |
| 29 | 29 |
| 30 const NO_INPUT_EVENT_FIRED = 'NO_INPUT_EVENT_FIRED'; | 30 const NO_INPUT_EVENT_FIRED = 'NO_INPUT_EVENT_FIRED'; |
| 31 function testKeyDownInputType(key, modifiers, beforeInputType, inputType) { | 31 function testKeyDownInputType(key, modifiers, beforeInputType, inputType) { |
| 32 inputType = inputType || beforeInputType; | 32 inputType = inputType || beforeInputType; |
| 33 lastBeforeInputType = NO_INPUT_EVENT_FIRED; | 33 lastBeforeInputType = NO_INPUT_EVENT_FIRED; |
| 34 lastInputType = NO_INPUT_EVENT_FIRED; | 34 lastInputType = NO_INPUT_EVENT_FIRED; |
| 35 eventSender.keyDown(key, modifiers); | 35 eventSender.keyDown(key, modifiers); |
| 36 assert_equals(lastBeforeInputType, beforeInputType, `${modifiers.toStrin
g()}+${key} should produce beforeInputType: ${inputType}`); | 36 assert_equals(lastBeforeInputType, beforeInputType, `${modifiers.toStrin
g()}+${key} should produce beforeInputType: ${beforeInputType}`); |
| 37 assert_equals(lastInputType, inputType, `${modifiers.toString()}+${key}
should produce inputType: ${inputType}`); | 37 assert_equals(lastInputType, inputType, `${modifiers.toString()}+${key}
should produce inputType: ${inputType}`); |
| 38 } | 38 } |
| 39 | 39 |
| 40 editable.focus(); | 40 editable.focus(); |
| 41 // Typing | 41 // Typing |
| 42 testKeyDownInputType('a', [], 'insertText'); | 42 testKeyDownInputType('a', [], 'insertText'); |
| 43 testKeyDownInputType('6', [], 'insertText'); | 43 testKeyDownInputType('6', [], 'insertText'); |
| 44 testKeyDownInputType('l', ['shiftKey'], 'insertText'); | 44 testKeyDownInputType('l', ['shiftKey'], 'insertText'); |
| 45 testKeyDownInputType('w', ['shiftKey'], 'insertText'); | 45 testKeyDownInputType('w', ['shiftKey'], 'insertText'); |
| 46 | 46 |
| 47 // Enter key has different behavior on <input>, <textarea> and ContentEditab
le. | 47 // Enter key has different behavior on <input>, <textarea> and ContentEditab
le. |
| 48 document.getElementById('input').focus(); | 48 document.getElementById('input').focus(); |
| 49 testKeyDownInputType('Enter', [], 'insertLineBreak', NO_INPUT_EVENT_FIRED); | 49 testKeyDownInputType('Enter', [], NO_INPUT_EVENT_FIRED, NO_INPUT_EVENT_FIRED
); |
| 50 testKeyDownInputType('Enter', ['shiftKey'], 'insertLineBreak', NO_INPUT_EVEN
T_FIRED); | 50 testKeyDownInputType('Enter', ['shiftKey'], NO_INPUT_EVENT_FIRED, NO_INPUT_E
VENT_FIRED); |
| 51 | 51 |
| 52 document.getElementById('textarea').focus(); | 52 document.getElementById('textarea').focus(); |
| 53 testKeyDownInputType('Enter', [], 'insertLineBreak', 'insertLineBreak'); | 53 testKeyDownInputType('Enter', [], 'insertLineBreak', 'insertLineBreak'); |
| 54 testKeyDownInputType('Enter', ['shiftKey'], 'insertLineBreak', 'insertLineBr
eak'); | 54 testKeyDownInputType('Enter', ['shiftKey'], 'insertLineBreak', 'insertLineBr
eak'); |
| 55 | 55 |
| 56 editable.focus(); | 56 editable.focus(); |
| 57 testKeyDownInputType('Enter', [], 'insertParagraph', 'insertParagraph'); | 57 testKeyDownInputType('Enter', [], 'insertParagraph', 'insertParagraph'); |
| 58 testKeyDownInputType('Enter', ['shiftKey'], 'insertLineBreak', 'insertLineBr
eak'); | 58 testKeyDownInputType('Enter', ['shiftKey'], 'insertLineBreak', 'insertLineBr
eak'); |
| 59 | 59 |
| 60 // Deletion | 60 // Deletion |
| (...skipping 19 matching lines...) Expand all Loading... |
| 80 testKeyDownInputType('z', ['ctrlKey', 'shiftKey'], 'historyRedo'); | 80 testKeyDownInputType('z', ['ctrlKey', 'shiftKey'], 'historyRedo'); |
| 81 } | 81 } |
| 82 // Move command should not generate input events. | 82 // Move command should not generate input events. |
| 83 testKeyDownInputType('ArrowLeft', [], NO_INPUT_EVENT_FIRED); | 83 testKeyDownInputType('ArrowLeft', [], NO_INPUT_EVENT_FIRED); |
| 84 testKeyDownInputType('ArrowLeft', ['shiftKey'], NO_INPUT_EVENT_FIRED); | 84 testKeyDownInputType('ArrowLeft', ['shiftKey'], NO_INPUT_EVENT_FIRED); |
| 85 testKeyDownInputType('Home', [], NO_INPUT_EVENT_FIRED); | 85 testKeyDownInputType('Home', [], NO_INPUT_EVENT_FIRED); |
| 86 }, 'Testing beforeinput inputType'); | 86 }, 'Testing beforeinput inputType'); |
| 87 </script> | 87 </script> |
| 88 </body> | 88 </body> |
| 89 </html> | 89 </html> |
| OLD | NEW |