blob: 7756ddce0768efa9af57234d0fe14054b6f03c9f [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../resources/js-test.js"></script>
</head>
<body>
<input id="password" type="password" value="Secret">
<script>
description("This tests that AXValue, caret position and text selection are reported correctly for password fields.");
if (window.accessibilityController) {
let password = document.getElementById("password");
let textLength = password.value.length;
password.focus();
window.axPassword = accessibilityController.accessibleElementById("password");
// Initially the caret should be at the beginning of the field.
shouldBe("axPassword", "axPassword.selectionAnchorObject");
shouldBe("axPassword", "axPassword.selectionFocusObject");
shouldBeZero("axPassword.selectionAnchorOffset");
shouldBeZero("axPassword.selectionFocusOffset");
// The password field should contain 6 bullets.
// (Bullet is the default mask character, not star.)
let axValue = "AXValue: " + new Array(textLength + 1).join(
String.fromCharCode(8226 /* Bullet symbol. */));
shouldBeEqualToString("axPassword.stringValue", axValue);
for (let start = 0; start < textLength; ++start) {
for (let end = start; end < textLength; ++end) {
password.setSelectionRange(start, end);
shouldBe("axPassword", "axPassword.selectionAnchorObject");
shouldBe("axPassword", "axPassword.selectionFocusObject");
shouldBeEqualToNumber("axPassword.selectionAnchorOffset", start);
shouldBeEqualToNumber("axPassword.selectionFocusOffset", end);
}
}
// Invalid range.
password.setSelectionRange(7, 0);
shouldBe("axPassword", "axPassword.selectionAnchorObject");
shouldBe("axPassword", "axPassword.selectionFocusObject");
shouldBeZero("axPassword.selectionAnchorOffset");
shouldBeZero("axPassword.selectionFocusOffset");
}
</script>
</body>
</html>