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 Referrer: http://127.0.0.1:8000/navigation/back-send-referrer.html
history.length : 3 sessionStorage.name : 3
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
window.onload = function() { window.onload = function() {
setTimeout(function() { setTimeout(function() {
window.name = "0"; sessionStorage.setItem("name", "0");
window.location = "resources/back-send-referrer-helper.php" window.location = "resources/back-send-referrer-helper.php"
}, 0); }, 0);
} }
......
...@@ -6,37 +6,38 @@ ...@@ -6,37 +6,38 @@
<html> <html>
Referrer: <?php echo $_SERVER['HTTP_REFERER']; ?><br>
sessionStorage.name : <span id="name"></span>
<form name=loopback action="" method=GET></form>
<script> <script>
// This test consists of following 3 pages in its history. // This test consists of following 3 pages in its history.
// a. back-send-referrer.html // a. back-send-referrer.html
// b. back-send-referrer-helper.php // 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 // It expects to navigate a.->b.->c.-(back)->b. and the last navigation
// handles the referrer correctly. // handles the referrer correctly.
window.addEventListener('pageshow', () => { 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() {
// Showing b. for the first time. const name = sessionStorage.getItem("name");
// Navigate once more (in a timeout) to add a history entry. if (name == 1) {
setTimeout(function() { document.loopback.submit(); }, 0); // Showing b. for the first time.
} else if (location.search) { // Navigate once more (in a timeout) to add a history entry.
// Showing c. The query means nothing. document.loopback.submit();
setTimeout(function() { history.back(); }, 0); } else if (name == 2) {
} else { // Showing c. The query means nothing.
// Should be showing b. for the second time. history.back();
if (window.testRunner) { } else {
testRunner.notifyDone(); // Should be showing b. for the second time.
if (window.testRunner)
testRunner.notifyDone();
} }
} }, 0);
}); });
</script> </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> </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