| 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 value = { | |
| 14 then: function(fulfillCallback, rejectCallback) { | |
| 15 testPassed('value.then is called.'); | |
| 16 window.thisValue = this; | |
| 17 shouldBe('thisValue', 'value'); | |
| 18 rejectCallback('hello'); | |
| 19 } | |
| 20 }; | |
| 21 var promise = new Promise(function(resolve) { resolve(value); }); | |
| 22 | |
| 23 promise.then(function(result) { | |
| 24 testFailed('fulfilled'); | |
| 25 finishJSTest(); | |
| 26 }, function(result) { | |
| 27 testPassed('rejected'); | |
| 28 window.result = result; | |
| 29 shouldBeEqualToString('result', 'hello'); | |
| 30 finishJSTest(); | |
| 31 }); | |
| 32 | |
| 33 debug('The promise is not rejected now.'); | |
| 34 | |
| 35 </script> | |
| 36 </body> | |
| 37 </html> | |
| OLD | NEW |