Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <title>InputEvent: beforeinput order on typing and command</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 eventList = ['keydown', 'keypress', 'beforeinput', 'input', 'keyup']; | |
| 13 var expectedEventOrder = [ | |
| 14 // Pressing 'a'. | |
| 15 'keydown', 'keypress', 'beforeinput', 'input', 'keyup', | |
| 16 // Pressing Ctrl+z, eventSender.keyDown won't send 'keydown' and 'keyup' for Ctrl. | |
|
ojan
2016/04/16 00:11:45
Make this a TODO?
chongz
2016/04/18 22:54:47
Actually I realized this should be the correct beh
| |
| 17 /*'keydown',*/ 'keydown', 'beforeinput', 'input', 'keyup', /*'keyup',*/ | |
| 18 ]; | |
| 19 var actualEventOrder = []; | |
| 20 var txt = document.getElementById('txt'); | |
| 21 eventList.forEach(function(eventType) { | |
| 22 txt.addEventListener(eventType, function(event) { | |
| 23 actualEventOrder.push(event.type); | |
| 24 }); | |
| 25 }); | |
| 26 if (!window.eventSender) { | |
| 27 document.write('This test requires eventSender'); | |
| 28 } else { | |
| 29 txt.focus(); | |
| 30 eventSender.keyDown('a'); | |
| 31 var isMacOSX = navigator.userAgent.indexOf('Mac OS X') != -1; | |
| 32 if (!isMacOSX) { | |
| 33 // MacOS's eventSender does not work on hot keys other than arrows. | |
| 34 eventSender.keyDown('z', ['ctrlKey']); | |
| 35 assert_array_equals(actualEventOrder, expectedEventOrder, actualEven tOrder.toString()); | |
| 36 } | |
| 37 } | |
| 38 }, 'Testing beforeinput order on typing and command'); | |
| 39 </script> | |
| 40 </body> | |
| 41 </html> | |
| OLD | NEW |