diff options
Diffstat (limited to 'dom/html/test/forms/test_input_hasBeenTypePassword_navigation.html')
-rw-r--r-- | dom/html/test/forms/test_input_hasBeenTypePassword_navigation.html | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/dom/html/test/forms/test_input_hasBeenTypePassword_navigation.html b/dom/html/test/forms/test_input_hasBeenTypePassword_navigation.html new file mode 100644 index 0000000000..70a0f8427e --- /dev/null +++ b/dom/html/test/forms/test_input_hasBeenTypePassword_navigation.html @@ -0,0 +1,68 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=1330228 +--> +<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> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1330228">Mozilla Bug 1330228</a> +<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> |