Index: chrome/test/data/keyboardevent_code_test.html |
diff --git a/chrome/test/data/keyboardevent_code_test.html b/chrome/test/data/keyboardevent_code_test.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d05066ef0e8b119cb130d98a79c650df9971247b |
--- /dev/null |
+++ b/chrome/test/data/keyboardevent_code_test.html |
@@ -0,0 +1,48 @@ |
+<!DOCTYPE html> |
+<!-- |
+ The html / js to help testing keyboard events. It receives keyboard events and |
+ writes the key codes to /html/body/div[@id='container']. Once KeyX is |
+ received, it sends the recorded key codes to window.domAutomationController. |
+--> |
+<html> |
+ <head> |
+ <title>KeyboardEvent.code Test</title> |
+ <script> |
+ let done = false; |
+ |
+ function report() { |
+ return new Promise((resolve, reject) => { |
+ const register = () => { |
+ window.setTimeout(() => { |
+ if (done) { |
+ resolve(); |
+ } else { |
+ register(); |
+ } |
+ }, 100); |
+ } |
+ register(); |
+ }).then(() => { |
+ window.domAutomationController.send(container().innerHTML); |
+ }); |
+ } |
+ |
+ function container() { |
+ return document.getElementById('container'); |
+ } |
+ |
+ function init() { |
+ document.addEventListener('keypress', (e) => { |
+ container().innerHTML += e.code + '\n'; |
+ if (e.code == 'KeyX') { |
+ done = true; |
+ } |
+ }); |
+ } |
+ </script> |
+ </head> |
+ <body onload='init()'> |
+ <div id='container'> |
+ </div> |
+ </body> |
+</html> |