| <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.then(function(result) { |
| window.thisInFulfillCallback = this; |
| shouldBeFalse('thisInFulfillCallback === firstPromise'); |
| shouldBeTrue('thisInFulfillCallback === secondPromise'); |
| shouldBeEqualToString('result', 'hello'); |
| shouldBeTrue('thisInInit === firstPromise'); |
| shouldBeTrue('firstPromise instanceof Promise'); |
| shouldBeTrue('secondPromise instanceof Promise'); |
| shouldThrow('firstPromise.then(null)', '"TypeError: Expected function or undefined as as first argument"'); |
| shouldThrow('firstPromise.then(undefined, null)', '"TypeError: Expected function or undefined as as second argument"'); |
| shouldThrow('firstPromise.then(37)', '"TypeError: Expected function or undefined as as first argument"'); |
| resolver.fulfill('hello'); |
| <script src="../resources/js-test-post.js"></script> |