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

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

Issue 2922773002: Add BrowserCommandController Interactive Test (Closed)
Patch Set: msvc does not support recursive #if 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/fullscreen_keyboardlock/fullscreen_keyboardlock.html
diff --git a/chrome/test/data/fullscreen_keyboardlock/fullscreen_keyboardlock.html b/chrome/test/data/fullscreen_keyboardlock/fullscreen_keyboardlock.html
new file mode 100644
index 0000000000000000000000000000000000000000..9969639f98f527fb116d42115563277bc426ba84
--- /dev/null
+++ b/chrome/test/data/fullscreen_keyboardlock/fullscreen_keyboardlock.html
@@ -0,0 +1,91 @@
+<!DOCTYPE html>
msw 2017/06/30 20:17:29 Someone more familiar with test html helper files
+<!--
+ 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 done = false;
+ function report() {
msw 2017/06/30 20:17:29 nit: Is "report" a common name for this type of fu
Hzj_jie 2017/07/01 01:56:48 Done.
+ return new Promise((resolve, reject) => {
+ const register = () => {
+ window.setTimeout(() => {
+ if (done) {
+ resolve();
+ } else {
+ register();
+ }
+ }, 100);
+ };
+ register();
+ }).then(() => {
+ window.domAutomationController.send(container().innerHTML);
+ });
+ };
+
+ 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(t, e) {
msw 2017/06/30 20:17:29 nit: give a better name for the type/title than 't
Hzj_jie 2017/07/01 01:56:48 Done.
+ container().innerHTML += t + ' ' + e.code + '\n';
+ e.preventDefault();
+ }
+
+ function init() {
+ document.addEventListener('keydown', (e) => {
msw 2017/06/30 20:17:29 nit: add a comment explaining the purpose of this
Hzj_jie 2017/07/01 01:56:48 Done.
+ if (e.code == 'KeyS') {
+ container().webkitRequestFullscreen();
+ } else if (isBrowserFullscreenShortcut(e)) {
msw 2017/06/30 20:17:29 aside q: Can websites preventDefault on the fullsc
Hzj_jie 2017/07/01 01:56:48 No, otherwise the "ExceptForF11" test will fail. B
msw 2017/07/05 19:11:44 Actually, it might be interesting to construct a t
Hzj_jie 2017/07/07 23:18:10 Yes, I can do it in a separated change.
+ return;
+ }
+ consumeEvent('keydown', e);
+ });
+
+ document.addEventListener('keyup', (e) => {
+ if (isBrowserFullscreenShortcut(e)) {
+ return;
+ }
+ consumeEvent('keyup', e);
+
+ if (e.code == 'KeyX') {
+ done = true;
+ }
+ });
+
+ document.addEventListener('keypress', (e) => {
+ consumeEvent('keypress', e);
+ });
+ }
+ </script>
+ </head>
+ <body onload='init()'>
+ <div id='container'>
+ </div>
+ </body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698