Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <meta charset="utf-8"> | |
| 3 <title>InputEvent have data when typing on textarea and contenteditable</title> | |
| 4 <script src="/resources/testharness.js"></script> | |
| 5 <script src="/resources/testharnessreport.js"></script> | |
| 6 <p>To manually run this test, please follow the steps below:<br/> | |
| 7 1. Focus the first box and press key 'a' and then 'b'.<br/> | |
| 8 2. Focus the second box and press key 'c' and then 'd'.<br/> | |
| 9 <br/> | |
| 10 If a "PASS" result appears the test passes, otherwise it fails</p> | |
| 11 <textarea id='plain'></textarea> | |
| 12 <div id='rich' style='border-style: solid;' contenteditable></div> | |
| 13 <script> | |
| 14 async_test(t => { | |
| 15 const expectedResult = [ | |
| 16 'plain-beforeinput-a', | |
| 17 'plain-input-a', | |
| 18 'plain-beforeinput-b', | |
| 19 'plain-input-b', | |
| 20 'rich-beforeinput-c', | |
| 21 'rich-input-c', | |
| 22 'rich-beforeinput-d', | |
| 23 'rich-input-d', | |
| 24 ]; | |
| 25 let eventCounter = 0; | |
| 26 | |
| 27 ['plain', 'rich'].forEach(targetId => { | |
|
foolip
2017/06/01 13:54:21
Optional nit: I like to use `for (x of [...])` in
chongz
2017/06/01 15:34:13
Done.
| |
| 28 ['beforeinput', 'input'].forEach(eventType => { | |
| 29 document.getElementById(targetId).addEventListener(eventType, t.step _func(e => { | |
| 30 assert_equals(`${targetId}-${eventType}-${e.data}`, expectedResu lt[eventCounter]); | |
| 31 ++eventCounter; | |
| 32 if (eventCounter >= expectedResult.length) | |
|
foolip
2017/06/01 13:54:21
nit: nothing that happens after the t.done() call
chongz
2017/06/01 15:34:13
Done.
| |
| 33 t.done(); | |
| 34 })); | |
| 35 }); | |
| 36 }); | |
| 37 }) | |
| 38 </script> | |
| OLD | NEW |