Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE HTML>
<html>
<!--
-->
<head>
<title>Test hasBeenTypePassword is used with bfcache</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<p id="display">
<iframe id="testframe" src="file_login_fields.html"></iframe>
</p>
<pre id="test">
<script type="application/javascript">
/** Test hasBeenTypePassword is used with bfcache **/
SimpleTest.waitForExplicitFinish();
function afterLoad() {
var iframeDoc = $("testframe").contentDocument;
/* change all the form controls */
iframeDoc.getElementById("un").value = "username";
iframeDoc.getElementById("pw1").value = "password1";
// Convert pw2 to a password field temporarily to test hasBeenTypePassword.
// We don't want the initial or final value to be type=password or we may
// not test the right scenario.
iframeDoc.getElementById("pw2").type = "password";
iframeDoc.getElementById("pw2").value = "password2";
iframeDoc.getElementById("pw2").type = "";
/* navigate the page */
$("testframe").setAttribute("onload", "afterNavigation()");
// Use a click on an <a> so that the current page is included in session history.
iframeDoc.getElementById("navigate").click();
}
addLoadEvent(afterLoad);
function afterNavigation() {
info("Navigated to a new document");
var iframeDoc = $("testframe").contentDocument;
$("testframe").setAttribute("onload", "afterBack()");
// Calling `history.back()` on the contentWindow from here doesn't use bfcache
// so call it from within the contentDocument.
iframeDoc.getElementById("back").click();
}
function afterBack() {
info("Should be back showing the first document from bfcache");
var iframeDoc = $("testframe").contentDocument;
is(iframeDoc.getElementById("un").value, "username",
"username field value remembered");
is(iframeDoc.getElementById("pw1").value, "",
"type=password field value not remembered");
is(iframeDoc.getElementById("pw2").value, "",
"former type=password field value not remembered");
SimpleTest.finish();
}
</script>
</pre>
</body>
</html>