<!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>
<input type=text>
<script>
jsTestIsAsync = true;

description("Verify that basic focusing/unfocusing updates secure input state.");

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

debug("Initial state, no selection:");
shouldBe("testRunner.secureEventInputIsEnabled", "false");

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

UIHelper.ensurePresentationUpdate().then(() => {
    shouldBe("testRunner.secureEventInputIsEnabled", "true");
    debug("\nA regular text input is focused:");
    textInput.focus();
})

.then(() => UIHelper.ensurePresentationUpdate())
.then(() => {
    shouldBe("testRunner.secureEventInputIsEnabled", "false");
    debug("\nA password input is focused again:");
    passwordInput.focus();
})

.then(() => UIHelper.ensurePresentationUpdate())
.then(() => {
    shouldBe("testRunner.secureEventInputIsEnabled", "true");
    finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>
