Commit 4835a7de authored by arthursonzogni's avatar arthursonzogni Committed by Commit Bot

Fix tests: window.onload = setTimeout.

This is similar to a previous CL:
https://chromium-review.googlesource.com/c/chromium/src/+/1051908

All of these tests are using:
window.onload = setTimeout([...], 0);
The issue is that setTimeout is executed immediately instead of on load.

Bug: 831155
Change-Id: I913b8c04de5d583ef87c91dfc23d4ba8be8ba642
Reviewed-on: https://chromium-review.googlesource.com/1055391Reviewed-by: default avatarNate Chapin <japhet@chromium.org>
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558229}
parent ef846477
...@@ -4,7 +4,8 @@ if (window.testRunner) { ...@@ -4,7 +4,8 @@ if (window.testRunner) {
testRunner.waitUntilDone(); testRunner.waitUntilDone();
} }
window.onload = setTimeout(function() { window.onload = function() {
setTimeout(function() {
window.addEventListener('hashchange', function() { window.addEventListener('hashchange', function() {
document.body.appendChild(document.createTextNode(history.state == "FAIL" ? "FAIL" : "PASS")); document.body.appendChild(document.createTextNode(history.state == "FAIL" ? "FAIL" : "PASS"));
if (window.testRunner) if (window.testRunner)
...@@ -13,5 +14,6 @@ window.onload = setTimeout(function() { ...@@ -13,5 +14,6 @@ window.onload = setTimeout(function() {
history.replaceState("FAIL", null); history.replaceState("FAIL", null);
location.href = "#test"; location.href = "#test";
}, 0); }, 0);
}
</script> </script>
<script> <script>
window.onload = setTimeout(function() { window.onload = function() {
setTimeout(function() {
history.pushState("pushState", "", "#pushState"); history.pushState("pushState", "", "#pushState");
top.continueTest(); top.continueTest();
}, 0); }, 0);
}
</script> </script>
...@@ -10,7 +10,8 @@ const url = '/cache/resources/etag-200.php?' + ...@@ -10,7 +10,8 @@ const url = '/cache/resources/etag-200.php?' +
xhr1 = new XMLHttpRequest(); xhr1 = new XMLHttpRequest();
xhr2SendIsReturned = false; xhr2SendIsReturned = false;
xhr1.open('GET', url, false); xhr1.open('GET', url, false);
xhr1.onload = setTimeout(function() { xhr1.onload = function() {
setTimeout(function() {
xhr2 = new XMLHttpRequest(); xhr2 = new XMLHttpRequest();
xhr2.open('GET', url, true); xhr2.open('GET', url, true);
xhr2.onload = function() { xhr2.onload = function() {
...@@ -20,7 +21,8 @@ xhr1.onload = setTimeout(function() { ...@@ -20,7 +21,8 @@ xhr1.onload = setTimeout(function() {
}; };
xhr2.send(); xhr2.send();
xhr2SendIsReturned = true; xhr2SendIsReturned = true;
}, 0); }, 0);
}
xhr1.send(); xhr1.send();
</script> </script>
</body> </body>
......
CONSOLE WARNING: line 15: Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/. CONSOLE WARNING: line 16: Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
Sync XHR should not turn async due to revalidation. Sync XHR should not turn async due to revalidation.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
......
...@@ -10,7 +10,8 @@ const url = '/cache/resources/etag-200.php?' + ...@@ -10,7 +10,8 @@ const url = '/cache/resources/etag-200.php?' +
xhr1 = new XMLHttpRequest(); xhr1 = new XMLHttpRequest();
xhr2SendIsReturned = false; xhr2SendIsReturned = false;
xhr1.open('GET', url, true); xhr1.open('GET', url, true);
xhr1.onload = setTimeout(function() { xhr1.onload = function() {
setTimeout(function() {
xhr2 = new XMLHttpRequest(); xhr2 = new XMLHttpRequest();
xhr2.open('GET', url, false); xhr2.open('GET', url, false);
xhr2.onload = function() { xhr2.onload = function() {
...@@ -20,7 +21,8 @@ xhr1.onload = setTimeout(function() { ...@@ -20,7 +21,8 @@ xhr1.onload = setTimeout(function() {
}; };
xhr2.send(); xhr2.send();
xhr2SendIsReturned = true; xhr2SendIsReturned = true;
}, 0); }, 0);
}
xhr1.send(); xhr1.send();
</script> </script>
</body> </body>
......
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