OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <html> | |
3 <head> | |
4 <script src="../../resources/js-test.js"></script> | |
5 </head> | |
6 <body> | |
7 <div id="description"></div> | |
8 <div id="console"></div> | |
9 <script> | |
10 description('Test Promise.'); | |
11 | |
12 window.jsTestIsAsync = true; | |
13 var reject; | |
14 | |
15 var firstPromise = new Promise(function(_, newReject) { | |
16 window.thisInInit = this; | |
17 reject = newReject; | |
18 }); | |
19 | |
20 var secondPromise = firstPromise.catch(function(result) { | |
21 window.thisInFulfillCallback = this; | |
22 shouldBeFalse('thisInFulfillCallback === firstPromise'); | |
23 shouldBeFalse('thisInFulfillCallback === secondPromise'); | |
24 shouldBeTrue('thisInFulfillCallback === window'); | |
25 window.result = result; | |
26 shouldBeEqualToString('result', 'hello'); | |
27 return 'bye'; | |
28 }); | |
29 | |
30 secondPromise.then(function(result) { | |
31 window.result = result; | |
32 shouldBeEqualToString('result', 'bye'); | |
33 testPassed('fulfilled'); | |
34 finishJSTest(); | |
35 }, function() { | |
36 testFailed('rejected'); | |
37 finishJSTest(); | |
38 }, function() { | |
39 }); | |
40 | |
41 shouldBeFalse('thisInInit === firstPromise'); | |
42 shouldBeTrue('thisInInit === window'); | |
43 shouldBeTrue('firstPromise instanceof Promise'); | |
44 shouldBeTrue('secondPromise instanceof Promise'); | |
45 | |
46 shouldThrow('firstPromise.catch(null)', '"TypeError: onRejected must be a functi
on or undefined"'); | |
47 shouldThrow('firstPromise.catch(37)', '"TypeError: onRejected must be a function
or undefined"'); | |
48 | |
49 reject('hello'); | |
50 </script> | |
51 </body> | |
52 </html> | |
OLD | NEW |