diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-setup.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-setup.js')
-rw-r--r-- | testing/web-platform/tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-setup.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-setup.js b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-setup.js new file mode 100644 index 0000000000..d2e28935c4 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/scripting-1/the-script-element/microtasks/resources/evaluation-order-setup.js @@ -0,0 +1,30 @@ +globalThis.setup({allow_uncaught_exception: true}); + +// Must be called after previous tests are completed. +globalThis.setupTest = (description, expectedLog) => { + globalThis.log = []; + globalThis.onerror = message => { + globalThis.log.push("global-error"); + return true; + }; + globalThis.onunhandledrejection = + () => globalThis.log.push('unhandled-promise-rejection'); + + globalThis.unreachable = () => globalThis.log.push("unreachable"); + + globalThis.test_load = async_test(description); + globalThis.testDone = globalThis.test_load.step_func_done(() => { + assert_array_equals(globalThis.log, expectedLog); + }); + + if (!('Window' in globalThis && globalThis instanceof Window)) { + // In workers, there are no <script> load event, so scheduling `testDone()` + // here, assuming the target script is loaded and evaluated soon. + globalThis.test_load.step_timeout(() => globalThis.testDone(), 1000); + + // In workers, call `done()` here because the auto-generated `done()` calls + // by `any.js` etc. are at the end of main script and thus are not + // evaluated when the target script throws an exception. + done(); + } +}; |