| <script src="../../resources/js-test-pre.js"></script> |
| <div id="description"></div> |
| window.jsTestIsAsync = true; |
| description('Test Promise.'); |
| var promise = new Promise(function(r) { |
| shouldBeTrue('promise instanceof Promise'); |
| shouldBe('promise.constructor', 'Promise'); |
| shouldBe('thisInInit', 'promise'); |
| shouldBeTrue('resolver instanceof PromiseResolver'); |
| shouldBe('resolver.constructor', 'PromiseResolver'); |
| shouldThrow('new Promise()', '"TypeError: Expected at least one argument"'); |
| shouldThrow('new Promise(37)', '"TypeError: Expected function as as first argument"'); |
| shouldNotThrow('promise = new Promise(function() { throw Error("foo"); })'); |
| promise.then(undefined, function(result) { |
| shouldBeEqualToString('result.message', 'foo'); |
| new Promise(function(resolver) { |
| resolver.fulfill("hello"); |
| }).then(function(result) { |
| shouldBeEqualToString('result', 'hello'); |
| <script src="../../resources/js-test-post.js"></script> |