| <script src="../resources/js-test-pre.js"></script> |
| <div id="description"></div> |
| description('Test Promise.'); |
| window.jsTestIsAsync = true; |
| var firstPromise = new Promise(function(newResolver) { |
| window.thisInInit = this; |
| var secondPromise = firstPromise.catch(function(result) { |
| window.thisInFulfillCallback = this; |
| shouldBeFalse('thisInFulfillCallback === firstPromise'); |
| shouldBeTrue('thisInFulfillCallback === secondPromise'); |
| shouldBeEqualToString('result', 'hello'); |
| secondPromise.then(function(result) { |
| shouldBeEqualToString('result', 'bye'); |
| shouldBeTrue('thisInInit === firstPromise'); |
| shouldBeTrue('firstPromise instanceof Promise'); |
| shouldBeTrue('secondPromise instanceof Promise'); |
| shouldThrow('firstPromise.catch(null)', '"TypeError: Expected function or undefined as as first argument"'); |
| shouldThrow('firstPromise.catch(37)', '"TypeError: Expected function or undefined as as first argument"'); |
| resolver.reject('hello'); |
| <script src="../resources/js-test-post.js"></script> |