REGRESSION (r230523): Caps lock indicator not shown in password field
[WebKit-https.git] / LayoutTests / fast / events / detect-caps-lock.html
1 <!DOCTYPE html>
2 <html><head></head>
3     <body>
4         <p>This test verifies that the function WebCore::currentCapsLockState() returns true when Caps Lock is on.</p>
5         <input type="password"></input>
6         <div id="log"></div>
7         
8         <script>
9             function log(msg) {
10                 document.getElementById("log").innerHTML+= msg + "<br>";
11             }
12         
13             function keyDown(e) {
14                 if (e.key == "q")
15                     return;
16                 if (window.internals) {
17                     log(messages[messageCount++]);
18                     if (window.internals.capsLockIsOn())
19                         log("CapsLock is on.");
20                     else
21                         log("CapsLock is not on.");
22                 }
23             }
24
25             function keyUp(e) {
26                 if (e.key == "q")
27                     testRunner.notifyDone();
28                 if (window.internals) {
29                     if (window.internals.capsLockIsOn())
30                         log("CapsLock is on.");
31                     else
32                         log("CapsLock is not on.");
33                 }
34             }
35
36             var messages = ["1. Press Caps Lock key when view is active, make view inactive, make view active again, press Caps Lock key.",
37                             "2. Press Caps Lock key in inactive view, make view active, press Caps Lock key.",
38                             "3. Press Caps Lock key when view is active, press Caps Lock key when view is active.",
39                             "4. Press Caps Lock key when view is inactive, press Caps Lock key when view inactive."];
40             var messageCount = 0;
41         
42             var input = document.getElementsByTagName("input")[0];
43             input.addEventListener('keydown', keyDown, false);
44             input.addEventListener('keyup', keyUp, false);
45             input.focus();
46             
47             if (window.testRunner) {
48                 testRunner.dumpAsText();
49                 testRunner.waitUntilDone();
50                 
51                 testRunner.toggleCapsLock();
52                 testRunner.setWindowIsKey(false);
53                 testRunner.setWindowIsKey(true);
54                 testRunner.toggleCapsLock();
55                 
56                 testRunner.setWindowIsKey(false);
57                 testRunner.toggleCapsLock();
58                 testRunner.setWindowIsKey(true);
59                 testRunner.toggleCapsLock();
60
61                 testRunner.setWindowIsKey(true);
62                 testRunner.toggleCapsLock();
63                 testRunner.toggleCapsLock();
64
65                 testRunner.setWindowIsKey(false);
66                 testRunner.toggleCapsLock();
67                 testRunner.toggleCapsLock();
68
69                 eventSender.keyDown("q", []);
70             }
71         </script>
72     </body>
73 </html>