Commit 36f5bb5e authored by Arthur Sonzogni's avatar Arthur Sonzogni Committed by Commit Bot

Update LayoutTest /history/redirect-js-* (11 tests)

The current behavior of chrome is the following one:
---
When a javascript navigation is triggered, if it happens:
   * before the load event, replace the current history entry.
   * after the load event, append a new history entry.
---

The first case is sometimes called "javascript-redirect".

The current set of tests uses two kind of tests. One with a timeout of 2
seconds. This one is expected to happens after the load event. Another
one with a timeout of 0 seconds. We don't really know this one is
expected to happens. This is flaky. It usually happens after the load
event, but it is non deterministic.

This CLs removes:
  * /http/tests/history/redirect-js-*-0-seconds}.html
  * /http/tests/history/redirect-js-*-2-seconds}.html

And completes:
  * /http/tests/history/redirect-js-*-before-load}.html
  * /http/tests/history/redirect-js-*-after-load}.html

It modifies the tests so that they really depend on the load event, not
on timing, which is not reliable.

Bug: 862591, 831155
Change-Id: I3d568019c8616e6b52b9db554ad95ed312bd82d9
Reviewed-on: https://chromium-review.googlesource.com/1185094
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Reviewed-by: default avatarNate Chapin <japhet@chromium.org>
Cr-Commit-Position: refs/heads/master@{#587965}
parent 3b06b81f
This page is the target of a redirect.
FAIL: History item count should be 1 but instead is 2.
PASS: History item count should be 2 and is.
============== Back Forward List ==============
http://127.0.0.1:8000/history/redirect-js-document-location-2-seconds.html
curr-> http://127.0.0.1:8000/history/resources/redirect-target.html#1
http://127.0.0.1:8000/history/redirect-js-document-location-after-load.html
curr-> http://127.0.0.1:8000/history/resources/redirect-target.html#2
===============================================
<html>
<head>
<title>JavaScript Redirect</title>
<script>
if (window.testRunner) {
testRunner.clearBackForwardList();
testRunner.waitUntilDone();
}
window.onload = function() {
setTimeout(function () {
document.location = "resources/redirect-target.html#2";
}, 0);
}
</script>
</head>
<body>
This page modifies document.location after the load event.
It must create a new history entry.
</body>
</html>
This page is the target of a redirect.
FAIL: History item count should be 1 but instead is 2.
============== Back Forward List ==============
http://127.0.0.1:8000/history/redirect-js-form-submit-0-seconds.html
curr-> http://127.0.0.1:8000/history/resources/redirect-target.html?#1
===============================================
This page is the target of a redirect.
FAIL: History item count should be 1 but instead is 2.
============== Back Forward List ==============
http://127.0.0.1:8000/history/redirect-js-form-submit-2-seconds.html
curr-> http://127.0.0.1:8000/history/resources/redirect-target.html?#1
===============================================
This page is the target of a redirect.
FAIL: History item count should be 1 but instead is 2.
PASS: History item count should be 2 and is.
============== Back Forward List ==============
http://127.0.0.1:8000/history/redirect-js-location-2-seconds.html
curr-> http://127.0.0.1:8000/history/resources/redirect-target.html#1
http://127.0.0.1:8000/history/redirect-js-form-submit-after-load.html
curr-> http://127.0.0.1:8000/history/resources/redirect-target.html?#2
===============================================
<html>
<head>
<title>JavaScript Redirect</title>
<script>
if (window.testRunner) {
testRunner.clearBackForwardList();
testRunner.waitUntilDone();
}
</script>
</head>
<body>
<p>This page submits a form after the load event.
It must create a new history entry. </p>
<form id="form" action="resources/redirect-target.html#2"></form>
<script>
window.onload = function() {
setTimeout(function () {
document.getElementById("form").submit();
}, 0);
}
</script>
</body>
</html>
This page is the target of a redirect.
PASS: History item count should be 1 and is.
PASS: History item count should be 2 and is.
============== Back Forward List ==============
curr-> http://127.0.0.1:8000/history/resources/redirect-target.html#1
http://127.0.0.1:8000/history/redirect-js-location-after-load.html
curr-> http://127.0.0.1:8000/history/resources/redirect-target.html#2
===============================================
......@@ -7,14 +7,16 @@ if (window.testRunner) {
testRunner.clearBackForwardList();
testRunner.waitUntilDone();
}
window.onload = function() {
setTimeout(function () {
location = "resources/redirect-target.html#2";
}, 0);
}
</script>
</head>
<body>
<p>This page is a JavaScript redirect on a 0 second delay.</p>
<form id="form" action="resources/redirect-target.html#1"></form>
<script>
setTimeout(function () { document.getElementById("form").submit(); }, 0);
</script>
This page modifies location after the load event.
It must create a new history entry.
</body>
</html>
<html>
<head>
<title>JavaScript Redirect</title>
<script>
if (window.testRunner) {
testRunner.clearBackForwardList();
testRunner.waitUntilDone();
}
setTimeout(function () { location.assign("resources/redirect-target.html#1"); }, 0);
</script>
</head>
<body>This page is a JavaScript redirect on a 0 second delay.</body>
</html>
This page is the target of a redirect.
FAIL: History item count should be 1 but instead is 2.
============== Back Forward List ==============
http://127.0.0.1:8000/history/redirect-js-location-assign-2-seconds.html
curr-> http://127.0.0.1:8000/history/resources/redirect-target.html#1
===============================================
<html>
<head>
<title>JavaScript Redirect</title>
<script>
if (window.testRunner) {
testRunner.clearBackForwardList();
testRunner.waitUntilDone();
}
setTimeout(function () { location.assign("resources/redirect-target.html#1"); }, 2000);
</script>
</head>
<body>This page is a JavaScript redirect on a 2 second delay.</body>
</html>
This page is the target of a redirect.
FAIL: History item count should be 1 but instead is 2.
PASS: History item count should be 2 and is.
============== Back Forward List ==============
http://127.0.0.1:8000/history/redirect-js-location-assign-0-seconds.html
curr-> http://127.0.0.1:8000/history/resources/redirect-target.html#1
http://127.0.0.1:8000/history/redirect-js-location-assign-after-load.html
curr-> http://127.0.0.1:8000/history/resources/redirect-target.html#2
===============================================
......@@ -7,14 +7,17 @@ if (window.testRunner) {
testRunner.clearBackForwardList();
testRunner.waitUntilDone();
}
window.onload = function() {
setTimeout(function () {
location.assign("resources/redirect-target.html#2");
}, 0);
}
</script>
</head>
<body>
<p>This page is a JavaScript redirect on a 2 second delay.</p>
<form id="form" action="resources/redirect-target.html#1"></form>
<script>
setTimeout(function () { document.getElementById("form").submit(); }, 2000);
</script>
This page uses location.assign after the load event.
It must create a new history entry.
</body>
</html>
<html>
<head>
<title>JavaScript Redirect</title>
<script>
if (window.testRunner) {
testRunner.clearBackForwardList();
testRunner.waitUntilDone();
}
setTimeout(function () { location.href = "resources/redirect-target.html#1"; }, 2000);
</script>
</head>
<body>This page is a JavaScript redirect on a 2 second delay.</body>
</html>
This page is the target of a redirect.
FAIL: History item count should be 1 but instead is 2.
PASS: History item count should be 2 and is.
============== Back Forward List ==============
http://127.0.0.1:8000/history/redirect-js-location-href-2-seconds.html
curr-> http://127.0.0.1:8000/history/resources/redirect-target.html#1
http://127.0.0.1:8000/history/redirect-js-location-href-after-load.html
curr-> http://127.0.0.1:8000/history/resources/redirect-target.html#2
===============================================
......@@ -7,9 +7,17 @@ if (window.testRunner) {
testRunner.clearBackForwardList();
testRunner.waitUntilDone();
}
setTimeout(function () { document.location = "resources/redirect-target.html#1"; }, 2000);
window.onload = function() {
setTimeout(function () {
location.href = "resources/redirect-target.html#2";
}, 0);
}
</script>
</head>
<body>This page is a JavaScript redirect on a 2 second delay.</body>
<body>
This page modifies location.href after the load event. It must create a new
history entry.
</body>
</html>
<html>
<head>
<title>JavaScript Redirect</title>
<script>
if (window.testRunner) {
testRunner.clearBackForwardList();
testRunner.waitUntilDone();
}
setTimeout(function () { location.replace("resources/redirect-target.html#1"); }, 0);
</script>
</head>
<body>This page is a JavaScript redirect on a 0 second delay.</body>
</html>
<html>
<head>
<title>JavaScript Redirect</title>
<script>
if (window.testRunner) {
testRunner.clearBackForwardList();
testRunner.waitUntilDone();
}
setTimeout(function () { location.replace("resources/redirect-target.html#1"); }, 2000);
</script>
</head>
<body>This page is a JavaScript redirect on a 2 second delay.</body>
</html>
......@@ -7,9 +7,16 @@ if (window.testRunner) {
testRunner.clearBackForwardList();
testRunner.waitUntilDone();
}
setTimeout(function () { location = "resources/redirect-target.html#1"; }, 2000);
window.onload = function() {
setTimeout(function () {
location.replace("resources/redirect-target.html#1");
}, 0);
}
</script>
</head>
<body>This page is a JavaScript redirect on a 2 second delay.</body>
<body>
This page uses location.replace after the load event.
It should not create a new history entry.
</body>
</html>
This tests starting a new resource load after the load event has finished, then reloading while that load is still in progress. Due to a regression in https://chromium.googlesource.com/chromium/src/+/8b913deb7165a50daa13e6b64300e550cf62a47e, we would overwrite the load type such that the reload will still be executed correctly, but the history entry will be created as though it was a standard load.
============== Back Forward List ==============
curr-> http://127.0.0.1:8000/history/reload-during-load-after-load-event.html
===============================================
<html>
<body onload="setTimeout(test, 0);">
This tests starting a new resource load after the load event has finished, then reloading while that load is still in progress.
Due to a regression in https://chromium.googlesource.com/chromium/src/+/8b913deb7165a50daa13e6b64300e550cf62a47e, we would overwrite the load type such that
the reload will still be executed correctly, but the history entry will be created as though it was a standard load.
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
function test() {
if (window.localStorage.getItem("finish-during-reload") == null) {
window.localStorage.setItem("finish-during-reload", "reload")
var img = document.createElement("img");
img.src = "resources/slow-image.php";
document.body.appendChild(img);
if (window.internals)
internals.forceReload(false);
} else {
window.localStorage.clear();
if (window.testRunner) {
testRunner.dumpBackForwardList();
testRunner.notifyDone();
}
}
}
</script>
</body>
</html>
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