REGRESSION (r238078): Do not draw caps lock indicator when Strong Password button...
[WebKit-https.git] / LayoutTests / fast / forms / auto-fill-button / caps-lock-indicator-should-not-be-visible-when-auto-fill-strong-password-button-is-visible.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../../resources/ui-helper.js"></script>
5 <script>
6 if (window.testRunner)
7     testRunner.waitUntilDone();
8 </script>
9 </head>
10 <body>
11 <p>This tests that the caps lock indicator is not visible when the Strong Password AutoFill button is shown. It can only be tested in the test tool.</p>
12 <input type="password" value="A quick brown fox jumped over the lazy dog.">
13 <script>
14 function done()
15 {
16     if (window.testRunner)
17         testRunner.notifyDone();
18 }
19
20 function handleCapsLockEnabled(event)
21 {
22     console.assert(event.key === "CapsLock");
23     // FIXME: For some reason it takes up to 100ms for the caps lock indicator to be painted (why?).
24     window.setTimeout(done, 100);
25 }
26
27 async function runTest()
28 {
29     if (!window.internals)
30         return;
31
32     let input = document.querySelector("input");
33     internals.setAutofilled(input, true);
34     internals.setShowAutoFillButton(input, "StrongPassword");
35
36     function handleFocus(event) {
37         console.assert(event.target === input);
38         input.addEventListener("keydown", handleCapsLockEnabled, { once: true });
39         UIHelper.toggleCapsLock();
40     }
41     input.addEventListener("focus", handleFocus, { once: true });
42     UIHelper.activateElement(input);
43 }
44
45 runTest();
46 </script>
47 </body>
48 </html>