<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="../../resources/ui-helper.js"></script>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<input type=password>
<script>

jsTestIsAsync = true;

description("Verify that changing a password input's type updates secure input state.");

var passwordInput = document.getElementsByTagName("input")[0];

debug("A password input is focused:");
passwordInput.focus();

UIHelper.ensurePresentationUpdate().then(() => {
    shouldBe("testRunner.secureEventInputIsEnabled", "true");
    debug("\nAfter changing the type to text:");
    passwordInput.type = "text";
})

.then(() => UIHelper.ensurePresentationUpdate())
.then(() => {
    shouldBe("testRunner.secureEventInputIsEnabled", "false");
    debug("\nAfter changing the type back to password:");
    passwordInput.type = "password";
})

.then(() => UIHelper.ensurePresentationUpdate())
.then(() => {
    shouldBe("testRunner.secureEventInputIsEnabled", "true");
    finishJSTest();
});

</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>
