diff options
Diffstat (limited to 'testing/web-platform/tests/navigation-api/navigate-event/intercept-multiple-times-reject.html')
-rw-r--r-- | testing/web-platform/tests/navigation-api/navigate-event/intercept-multiple-times-reject.html | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/testing/web-platform/tests/navigation-api/navigate-event/intercept-multiple-times-reject.html b/testing/web-platform/tests/navigation-api/navigate-event/intercept-multiple-times-reject.html new file mode 100644 index 0000000000..0b0f1f0b8e --- /dev/null +++ b/testing/web-platform/tests/navigation-api/navigate-event/intercept-multiple-times-reject.html @@ -0,0 +1,38 @@ +<!doctype html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +promise_test(async t => { + const err = new TypeError("a message"); + let start_href = location.href; + + let onnavigateerror_called = false; + let caught_rejection = false; + navigation.onnavigatesuccess = t.step_func(assert_unreached); + navigation.onnavigateerror = t.step_func(e => { + onnavigateerror_called = true; + assert_equals(location.hash, "#1"); + assert_equals(e.constructor, ErrorEvent); + assert_equals(e.error, err); + assert_equals(e.message, "Uncaught TypeError: a message"); + assert_equals(e.filename, start_href); + assert_greater_than(e.colno, 0); + assert_greater_than(e.lineno, 0); + }); + navigation.onnavigate = t.step_func(e => { + e.intercept(); + e.intercept({ handler: async () => { + await new Promise(r => t.step_timeout(r, 1)); + return Promise.reject(err); + }}); + e.intercept({ handler: () => new Promise(resolve => t.step_timeout(resolve, 1)) }); + }); + + await navigation.navigate("#1").finished.catch(t.step_func(e => { + caught_rejection = true; + assert_equals(e, err); + })); + assert_true(onnavigateerror_called); + assert_true(caught_rejection); +}, "event.intercept() is called multiple times and one of the promises rejects"); +</script> |