Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / constructors / promise-rejection-event-constructor.html
blobf1649a2d4446cbadacb09d3d69fa69c895109980
1 <!DOCTYPE html>
2 <meta charset="utf-8">
3 <script src="../../../resources/testharness.js"></script>
4 <script src="../../../resources/testharnessreport.js"></script>
5 <script>
6 'use strict';
8 test(function() {
9 var p = new Promise(function(resolve, reject) {});
11 // No initializer is passed.
12 assert_equals(new PromiseRejectionEvent('eventType').bubbles, false);
13 assert_equals(new PromiseRejectionEvent('eventType').cancelable, false);
14 assert_equals(new PromiseRejectionEvent('eventType').promise, null);
15 assert_equals(new PromiseRejectionEvent('eventType').reason, null);
17 // No promise is passed.
18 assert_throws(new TypeError(),
19 function() {
20 new PromiseRejectionEvent('eventType', { bubbles: false });
21 },
22 'Cannot construct PromiseRejectionEventInit without promise');
24 // bubbles is passed.
25 assert_equals(new PromiseRejectionEvent('eventType', { bubbles: false, promise: p }).bubbles, false);
26 assert_equals(new PromiseRejectionEvent('eventType', { bubbles: true, promise: p }).bubbles, true);
28 // cancelable is passed.
29 assert_equals(new PromiseRejectionEvent('eventType', { cancelable: false, promise: p }).cancelable, false);
30 assert_equals(new PromiseRejectionEvent('eventType', { cancelable: true, promise: p }).cancelable, true);
32 // promise is passed.
33 assert_equals(new PromiseRejectionEvent('eventType', { promise: p }).promise, p);
35 // reason is passed.
36 var r = new Error();
37 assert_equals(new PromiseRejectionEvent('eventType', { promise: p, reason: r }).reason, r);
40 // All initializers are passed.
41 assert_equals(new PromiseRejectionEvent('eventType', { bubbles: true, cancelable: true, promise: p, reason: r }).bubbles, true);
42 assert_equals(new PromiseRejectionEvent('eventType', { bubbles: true, cancelable: true, promise: p, reason: r }).cancelable, true);
43 assert_equals(new PromiseRejectionEvent('eventType', { bubbles: true, cancelable: true, promise: p, reason: r }).promise, p);
44 assert_equals(new PromiseRejectionEvent('eventType', { bubbles: true, cancelable: true, promise: p, reason: r }).reason, r);
45 }, "This tests the constructor for the PromiseRejectionEvent DOM class.");
46 </script>