OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <!-- |
| 3 The html / js to help testing keyboard events. It receives keyboard events and |
| 4 writes the key codes to /html/body/div[@id='container']. Once KeyX is |
| 5 received, it sends the recorded key codes to window.domAutomationController. |
| 6 --> |
| 7 <html> |
| 8 <head> |
| 9 <title>KeyboardEvent.code Test</title> |
| 10 <script> |
| 11 let done = false; |
| 12 |
| 13 function report() { |
| 14 return new Promise((resolve, reject) => { |
| 15 const register = () => { |
| 16 window.setTimeout(() => { |
| 17 if (done) { |
| 18 resolve(); |
| 19 } else { |
| 20 register(); |
| 21 } |
| 22 }, 100); |
| 23 } |
| 24 register(); |
| 25 }).then(() => { |
| 26 window.domAutomationController.send(container().innerHTML); |
| 27 }); |
| 28 } |
| 29 |
| 30 function container() { |
| 31 return document.getElementById('container'); |
| 32 } |
| 33 |
| 34 function init() { |
| 35 document.addEventListener('keypress', (e) => { |
| 36 container().innerHTML += e.code + '\n'; |
| 37 if (e.code == 'KeyX') { |
| 38 done = true; |
| 39 } |
| 40 }); |
| 41 } |
| 42 </script> |
| 43 </head> |
| 44 <body onload='init()'> |
| 45 <div id='container'> |
| 46 </div> |
| 47 </body> |
| 48 </html> |
OLD | NEW |