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 <input type="text" id="txt"> | |
10 <script> | |
11 test(function() { | |
12 var lastInputType = ""; | |
yosin_UTC9
2016/04/13 06:13:08
Please use single-quote in script fragment since o
chongz
2016/04/13 23:53:08
Done.
| |
13 var txt = document.getElementById('txt'); | |
14 txt.addEventListener('beforeinput', function(e) { | |
yosin_UTC9
2016/04/13 06:13:09
nit: Please avoid to use single-letter variable na
chongz
2016/04/13 23:53:08
Done.
| |
15 lastInputType = e.inputType; | |
16 }); | |
17 if (!window.eventSender) { | |
18 document.write('This test requires eventSender'); | |
19 } else { | |
20 var kNoBeforeInputFired = "noBeforeInputFired"; | |
21 function testKeyDownInputType(key, modifiers, inputType) { | |
22 lastInputType = kNoBeforeInputFired; | |
23 eventSender.keyDown(key, modifiers); | |
24 assert_equals(lastInputType, inputType, "${modifiers.toString()}+${k ey} should produce inputType: ${inputType}"); | |
25 } | |
26 | |
27 txt.focus(); | |
28 // Typing | |
29 testKeyDownInputType('a', [], 'insertText'); | |
30 testKeyDownInputType('6', [], 'insertText'); | |
31 testKeyDownInputType('backspace', [], 'deleteContent'); | |
32 testKeyDownInputType('l', ['shiftKey'], 'insertText'); | |
33 testKeyDownInputType('w', ['shiftKey'], 'insertText'); | |
34 | |
35 // Keyboard commands | |
36 var isMacOS = (navigator.userAgent.indexOf('Mac OS X') != -1); | |
37 if (!isMacOS) { | |
38 // MacOS's eventSender does not work on hot keys other than arrows. | |
39 testKeyDownInputType('z', ['ctrlKey'], 'undo'); | |
40 testKeyDownInputType('z', ['ctrlKey', 'shiftKey'], 'redo'); | |
41 } | |
42 // Move command should not generate input events. | |
43 testKeyDownInputType('leftArrow', [], kNoBeforeInputFired); | |
44 testKeyDownInputType('leftArrow', ['shiftKey'], kNoBeforeInputFired); | |
45 testKeyDownInputType('home', [], kNoBeforeInputFired); | |
46 } | |
47 }, "Testing beforeinput inputType"); | |
yosin_UTC9
2016/04/13 06:13:09
Please use single-quote in script fragment since o
chongz
2016/04/13 23:53:08
Done.
| |
48 </script> | |
49 </body> | |
50 </html> | |
OLD | NEW |