Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(510)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-keyboard.html

Issue 2074423004: [InputEvent] Dispatch 'input' event for ContentEditable and typing on Input element (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tkent's review Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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="txt"> 9 <input type="text" id="txt">
10 <script> 10 <script>
11 test(function() { 11 test(function() {
12 var lastBeforeInputType = '';
12 var lastInputType = ''; 13 var lastInputType = '';
13 var txt = document.getElementById('txt'); 14 var txt = document.getElementById('txt');
14 txt.addEventListener('beforeinput', function(event) { 15 txt.addEventListener('beforeinput', function(event) {
16 assert_true(event instanceof InputEvent);
17 assert_false(event.isComposing);
18 lastBeforeInputType = event.inputType;
19 });
20 txt.addEventListener('input', function(event) {
21 assert_true(event instanceof InputEvent);
22 assert_false(event.isComposing);
15 lastInputType = event.inputType; 23 lastInputType = event.inputType;
16 }); 24 });
17 if (!window.eventSender) { 25 if (!window.eventSender) {
18 document.write('This test requires eventSender'); 26 document.write('This test requires eventSender');
19 } else { 27 } else {
20 var kNoBeforeInputFired = 'noBeforeInputFired'; 28 var kNoInputEventFired = 'noInputEventFired';
21 function testKeyDownInputType(key, modifiers, inputType) { 29 function testKeyDownInputType(key, modifiers, inputType) {
22 lastInputType = kNoBeforeInputFired; 30 lastBeforeInputType = kNoInputEventFired;
31 lastInputType = kNoInputEventFired;
23 eventSender.keyDown(key, modifiers); 32 eventSender.keyDown(key, modifiers);
33 assert_equals(lastBeforeInputType, inputType, `${modifiers.toString( )}+${key} should produce beforeInputType: ${inputType}`);
24 assert_equals(lastInputType, inputType, `${modifiers.toString()}+${k ey} should produce inputType: ${inputType}`); 34 assert_equals(lastInputType, inputType, `${modifiers.toString()}+${k ey} should produce inputType: ${inputType}`);
25 } 35 }
26 36
27 txt.focus(); 37 txt.focus();
28 // Typing 38 // Typing
29 testKeyDownInputType('a', [], 'insertText'); 39 testKeyDownInputType('a', [], 'insertText');
30 testKeyDownInputType('6', [], 'insertText'); 40 testKeyDownInputType('6', [], 'insertText');
31 testKeyDownInputType('backspace', [], 'deleteContent'); 41 testKeyDownInputType('backspace', [], 'deleteContent');
32 testKeyDownInputType('l', ['shiftKey'], 'insertText'); 42 testKeyDownInputType('l', ['shiftKey'], 'insertText');
33 testKeyDownInputType('w', ['shiftKey'], 'insertText'); 43 testKeyDownInputType('w', ['shiftKey'], 'insertText');
34 44
35 // Keyboard commands 45 // Keyboard commands
36 var isMacOS = (navigator.userAgent.indexOf('Mac OS X') != -1); 46 var isMacOS = (navigator.userAgent.indexOf('Mac OS X') != -1);
37 if (!isMacOS) { 47 if (!isMacOS) {
38 // MacOS's eventSender does not work on hot keys other than arrows. 48 // MacOS's eventSender does not work on hot keys other than arrows.
39 testKeyDownInputType('z', ['ctrlKey'], 'undo'); 49 testKeyDownInputType('z', ['ctrlKey'], 'undo');
40 testKeyDownInputType('z', ['ctrlKey', 'shiftKey'], 'redo'); 50 testKeyDownInputType('z', ['ctrlKey', 'shiftKey'], 'redo');
41 } 51 }
42 // Move command should not generate input events. 52 // Move command should not generate input events.
43 testKeyDownInputType('leftArrow', [], kNoBeforeInputFired); 53 testKeyDownInputType('leftArrow', [], kNoInputEventFired);
44 testKeyDownInputType('leftArrow', ['shiftKey'], kNoBeforeInputFired); 54 testKeyDownInputType('leftArrow', ['shiftKey'], kNoInputEventFired);
45 testKeyDownInputType('home', [], kNoBeforeInputFired); 55 testKeyDownInputType('home', [], kNoInputEventFired);
46 } 56 }
47 }, 'Testing beforeinput inputType'); 57 }, 'Testing beforeinput inputType');
48 </script> 58 </script>
49 </body> 59 </body>
50 </html> 60 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698