Commit 27ce92d6 authored by Hitoshi Yoshida's avatar Hitoshi Yoshida Committed by Commit Bot

WebTest: Fix back-send-referrer test

This CL refines back-send-referrer test again.
https://crrev.com/c/2501881 updated the test to work with back-forward
cache, but introduced strange states and it turned out not working
with the latest implementation of BF cache test infrastructure.

This CL cleans it up, and make it work again with BF cache.


Change-Id: I28862271f540e61830e9df948bbb0b282c55e2f5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2509641Reviewed-by: default avatarRakina Zata Amni <rakina@chromium.org>
Reviewed-by: default avatarFergal Daly <fergal@chromium.org>
Commit-Queue: Hitoshi Yoshida <peria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825258}
parent 087254c4
Referrer: http://127.0.0.1:8000/navigation/back-send-referrer.html
history.length : 3
sessionStorage.name : 3
......@@ -6,7 +6,7 @@
window.onload = function() {
setTimeout(function() {
window.name = "0";
sessionStorage.setItem("name", "0");
window.location = "resources/back-send-referrer-helper.php"
}, 0);
}
......
......@@ -6,37 +6,38 @@
<html>
Referrer: <?php echo $_SERVER['HTTP_REFERER']; ?><br>
sessionStorage.name : <span id="name"></span>
<form name=loopback action="" method=GET></form>
<script>
// This test consists of following 3 pages in its history.
// a. back-send-referrer.html
// b. back-send-referrer-helper.php
// c. back-send-referrer-helper.php?x=42
// c. back-send-referrer-helper.php?
// It expects to navigate a.->b.->c.-(back)->b. and the last navigation
// handles the referrer correctly.
window.addEventListener('pageshow', () => {
document.getElementById('length').innerText = history.length;
sessionStorage.setItem("name", parseInt(sessionStorage.getItem("name")) + 1);
document.getElementById("name").innerText = sessionStorage.getItem("name");
if (history.length == 2) {
setTimeout(function() {
const name = sessionStorage.getItem("name");
if (name == 1) {
// Showing b. for the first time.
// Navigate once more (in a timeout) to add a history entry.
setTimeout(function() { document.loopback.submit(); }, 0);
} else if (location.search) {
document.loopback.submit();
} else if (name == 2) {
// Showing c. The query means nothing.
setTimeout(function() { history.back(); }, 0);
history.back();
} else {
// Should be showing b. for the second time.
if (window.testRunner) {
if (window.testRunner)
testRunner.notifyDone();
}
}
}, 0);
});
</script>
Referrer: <?php echo $_SERVER['HTTP_REFERER']; ?><br>
history.length : <span id="length"></span>
<form name=loopback action="" method=GET>
<input type="hidden" name="x" value="42">
</form>
</html>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment