Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'android' OR os == 'android'
- Manifest: toolkit/components/passwordmgr/test/mochitest/mochitest.toml
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test autofilling documents restored from the back/forward cache (bfcache)</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body onload="test_crossOriginBfcacheRestore();">
<p id="display"></p>
<div id="content">
<a id="next" href="https://example.org/tests/toolkit/components/passwordmgr/test/mochitest/file_history_back.html" target="loginWin">Next</a>
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
SimpleTest.waitForExplicitFinish();
/*
* The test opens a new window and updates login information. Then
* a new page is loaded and it goes immediately back. The initial page
* should be coming out from the bfcache and the form control values should be
* the ones filled during the initial load.
*/
async function test_crossOriginBfcacheRestore() {
// If Fission is disabled, the pref is no-op.
await SpecialPowers.pushPrefEnv({set: [["fission.bfcacheInParent", true]]});
var bc = new BroadcastChannel("form_basic_bfcache");
window.open("form_basic_bfcache.html", "", "noopener");
var pageshowCount = 0;
bc.onmessage = function(event) {
if (event.data.type == "pageshow") {
++pageshowCount;
if (pageshowCount == 1) {
is(event.data.persisted, false, "Initial load");
bc.postMessage("nextpage");
} else if (pageshowCount == 2) {
is(event.data.persisted, true, "Should have persisted the page.");
bc.postMessage("close");
}
} else if (event.data.type == "is") {
is(event.data.value1, event.data.value2, event.data.message);
} else if (event.data.type == "ok") {
is(event.data.value, event.data.message);
} else if (event.data == "closed") {
bc.close();
SimpleTest.finish();
}
}
}
</script>
</pre>
</body>
</html>