blob: af107d145181e6bc2e4a4a081a7a8576ab0c3da8 [file] [edit]
<!-- webkit-test-runner [ UsesBackForwardCache=false dumpJSConsoleLogInStdErr=true ] -->
<!DOCTYPE html>
<html>
<head>
<script src="/js-test-resources/js-test.js"></script>
<script src="resources/navigation-utils.js"></script>
<script>
description("Nested iframe history navigation works correctly when back/forward cache is disabled.");
jsTestIsAsync = true;
const page = "opener";
var popup = null;
window.onload = function() {
popup = window.open("resources/back-iframe-popup.html");
}
var page1ShowCount = 0;
var page2ShowCount = 0;
window.onmessage = (event) => dispatchMessage(event.data, {
popup: {
load: () => debug("Popup loaded"),
pageshow: ({arg}) => {
if (arg !== "not-persisted") {
testFailed("Popup should not be loaded from back/forward cache.");
finishJSTest();
return;
}
debug("Popup pageshow: " + arg);
},
},
page1: {
load: () => debug("Page1 loaded"),
pageshow: ({arg}) => {
if (arg !== "not-persisted") {
testFailed("Page1 should not be loaded from back/forward cache.");
finishJSTest();
return;
}
page1ShowCount++;
if (page1ShowCount == 1) {
debug("Page1 displayed first time.");
sendMessageToPopup("navigate-to-page2");
} else if (page1ShowCount == 2) {
testPassed("Page1 displayed twice.");
finishJSTest();
}
}
},
page2: {
load: () => debug("Page2 loaded"),
pageshow: ({arg}) => {
if (arg !== "not-persisted") {
testFailed("Page2 should not be loaded from back/forward cache.");
finishJSTest();
return;
}
page2ShowCount++;
if (page2ShowCount == 1) {
debug("Page2 displayed first time.");
sendMessageToPopup("navigate-to-other");
} else if (page2ShowCount == 2) {
testPassed("Page2 displayed twice.");
sendMessageToPopup("back");
}
}
},
other: {
load: () => debug("Other page loaded"),
pageshow: ({arg}) => {
debug("Other page displayed.");
sendMessageToPopup("back");
}
},
});
</script>
</head>
<body>
<ul>
<li>Open a new window with back-iframe-popup.html. It has an iframe with page1 loaded initially.</li>
<li>Navigate iframe to page2.</li>
<li>Navigate main frame to other.</li>
<li>Go back. (back-iframe-popup.html with iframe showing page2)</li>
<li>Go back again. (back-iframe-popup.html with iframe showing page1)</li>
</ul>
<p>... and ensures the nested iframe content is correctly restored to page1.</p>
</body>
</html>