Tests/LibWeb: Finish async test when an error is caught

This catches errors that occur within async tests so that we fail faster
rather than timing out due to `done()` not being called.

We use `Promise.resolve()` because `f` isn't guaranteed to be an async
function.
This commit is contained in:
rmg-x 2025-01-15 19:12:56 -06:00 committed by Andrew Kaster
parent 9f7bdaf3b4
commit 0de910784e

View File

@ -86,7 +86,10 @@ function asyncTest(f) {
__finishTest();
};
document.addEventListener("DOMContentLoaded", () => {
f(done);
Promise.resolve(f(done)).catch(error => {
println(`Caught error while running async test: ${error}`);
done();
});
});
}