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,14 +4,16 @@ if (window.testRunner) {
testRunner.waitUntilDone();
}
window.onload = setTimeout(function() {
window.addEventListener('hashchange', function() {
document.body.appendChild(document.createTextNode(history.state == "FAIL" ? "FAIL" : "PASS"));
if (window.testRunner)
testRunner.notifyDone();
});
window.onload = function() {
setTimeout(function() {
window.addEventListener('hashchange', function() {
document.body.appendChild(document.createTextNode(history.state == "FAIL" ? "FAIL" : "PASS"));
if (window.testRunner)
testRunner.notifyDone();
});
history.replaceState("FAIL", null);
location.href = "#test";
}, 0);
history.replaceState("FAIL", null);
location.href = "#test";
}, 0);
}
</script>
<script>
window.onload = setTimeout(function() {
history.pushState("pushState", "", "#pushState");
top.continueTest();
}, 0);
window.onload = function() {
setTimeout(function() {
history.pushState("pushState", "", "#pushState");
top.continueTest();
}, 0);
}
</script>
......@@ -10,17 +10,19 @@ const url = '/cache/resources/etag-200.php?' +
xhr1 = new XMLHttpRequest();
xhr2SendIsReturned = false;
xhr1.open('GET', url, false);
xhr1.onload = setTimeout(function() {
xhr2 = new XMLHttpRequest();
xhr2.open('GET', url, true);
xhr2.onload = function() {
shouldBeTrue("xhr2SendIsReturned");
shouldNotBe("xhr1.responseText", "xhr2.responseText");
finishJSTest();
};
xhr2.send();
xhr2SendIsReturned = true;
}, 0);
xhr1.onload = function() {
setTimeout(function() {
xhr2 = new XMLHttpRequest();
xhr2.open('GET', url, true);
xhr2.onload = function() {
shouldBeTrue("xhr2SendIsReturned");
shouldNotBe("xhr1.responseText", "xhr2.responseText");
finishJSTest();
};
xhr2.send();
xhr2SendIsReturned = true;
}, 0);
}
xhr1.send();
</script>
</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.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
......
......@@ -10,17 +10,19 @@ const url = '/cache/resources/etag-200.php?' +
xhr1 = new XMLHttpRequest();
xhr2SendIsReturned = false;
xhr1.open('GET', url, true);
xhr1.onload = setTimeout(function() {
xhr2 = new XMLHttpRequest();
xhr2.open('GET', url, false);
xhr2.onload = function() {
shouldBeFalse("xhr2SendIsReturned");
shouldNotBe("xhr1.responseText", "xhr2.responseText");
finishJSTest();
};
xhr2.send();
xhr2SendIsReturned = true;
}, 0);
xhr1.onload = function() {
setTimeout(function() {
xhr2 = new XMLHttpRequest();
xhr2.open('GET', url, false);
xhr2.onload = function() {
shouldBeFalse("xhr2SendIsReturned");
shouldNotBe("xhr1.responseText", "xhr2.responseText");
finishJSTest();
};
xhr2.send();
xhr2SendIsReturned = true;
}, 0);
}
xhr1.send();
</script>
</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