| <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| <html> |
| <head> |
| <script src="../resources/accessibility-helper.js"></script> |
| <script src="../resources/js-test.js"></script> |
| <script src="../resources/ui-helper.js"></script> |
| </head> |
| <body> |
| |
| <input type="password" id="password-field"> |
| |
| <script> |
| var output = "This test ensures that password notifications are spaced out in time in no less than a prefixed interval.\n\n"; |
| |
| var notificationsCount = 0; |
| var lastNotificationTime = Date.now(); |
| var interval = 25; // Notifications shouldn't come in less than 25 milliseconds. |
| function notificationCallback(notification) { |
| if (notification != "AXValueChanged") |
| return; |
| |
| now = Date.now(); |
| elapsed = now - lastNotificationTime; |
| lastNotificationTime = now; |
| output += expect("elapsed >= interval", "true"); |
| |
| ++notificationsCount; |
| } |
| |
| if (window.accessibilityController) { |
| window.jsTestIsAsync = true; |
| document.getElementById("password-field").focus(); |
| var field = accessibilityController.accessibleElementById("password-field"); |
| field.addNotificationListener(notificationCallback); |
| |
| var value = field.stringValue; |
| var valueLength = value.length; |
| output += `Field value length: ${valueLength}\n`; |
| setTimeout(async () => { |
| UIHelper.typeCharacter("a"); |
| UIHelper.typeCharacter("b"); |
| UIHelper.typeCharacter("c"); |
| |
| await waitFor(() => { |
| return notificationsCount == 3 && field.stringValue.length == valueLength + 3; |
| }); |
| value = field.stringValue; |
| output += `Field value length: ${value.length}\n`; |
| |
| debug(output); |
| finishJSTest(); |
| }, 0); |
| } |
| </script> |
| </body> |
| </html> |