ladybird/Tests/LibWeb/Text/input/link-element-rel-preload-load-event.html
Timothy Flynn c9cbaeb59d LibWeb: Convert some sync tests to be async
The events tested here are decidedly async. We also can't really write
sync tests of the form "test(async () => {})". Nothing will await the
async callback.
2024-10-03 07:07:28 -04:00

32 lines
1,009 B
HTML

<script src="include.js"></script>
<script>
asyncTest(done => {
let eventCount = 0;
let goodLink = document.createElement("link");
goodLink.setAttribute("rel", "preload");
goodLink.setAttribute("href", "valid.css");
goodLink.setAttribute("as", "style");
goodLink.addEventListener("load", function () {
println("Got load event");
if (++eventCount == 2) {
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 () {
println("Got error event");
if (++eventCount == 2) {
done();
}
});
document.head.appendChild(badLink);
});
</script>