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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « chrome/test/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <!--
3 The html/js to help testing keyboard events. It
4 - receives keybord events and preventDefault(),
5 - writes the key codes to /html/body/div[@id='container'],
6 - sends the key codes to window.domAutomationController once KeyX is received.
7 -->
8 <html>
9 <head>
10 <title>Fullscreen Keyboard Lock Test</title>
11 <script>
12 let x_pressed = false;
13 let report_called = false;
14
15 function processResult() {
16 if (x_pressed && report_called) {
17 window.domAutomationController.send(container().innerHTML);
18 }
19 }
20
21 function getKeyEventReport() {
22 report_called = true;
23 processResult();
24 }
25
26 function isMacOSFullscreenShortcut(e) {
27 return e.metaKey &&
28 e.ctrlKey &&
29 !e.altKey &&
30 !e.shiftKey &&
31 e.code == "KeyF";
32 }
33
34 function isF11FullscreenShortcut(e) {
35 return !e.metaKey &&
36 !e.ctrlKey &&
37 !e.altKey &&
38 !e.shiftKey &&
39 e.code == "F11";
40 }
41
42 function isBrowserFullscreenShortcut(e) {
43 return isMacOSFullscreenShortcut(e) ||
44 isF11FullscreenShortcut(e);
45 }
46
47 function container() {
48 return document.getElementById('container');
49 }
50
51 function consumeEvent(type, e) {
52 if (type == 'keydown' &&
53 !e.code.startsWith("Control") &&
54 !e.code.startsWith("Shift") &&
55 !e.code.startsWith("Alt") &&
56 !e.code.startsWith("Meta")) {
57 container().innerHTML +=
58 e.code +
59 ' ctrl:' + e.getModifierState('Control') +
60 ' shift:' + e.getModifierState('Shift') +
61 ' alt:' + e.getModifierState('Alt') +
62 ' meta:' + e.getModifierState('Meta') + '\n';
63 }
64 e.preventDefault();
65 }
66
67 function init() {
68 document.addEventListener('keydown', (e) => {
69 // The web content triggers fullscreen on the "S" key down event.
70 if (e.code == 'KeyS') {
71 container().webkitRequestFullscreen();
72 } else if (isBrowserFullscreenShortcut(e)) {
73 // Web page can consume fullscreen shortcut when the page is in
74 // window mode, but it's not expected in test cases.
75 return;
76 }
77 consumeEvent('keydown', e);
78 });
79
80 document.addEventListener('keyup', (e) => {
81 if (isBrowserFullscreenShortcut(e)) {
82 return;
83 }
84 consumeEvent('keyup', e);
85
86 if (e.code == 'KeyX') {
87 x_pressed = true;
88 processResult();
89 }
90 });
91
92 document.addEventListener('keypress', (e) => {
93 consumeEvent('keypress', e);
94 });
95 }
96 </script>
97 </head>
98 <body onload='init()'>
99 <div id='container'>
100 </div>
101 </body>
102 </html>
OLDNEW
« 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