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