Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(328)

Unified Diff: chrome/test/data/keyboardevent_code_test.html

Issue 2939283002: Use wScan instead of wVk to ensure webpage can get correct DOM CodeString (Closed)
Patch Set: Include 2946103002 Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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>

Powered by Google App Engine
This is Rietveld 408576698