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.
This commit is contained in:
Timothy Flynn 2024-10-02 12:58:07 -04:00 committed by Tim Flynn
commit c9cbaeb59d
Notes: github-actions[bot] 2024-10-03 11:08:36 +00:00
10 changed files with 32 additions and 12 deletions

View file

@ -1,12 +1,18 @@
<script src="include.js"></script>
<script>
test(() => {
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);
@ -16,6 +22,10 @@
badLink.setAttribute("as", "style");
badLink.addEventListener("error", function () {
println("Got error event");
if (++eventCount == 2) {
done();
}
});
document.head.appendChild(badLink);
});