mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-01 07:52:50 +00:00
LibWeb: Add a feature to LibWeb tests to fail on unhandled exceptions
Previously, if there was an unhandled exception in an async test, it might fail to call done() and timeout. Now we have a default "error" handler to catch unhandled exceptions and fail the test. A few tests want to actually test the behavior of window.onerror, so they need an escape hatch.
This commit is contained in:
parent
1fa948f114
commit
8edaec79de
Notes:
github-actions[bot]
2024-10-05 07:19:21 +00:00
Author: https://github.com/ADKaster
Commit: 8edaec79de
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1632
4 changed files with 20 additions and 0 deletions
|
@ -52,6 +52,20 @@ function timeout(ms) {
|
|||
return promise;
|
||||
}
|
||||
|
||||
const __testErrorHandlerController = new AbortController();
|
||||
window.addEventListener(
|
||||
"error",
|
||||
event => {
|
||||
println(`Uncaught Error In Test: ${event.message}`);
|
||||
__finishTest();
|
||||
},
|
||||
{ signal: __testErrorHandlerController.signal }
|
||||
);
|
||||
|
||||
function removeTestErrorHandler() {
|
||||
__testErrorHandlerController.abort();
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
__outputElement = document.createElement("pre");
|
||||
__outputElement.setAttribute("id", "out");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue