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

Side by Side 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, 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
OLDNEW
(Empty)
1 <!DOCTYPE html>
msw 2017/06/30 20:17:29 Someone more familiar with test html helper files
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 done = false;
13 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.
14 return new Promise((resolve, reject) => {
15 const register = () => {
16 window.setTimeout(() => {
17 if (done) {
18 resolve();
19 } else {
20 register();
21 }
22 }, 100);
23 };
24 register();
25 }).then(() => {
26 window.domAutomationController.send(container().innerHTML);
27 });
28 };
29
30 function isMacOSFullscreenShortcut(e) {
31 return e.metaKey &&
32 e.ctrlKey &&
33 !e.altKey &&
34 !e.shiftKey &&
35 e.code == "KeyF";
36 }
37
38 function isF11FullscreenShortcut(e) {
39 return !e.metaKey &&
40 !e.ctrlKey &&
41 !e.altKey &&
42 !e.shiftKey &&
43 e.code == "F11";
44 }
45
46 function isBrowserFullscreenShortcut(e) {
47 return isMacOSFullscreenShortcut(e) ||
48 isF11FullscreenShortcut(e);
49 }
50
51 function container() {
52 return document.getElementById('container');
53 }
54
55 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.
56 container().innerHTML += t + ' ' + e.code + '\n';
57 e.preventDefault();
58 }
59
60 function init() {
61 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.
62 if (e.code == 'KeyS') {
63 container().webkitRequestFullscreen();
64 } 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.
65 return;
66 }
67 consumeEvent('keydown', e);
68 });
69
70 document.addEventListener('keyup', (e) => {
71 if (isBrowserFullscreenShortcut(e)) {
72 return;
73 }
74 consumeEvent('keyup', e);
75
76 if (e.code == 'KeyX') {
77 done = true;
78 }
79 });
80
81 document.addEventListener('keypress', (e) => {
82 consumeEvent('keypress', e);
83 });
84 }
85 </script>
86 </head>
87 <body onload='init()'>
88 <div id='container'>
89 </div>
90 </body>
91 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698