mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
This changes `link-element-rel-preload-load-event.html`, so the test no longer depends on the relative ordering of load and error events. This is required for the upcoming change that makes fetching unbuffered by default, as the test would otherwise become flaky.
42 lines
1.2 KiB
HTML
42 lines
1.2 KiB
HTML
<!DOCTYPE html>
|
|
<script src="include.js"></script>
|
|
<script>
|
|
asyncTest(done => {
|
|
const logs = [];
|
|
const printLogs = () => {
|
|
logs.sort();
|
|
for (const log of logs) {
|
|
println(log);
|
|
}
|
|
};
|
|
|
|
let goodLink = document.createElement("link");
|
|
goodLink.setAttribute("rel", "preload");
|
|
goodLink.setAttribute("href", "valid.css");
|
|
goodLink.setAttribute("as", "style");
|
|
goodLink.addEventListener("load", function () {
|
|
logs.push("Got load event");
|
|
|
|
if (logs.length == 2) {
|
|
printLogs();
|
|
done();
|
|
}
|
|
});
|
|
document.head.appendChild(goodLink);
|
|
|
|
let badLink = document.createElement("link");
|
|
badLink.setAttribute("rel", "preload");
|
|
badLink.setAttribute("href", "this-file-does-not-exist-and-so-is-invalid.css");
|
|
badLink.setAttribute("as", "style");
|
|
badLink.addEventListener("error", function () {
|
|
logs.push("Got error event");
|
|
|
|
if (logs.length == 2) {
|
|
printLogs();
|
|
done();
|
|
}
|
|
});
|
|
document.head.appendChild(badLink);
|
|
});
|
|
</script>
|