mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +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: https://github.com/LadybirdBrowser/ladybird/commit/c9cbaeb59d6 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>
|
||||
test(() => {
|
||||
asyncTest(done => {
|
||||
const data = "param-a=value-a¶m-b=value-b¶m-c=value-c1¶m-c=value-c2";
|
||||
const response = new Response(data, {
|
||||
headers: {
|
||||
|
@ -12,6 +12,7 @@
|
|||
println(formData.get("param-a"));
|
||||
println(formData.get("param-b"));
|
||||
println(formData.getAll("param-c"));
|
||||
done();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
asyncTest(done => {
|
||||
const video = document.createElement("video");
|
||||
video.textTracks.addEventListener("addtrack", () => {
|
||||
println(`addtrack event called`);
|
||||
done();
|
||||
});
|
||||
|
||||
const track = video.addTextTrack("subtitles", "demo label", "en-GB");
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(async () => {
|
||||
asyncTest(async done => {
|
||||
let dataTransfer = new DataTransfer();
|
||||
println(`dropEffect: ${dataTransfer.dropEffect}`);
|
||||
println(`effectAllowed: ${dataTransfer.effectAllowed}`);
|
||||
|
@ -50,5 +50,7 @@
|
|||
if (dataTransferItemList[2] !== undefined) {
|
||||
println("FAILED");
|
||||
}
|
||||
|
||||
done();
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -18,13 +18,13 @@
|
|||
}
|
||||
}
|
||||
|
||||
test(async () => {
|
||||
asyncTest(done => {
|
||||
const asyncIterable = {
|
||||
[Symbol.asyncIterator]: asyncGenerator,
|
||||
};
|
||||
|
||||
const readableStream = ReadableStream.from(asyncIterable);
|
||||
|
||||
await readStream(readableStream);
|
||||
readStream(readableStream).then(done);
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -7,9 +7,10 @@
|
|||
<body>
|
||||
<script src="include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
asyncTest(done => {
|
||||
window.onload = () => {
|
||||
println("document background: " + getComputedStyle(document.body).backgroundColor);
|
||||
done();
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
</style>
|
||||
<script src="include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
asyncTest(done => {
|
||||
let link = document.createElement("link");
|
||||
link.setAttribute("rel", "stylesheet");
|
||||
link.setAttribute("href", "body-background-color-red.css");
|
||||
|
@ -14,6 +14,7 @@
|
|||
|
||||
window.onload = function () {
|
||||
println("document background: " + getComputedStyle(document.body).backgroundColor);
|
||||
done();
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -6,9 +6,10 @@
|
|||
<body>
|
||||
<script src="include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
asyncTest(done => {
|
||||
window.onload = function () {
|
||||
println("document background: " + getComputedStyle(document.body).backgroundColor);
|
||||
done();
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -6,9 +6,10 @@
|
|||
<body>
|
||||
<script src="include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
asyncTest(done => {
|
||||
window.onload = function () {
|
||||
println("document background: " + getComputedStyle(document.body).backgroundColor);
|
||||
done();
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
<script src="include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
asyncTest(done => {
|
||||
globalThis.done = done;
|
||||
|
||||
let link = document.createElement("link");
|
||||
link.setAttribute("rel", "preload");
|
||||
link.setAttribute("href", "valid.css");
|
||||
link.setAttribute("as", "style");
|
||||
link.setAttribute("onload", "println('link element onload')");
|
||||
link.setAttribute("onload", "println('link element onload'); done();");
|
||||
document.head.appendChild(link);
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue