mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-05 22:52:22 +02:00
These tests set up a delayed echo endpoint using a synchronous XHR to http://127.0.0.1:PORT/echo, but the page itself is served from http://localhost:PORT. This cross-origin request triggers a CORS preflight, which intermittently fails with a NetworkError. There's already a FIXME in place to get rid of the spin_until() that caused this to happen. Use a relative URL instead, since the page is already served from the echo server. Fixes #8564
41 lines
1.3 KiB
HTML
41 lines
1.3 KiB
HTML
<!DOCTYPE html>
|
|
<script src="include.js"></script>
|
|
<script>
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.open("POST", "/echo", false);
|
|
xhr.setRequestHeader("Content-Type", "application/json");
|
|
xhr.send(JSON.stringify({
|
|
method: "GET",
|
|
path: "/delayed-green.png",
|
|
status: 200,
|
|
headers: {"Content-Type": "image/png", "Cache-Control": "no-store"},
|
|
body: "iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAAD0lEQVR4nGNgaGAAIQgFAA4OAgFhGn2EAAAAAElFTkSuQmCC",
|
|
body_encoding: "base64",
|
|
delay_ms: 500
|
|
}));
|
|
</script>
|
|
<style>
|
|
#target {
|
|
width: 100px;
|
|
height: 100px;
|
|
background-color: red;
|
|
background-image: url("/delayed-green.png");
|
|
background-size: cover;
|
|
}
|
|
</style>
|
|
<div id="target"></div>
|
|
<script>
|
|
asyncTest((done) => {
|
|
window.addEventListener("load", () => {
|
|
let loadTime = performance.now();
|
|
println(`Load event delayed by at least 400ms: ${loadTime >= 400}`);
|
|
|
|
let entries = performance.getEntriesByType("resource");
|
|
let imageEntry = entries.find(e => e.name.includes("delayed-green"));
|
|
println(`Image resource entry exists: ${imageEntry !== undefined}`);
|
|
println(`Image loaded before load event: ${imageEntry !== undefined && imageEntry.responseEnd <= loadTime}`);
|
|
done();
|
|
});
|
|
});
|
|
</script>
|