blob: cd63be706dd09c9d16e1da6292e2682917cdd6f0 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<input type=password>
<iframe srcdoc="<input type=text>"></iframe>
<script>
description("Verify that changing focus to a different frame updates secure input state.");
jsTestIsAsync = true;
window.onload = function() {
passwordInput = document.getElementsByTagName("input")[0];
iframeElement = document.getElementsByTagName("iframe")[0];
textInput = frames[0].document.getElementsByTagName("input")[0];
debug("Initial state, no selection:");
shouldBe("testRunner.secureEventInputIsEnabled", "false");
debug("\nA password input is focused:");
passwordInput.focus();
shouldBe("document.activeElement", "passwordInput");
shouldBe("testRunner.secureEventInputIsEnabled", "true");
debug("\nA regular text input is focused with a mouse click:");
eventSender.mouseMoveTo(iframeElement.offsetLeft + textInput.offsetLeft + 5, iframeElement.offsetTop + textInput.offsetTop + 5);
eventSender.mouseDown(0);
eventSender.mouseUp(0);
shouldBe("frames[0].document.activeElement", "textInput");
shouldBe("testRunner.secureEventInputIsEnabled", "false");
debug("\nA password input is focused again with a mouse click:");
eventSender.mouseMoveTo(passwordInput.offsetLeft + 5, passwordInput.offsetTop + 5);
eventSender.mouseDown(0);
eventSender.mouseUp(0);
shouldBe("document.activeElement", "passwordInput");
shouldBe("testRunner.secureEventInputIsEnabled", "true");
debug("\nA regular text input is focused with a tab:");
eventSender.keyDown("\t");
shouldBe("frames[0].document.activeElement", "textInput");
shouldBe("testRunner.secureEventInputIsEnabled", "false");
debug("\nA password input is focused again with a tab:");
eventSender.keyDown("\t", ["Shift"]);
shouldBe("document.activeElement", "passwordInput");
shouldBe("testRunner.secureEventInputIsEnabled", "true");
debug("\nFocus is made empty:");
eventSender.mouseMoveTo(1, 1);
eventSender.mouseDown(0);
eventSender.mouseUp(0);
shouldBe("document.activeElement", "document.body");
shouldBe("testRunner.secureEventInputIsEnabled", "false");
finishJSTest();
}
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>