| <script src="../../resources/js-test-pre.js"></script> |
| <div id="description"></div> |
| window.jsTestIsAsync = true; |
| description('Test Promise.'); |
| var promise = new Promise(function(newResolve, newReject) { |
| shouldBeTrue('promise instanceof Promise'); |
| shouldBe('promise.constructor', 'Promise'); |
| shouldBeFalse('thisInInit === promise'); |
| shouldBeTrue('thisInInit === window'); |
| shouldBeTrue('resolve instanceof Function'); |
| shouldBeTrue('reject instanceof Function'); |
| shouldThrow('new Promise()', '"TypeError: Promise constructor takes a function argument"'); |
| shouldThrow('new Promise(37)', '"TypeError: Promise constructor takes a function argument"'); |
| shouldNotThrow('promise = new Promise(function() { throw Error("foo"); })'); |
| promise.then(undefined, function(result) { |
| shouldBeEqualToString('result.message', 'foo'); |
| new Promise(function(resolve) { |
| }).then(function(result) { |
| shouldBeEqualToString('result', 'hello'); |
| <script src="../../resources/js-test-post.js"></script> |