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

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

Issue 2922773002: Add BrowserCommandController Interactive Test (Closed)
Patch Set: Resolve review comments Created 3 years, 5 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
« no previous file with comments | « chrome/test/BUILD.gn ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/fullscreen_keyboardlock.html
diff --git a/chrome/test/data/fullscreen_keyboardlock.html b/chrome/test/data/fullscreen_keyboardlock.html
new file mode 100644
index 0000000000000000000000000000000000000000..7e88d0dbc60f7f9f18eb0ce77783357f9107d647
--- /dev/null
+++ b/chrome/test/data/fullscreen_keyboardlock.html
@@ -0,0 +1,102 @@
+<!DOCTYPE html>
+<!--
+ The html/js to help testing keyboard events. It
+ - receives keybord events and preventDefault(),
+ - writes the key codes to /html/body/div[@id='container'],
+ - sends the key codes to window.domAutomationController once KeyX is received.
+-->
+<html>
+ <head>
+ <title>Fullscreen Keyboard Lock Test</title>
+ <script>
+ let x_pressed = false;
+ let report_called = false;
+
+ function processResult() {
+ if (x_pressed && report_called) {
+ window.domAutomationController.send(container().innerHTML);
+ }
+ }
+
+ function getKeyEventReport() {
+ report_called = true;
+ processResult();
+ }
+
+ function isMacOSFullscreenShortcut(e) {
+ return e.metaKey &&
+ e.ctrlKey &&
+ !e.altKey &&
+ !e.shiftKey &&
+ e.code == "KeyF";
+ }
+
+ function isF11FullscreenShortcut(e) {
+ return !e.metaKey &&
+ !e.ctrlKey &&
+ !e.altKey &&
+ !e.shiftKey &&
+ e.code == "F11";
+ }
+
+ function isBrowserFullscreenShortcut(e) {
+ return isMacOSFullscreenShortcut(e) ||
+ isF11FullscreenShortcut(e);
+ }
+
+ function container() {
+ return document.getElementById('container');
+ }
+
+ function consumeEvent(type, e) {
+ if (type == 'keydown' &&
+ !e.code.startsWith("Control") &&
+ !e.code.startsWith("Shift") &&
+ !e.code.startsWith("Alt") &&
+ !e.code.startsWith("Meta")) {
+ container().innerHTML +=
+ e.code +
+ ' ctrl:' + e.getModifierState('Control') +
+ ' shift:' + e.getModifierState('Shift') +
+ ' alt:' + e.getModifierState('Alt') +
+ ' meta:' + e.getModifierState('Meta') + '\n';
+ }
+ e.preventDefault();
+ }
+
+ function init() {
+ document.addEventListener('keydown', (e) => {
+ // The web content triggers fullscreen on the "S" key down event.
+ if (e.code == 'KeyS') {
+ container().webkitRequestFullscreen();
+ } else if (isBrowserFullscreenShortcut(e)) {
+ // Web page can consume fullscreen shortcut when the page is in
+ // window mode, but it's not expected in test cases.
+ return;
+ }
+ consumeEvent('keydown', e);
+ });
+
+ document.addEventListener('keyup', (e) => {
+ if (isBrowserFullscreenShortcut(e)) {
+ return;
+ }
+ consumeEvent('keyup', e);
+
+ if (e.code == 'KeyX') {
+ x_pressed = true;
+ processResult();
+ }
+ });
+
+ document.addEventListener('keypress', (e) => {
+ consumeEvent('keypress', e);
+ });
+ }
+ </script>
+ </head>
+ <body onload='init()'>
+ <div id='container'>
+ </div>
+ </body>
+</html>
« no previous file with comments | « chrome/test/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698