| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../../resources/ui-helper.js"></script> |
| <script> |
| if (window.testRunner) |
| testRunner.waitUntilDone(); |
| </script> |
| </head> |
| <body> |
| <p>This tests that the caps lock indicator is visible after hiding the Strong Password AutoFill button. It can only be tested in the test tool.</p> |
| <input type="password" value="A quick brown fox jumped over the lazy dog."> |
| <script> |
| function done() |
| { |
| if (window.testRunner) |
| testRunner.notifyDone(); |
| } |
| |
| function handleCapsLockEnabled(event) |
| { |
| console.assert(event.key === "CapsLock"); |
| let input = document.querySelector("input"); |
| internals.setAutofilled(input, false); |
| internals.setShowAutoFillButton(input, "None"); |
| |
| // Move the caret to the beginning of the field to ensure consistent test results. |
| input.setSelectionRange(0, 0); |
| |
| // FIXME: For some reason it takes up to 100ms for the caps lock indicator to be painted (why?). |
| window.setTimeout(done, 100); |
| } |
| |
| async function runTest() |
| { |
| if (!window.internals) |
| return; |
| |
| let input = document.querySelector("input"); |
| internals.setAutofilled(input, true); |
| internals.setShowAutoFillButton(input, "StrongPassword"); |
| |
| function handleFocus(event) { |
| console.assert(event.target === input); |
| input.addEventListener("keydown", handleCapsLockEnabled, { once: true }); |
| UIHelper.toggleCapsLock(); |
| } |
| input.addEventListener("focus", handleFocus, { once: true }); |
| UIHelper.activateElement(input); |
| } |
| |
| runTest(); |
| </script> |
| </body> |
| </html> |