mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
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:
parent
96082d6ae1
commit
c9cbaeb59d
Notes:
github-actions[bot]
2024-10-03 11:08:36 +00:00
Author: https://github.com/trflynn89
Commit: c9cbaeb59d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1603
Reviewed-by: https://github.com/awesomekling ✅
Reviewed-by: https://github.com/circl-lastname
Reviewed-by: https://github.com/kalenikaliaksandr ✅
10 changed files with 32 additions and 12 deletions
|
@ -1,6 +1,6 @@
|
||||||
<script src="../include.js"></script>
|
<script src="../include.js"></script>
|
||||||
<script>
|
<script>
|
||||||
test(() => {
|
asyncTest(done => {
|
||||||
const data = "param-a=value-a¶m-b=value-b¶m-c=value-c1¶m-c=value-c2";
|
const data = "param-a=value-a¶m-b=value-b¶m-c=value-c1¶m-c=value-c2";
|
||||||
const response = new Response(data, {
|
const response = new Response(data, {
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -12,6 +12,7 @@
|
||||||
println(formData.get("param-a"));
|
println(formData.get("param-a"));
|
||||||
println(formData.get("param-b"));
|
println(formData.get("param-b"));
|
||||||
println(formData.getAll("param-c"));
|
println(formData.getAll("param-c"));
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<script src="../include.js"></script>
|
<script src="../include.js"></script>
|
||||||
<script>
|
<script>
|
||||||
test(() => {
|
asyncTest(done => {
|
||||||
const video = document.createElement("video");
|
const video = document.createElement("video");
|
||||||
video.textTracks.addEventListener("addtrack", () => {
|
video.textTracks.addEventListener("addtrack", () => {
|
||||||
println(`addtrack event called`);
|
println(`addtrack event called`);
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
const track = video.addTextTrack("subtitles", "demo label", "en-GB");
|
const track = video.addTextTrack("subtitles", "demo label", "en-GB");
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script src="../include.js"></script>
|
<script src="../include.js"></script>
|
||||||
<script>
|
<script>
|
||||||
test(async () => {
|
asyncTest(async done => {
|
||||||
let dataTransfer = new DataTransfer();
|
let dataTransfer = new DataTransfer();
|
||||||
println(`dropEffect: ${dataTransfer.dropEffect}`);
|
println(`dropEffect: ${dataTransfer.dropEffect}`);
|
||||||
println(`effectAllowed: ${dataTransfer.effectAllowed}`);
|
println(`effectAllowed: ${dataTransfer.effectAllowed}`);
|
||||||
|
@ -50,5 +50,7 @@
|
||||||
if (dataTransferItemList[2] !== undefined) {
|
if (dataTransferItemList[2] !== undefined) {
|
||||||
println("FAILED");
|
println("FAILED");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -18,13 +18,13 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
test(async () => {
|
asyncTest(done => {
|
||||||
const asyncIterable = {
|
const asyncIterable = {
|
||||||
[Symbol.asyncIterator]: asyncGenerator,
|
[Symbol.asyncIterator]: asyncGenerator,
|
||||||
};
|
};
|
||||||
|
|
||||||
const readableStream = ReadableStream.from(asyncIterable);
|
const readableStream = ReadableStream.from(asyncIterable);
|
||||||
|
|
||||||
await readStream(readableStream);
|
readStream(readableStream).then(done);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -7,9 +7,10 @@
|
||||||
<body>
|
<body>
|
||||||
<script src="include.js"></script>
|
<script src="include.js"></script>
|
||||||
<script>
|
<script>
|
||||||
test(() => {
|
asyncTest(done => {
|
||||||
window.onload = () => {
|
window.onload = () => {
|
||||||
println("document background: " + getComputedStyle(document.body).backgroundColor);
|
println("document background: " + getComputedStyle(document.body).backgroundColor);
|
||||||
|
done();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
</style>
|
</style>
|
||||||
<script src="include.js"></script>
|
<script src="include.js"></script>
|
||||||
<script>
|
<script>
|
||||||
test(() => {
|
asyncTest(done => {
|
||||||
let link = document.createElement("link");
|
let link = document.createElement("link");
|
||||||
link.setAttribute("rel", "stylesheet");
|
link.setAttribute("rel", "stylesheet");
|
||||||
link.setAttribute("href", "body-background-color-red.css");
|
link.setAttribute("href", "body-background-color-red.css");
|
||||||
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
window.onload = function () {
|
window.onload = function () {
|
||||||
println("document background: " + getComputedStyle(document.body).backgroundColor);
|
println("document background: " + getComputedStyle(document.body).backgroundColor);
|
||||||
|
done();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -6,9 +6,10 @@
|
||||||
<body>
|
<body>
|
||||||
<script src="include.js"></script>
|
<script src="include.js"></script>
|
||||||
<script>
|
<script>
|
||||||
test(() => {
|
asyncTest(done => {
|
||||||
window.onload = function () {
|
window.onload = function () {
|
||||||
println("document background: " + getComputedStyle(document.body).backgroundColor);
|
println("document background: " + getComputedStyle(document.body).backgroundColor);
|
||||||
|
done();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -6,9 +6,10 @@
|
||||||
<body>
|
<body>
|
||||||
<script src="include.js"></script>
|
<script src="include.js"></script>
|
||||||
<script>
|
<script>
|
||||||
test(() => {
|
asyncTest(done => {
|
||||||
window.onload = function () {
|
window.onload = function () {
|
||||||
println("document background: " + getComputedStyle(document.body).backgroundColor);
|
println("document background: " + getComputedStyle(document.body).backgroundColor);
|
||||||
|
done();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
<script src="include.js"></script>
|
<script src="include.js"></script>
|
||||||
<script>
|
<script>
|
||||||
test(() => {
|
asyncTest(done => {
|
||||||
|
globalThis.done = done;
|
||||||
|
|
||||||
let link = document.createElement("link");
|
let link = document.createElement("link");
|
||||||
link.setAttribute("rel", "preload");
|
link.setAttribute("rel", "preload");
|
||||||
link.setAttribute("href", "valid.css");
|
link.setAttribute("href", "valid.css");
|
||||||
link.setAttribute("as", "style");
|
link.setAttribute("as", "style");
|
||||||
link.setAttribute("onload", "println('link element onload')");
|
link.setAttribute("onload", "println('link element onload'); done();");
|
||||||
document.head.appendChild(link);
|
document.head.appendChild(link);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,12 +1,18 @@
|
||||||
<script src="include.js"></script>
|
<script src="include.js"></script>
|
||||||
<script>
|
<script>
|
||||||
test(() => {
|
asyncTest(done => {
|
||||||
|
let eventCount = 0;
|
||||||
|
|
||||||
let goodLink = document.createElement("link");
|
let goodLink = document.createElement("link");
|
||||||
goodLink.setAttribute("rel", "preload");
|
goodLink.setAttribute("rel", "preload");
|
||||||
goodLink.setAttribute("href", "valid.css");
|
goodLink.setAttribute("href", "valid.css");
|
||||||
goodLink.setAttribute("as", "style");
|
goodLink.setAttribute("as", "style");
|
||||||
goodLink.addEventListener("load", function () {
|
goodLink.addEventListener("load", function () {
|
||||||
println("Got load event");
|
println("Got load event");
|
||||||
|
|
||||||
|
if (++eventCount == 2) {
|
||||||
|
done();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
document.head.appendChild(goodLink);
|
document.head.appendChild(goodLink);
|
||||||
|
|
||||||
|
@ -16,6 +22,10 @@
|
||||||
badLink.setAttribute("as", "style");
|
badLink.setAttribute("as", "style");
|
||||||
badLink.addEventListener("error", function () {
|
badLink.addEventListener("error", function () {
|
||||||
println("Got error event");
|
println("Got error event");
|
||||||
|
|
||||||
|
if (++eventCount == 2) {
|
||||||
|
done();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
document.head.appendChild(badLink);
|
document.head.appendChild(badLink);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue