OLD | NEW |
(Empty) | |
| 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/#the-promiserejectionevent-i
nterface"> |
| 6 <script> |
| 7 'use strict'; |
| 8 |
| 9 test(function() { |
| 10 var p = new Promise(function(resolve, reject) {}); |
| 11 |
| 12 // No custom options are passed (besides required promise). |
| 13 assert_equals(new PromiseRejectionEvent('eventType', { promise: p }).bubbles,
false); |
| 14 assert_equals(new PromiseRejectionEvent('eventType', { promise: p }).cancelabl
e, false); |
| 15 assert_equals(new PromiseRejectionEvent('eventType', { promise: p }).promise,
p); |
| 16 assert_equals(new PromiseRejectionEvent('eventType', { promise: p }).reason, u
ndefined); |
| 17 |
| 18 // No promise is passed. |
| 19 assert_throws(new TypeError(), |
| 20 function() { |
| 21 new PromiseRejectionEvent('eventType', { bubbles: false }); |
| 22 }, |
| 23 'Cannot construct PromiseRejectionEventInit without promise'); |
| 24 |
| 25 // bubbles is passed. |
| 26 assert_equals(new PromiseRejectionEvent('eventType', { bubbles: false, promise
: p }).bubbles, false); |
| 27 assert_equals(new PromiseRejectionEvent('eventType', { bubbles: true, promise:
p }).bubbles, true); |
| 28 |
| 29 // cancelable is passed. |
| 30 assert_equals(new PromiseRejectionEvent('eventType', { cancelable: false, prom
ise: p }).cancelable, false); |
| 31 assert_equals(new PromiseRejectionEvent('eventType', { cancelable: true, promi
se: p }).cancelable, true); |
| 32 |
| 33 // reason is passed. |
| 34 var r = new Error(); |
| 35 assert_equals(new PromiseRejectionEvent('eventType', { promise: p, reason: r }
).reason, r); |
| 36 |
| 37 |
| 38 // All initializers are passed. |
| 39 assert_equals(new PromiseRejectionEvent('eventType', { bubbles: true, cancelab
le: true, promise: p, reason: r }).bubbles, true); |
| 40 assert_equals(new PromiseRejectionEvent('eventType', { bubbles: true, cancelab
le: true, promise: p, reason: r }).cancelable, true); |
| 41 assert_equals(new PromiseRejectionEvent('eventType', { bubbles: true, cancelab
le: true, promise: p, reason: r }).promise, p); |
| 42 assert_equals(new PromiseRejectionEvent('eventType', { bubbles: true, cancelab
le: true, promise: p, reason: r }).reason, r); |
| 43 }, "This tests the constructor for the PromiseRejectionEvent DOM class."); |
| 44 </script> |
OLD | NEW |