promise-rejection-events-attached-in-event.html (973B)
1 <!DOCTYPE html> 2 <meta charset="utf-8"> 3 <script src="/resources/testharness.js"></script> 4 <script src="/resources/testharnessreport.js"></script> 5 <link rel="help" href="https://html.spec.whatwg.org/#unhandled-promise-rejections"> 6 <script> 7 'use strict'; 8 setup({ 9 allow_uncaught_exception: true 10 }); 11 async_test(function(t) { 12 var e = new Error('e'); 13 var p = Promise.reject(e); 14 15 window.onunhandledrejection = function(evt) { 16 t.step(function() { 17 assert_equals(evt.promise, p); 18 assert_equals(evt.reason, e); 19 }); 20 var unreached = t.unreached_func('promise should not be fulfilled'); 21 p.then(unreached, function(reason) { 22 t.step(function() { 23 assert_equals(reason, e); 24 }); 25 t.step_timeout(function() { t.done(); }, 10); 26 }); 27 }; 28 29 window.onrejectionhandled = t.unreached_func('rejectionhandled event should not be invoked'); 30 }, 'Attaching a handler in unhandledrejection should not trigger rejectionhandled.'); 31 </script>