mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 05:09:12 +00:00
LibWeb: Add some async/animation test utilities
This commit is contained in:
parent
b2907f62a6
commit
e298e8af5a
Notes:
sideshowbarker
2024-07-16 23:55:09 +09:00
Author: https://github.com/mattco98
Commit: e298e8af5a
Pull-request: https://github.com/SerenityOS/serenity/pull/23774
13 changed files with 65 additions and 91 deletions
|
@ -24,6 +24,18 @@ function printElement(e) {
|
|||
println(element_string);
|
||||
}
|
||||
|
||||
function animationFrame() {
|
||||
const { promise, resolve } = Promise.withResolvers();
|
||||
requestAnimationFrame(resolve);
|
||||
return promise;
|
||||
}
|
||||
|
||||
function timeout(ms) {
|
||||
const { promise, resolve } = Promise.withResolvers();
|
||||
setTimeout(resolve, ms);
|
||||
return promise;
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
__outputElement = document.createElement("pre");
|
||||
__outputElement.setAttribute("id", "out");
|
||||
|
@ -47,3 +59,12 @@ function asyncTest(f) {
|
|||
f(done);
|
||||
});
|
||||
}
|
||||
|
||||
function promiseTest(f) {
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
f().then(() => {
|
||||
__preventMultipleTestFunctions();
|
||||
internals.signalTextTestIsDone();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue