Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <script src="resources/js-test-pre.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 | |
| 14 var resolver; | |
| 15 | |
| 16 var firstPromise = new Promise(function(newResolver) { | |
| 17 window.thisInInit = this; | |
| 18 resolver = newResolver; | |
| 19 }); | |
| 20 | |
| 21 var secondPromise = firstPromise.catch(function(value) { | |
| 22 window.thisInFulfillCallback = this; | |
| 23 shouldBeFalse("thisInFulfillCallback === firstPromise"); | |
| 24 shouldBeTrue("thisInFulfillCallback === secondPromise"); | |
| 25 window.value = value; | |
| 26 shouldBeEqualToString("value", "hello"); | |
| 27 }); | |
| 28 | |
| 29 secondPromise.then(function() { | |
| 30 debug("PASS fulfilled"); | |
| 31 finishJSTest(); | |
| 32 }, function() { | |
| 33 debug("FAIL rejected"); | |
| 34 finishJSTest(); | |
| 35 }, function() { | |
| 36 }); | |
| 37 | |
| 38 shouldBeTrue("thisInInit === firstPromise"); | |
| 39 shouldBeTrue("firstPromise instanceof Promise"); | |
| 40 shouldBeTrue("secondPromise instanceof Promise"); | |
| 41 | |
| 42 resolver.reject("hello"); | |
| 43 | |
| 44 </script> | |
| 45 <script src="resources/js-test-post.js"></script> | |
| 46 </body> | |
| 47 </html> | |
| 48 }); | |
| 49 | |
| 50 shouldBeTrue("thisInInit === firstPromise"); | |
| 51 shouldBeTrue("firstPromise instanceof Promise"); | |
| 52 shouldBeTrue("secondPromise instanceof Promise"); | |
| 53 | |
| 54 resolver.reject("hello"); | |
| 55 | |
| 56 </script> | |
| 57 <script src="resources/js-test-post.js"></script> | |
| 58 </body> | |
| 59 </html> | |
|
tyoshino (SeeGerritForStatus)
2013/06/14 04:57:53
Remove L49-59?
yhirano
2013/06/14 05:43:00
Done.
| |
| OLD | NEW |