Truly independent web browser
Tests/LibWeb: Report a promise test’s rejection rather than hang
sideshowbarker79e1428e0615
diff --git a/Tests/LibWeb/Text/expected/promise-test-reports-a-rejection.txt b/Tests/LibWeb/Text/expected/promise-test-reports-a-rejection.txtnew file mode 100644index 00000000000..80b18a9c717--- /dev/null+++ b/Tests/LibWeb/Text/expected/promise-test-reports-a-rejection.txt@@ -0,0 +1,2 @@+Before the rejection+Caught error while running promise test: Error: rejected on purposediff --git a/Tests/LibWeb/Text/input/include.js b/Tests/LibWeb/Text/input/include.jsindex f78b456cbf4..f35e40cea61 100644--- a/Tests/LibWeb/Text/input/include.js+++ b/Tests/LibWeb/Text/input/include.js@@ -240,17 +240,21 @@ function asyncTest(f) {};document.addEventListener("DOMContentLoaded", () => {Promise.resolve(f(done)).catch(error => {- println(`Caught error while running async test: ${error}`);+ println(`Caught error while running async test: ${String(error)}`);done();});});}function promiseTest(f) {+ const done = () => {+ __preventMultipleTestFunctions();+ __finishTest();+ };document.addEventListener("DOMContentLoaded", () => {- f().then(() => {- __preventMultipleTestFunctions();- __finishTest();+ f().then(done, error => {+ println(`Caught error while running promise test: ${String(error)}`);+ done();});});}diff --git a/Tests/LibWeb/Text/input/promise-test-reports-a-rejection.html b/Tests/LibWeb/Text/input/promise-test-reports-a-rejection.htmlnew file mode 100644index 00000000000..e147c3e6382--- /dev/null+++ b/Tests/LibWeb/Text/input/promise-test-reports-a-rejection.html@@ -0,0 +1,8 @@+<!DOCTYPE html>+<script src="include.js"></script>+<script>+ promiseTest(async () => {+ println("Before the rejection");+ throw new Error("rejected on purpose");+ });+</script>