diff options
Diffstat (limited to 'testing/web-platform/tests/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/promise-rejection-events-onerror.html')
-rw-r--r-- | testing/web-platform/tests/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/promise-rejection-events-onerror.html | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/promise-rejection-events-onerror.html b/testing/web-platform/tests/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/promise-rejection-events-onerror.html new file mode 100644 index 0000000000..b6c02d27c9 --- /dev/null +++ b/testing/web-platform/tests/html/webappapis/scripting/processing-model-2/unhandled-promise-rejections/promise-rejection-events-onerror.html @@ -0,0 +1,47 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<link rel="help" href="https://html.spec.whatwg.org/#runtime-script-errors"> +<link rel="help" href="https://html.spec.whatwg.org/#unhandled-promise-rejections"> +<script> +'use strict'; +setup({ + allow_uncaught_exception: true +}); +async_test(function(t) { + var e = new Error('e'); + var e2 = new Error('e2'); + + window.onerror = function (msg, url, line, col, error) { + t.step(function() { + assert_true(msg.includes('e2')); + assert_equals(error, e2); + }); + t.done(); + }; + + window.onrejectionhandled = function() { + // This should cause onerror + throw e2; + }; + + var p = Promise.reject(e); + queueTask(function() { + queueTask(t.step_func(function() { + // This will cause onrejectionhandled + p.catch(function() {}); + })); + }); +}, 'Throwing inside an unhandledrejection handler invokes the error handler.'); + +// This function queues a task in "DOM manipulation task source" +function queueTask(f) { + var d = document.createElement("details"); + d.ontoggle = function() { + f(); + }; + + d.setAttribute("open", ""); +} +</script> |