1 importScripts('../../../resources/js-test.js');
4 global.jsTestIsAsync = true;
6 description('Test Promise.');
10 var promise = new Promise(function(newResolve, newReject) {
16 shouldBeTrue('promise instanceof Promise');
17 shouldBe('promise.constructor', 'Promise');
18 shouldBeFalse('thisInInit === promise');
19 shouldBeTrue('thisInInit === global');
20 shouldBeTrue('resolve instanceof Function');
21 shouldBeTrue('reject instanceof Function');
23 shouldThrow('new Promise()', '"TypeError: Promise constructor takes a function argument"');
24 shouldThrow('new Promise(37)', '"TypeError: Promise constructor takes a function argument"');
26 shouldNotThrow('promise = new Promise(function() { throw Error("foo"); })');
27 promise.then(undefined, function(result) {
28 global.result = result;
29 shouldBeEqualToString('result.message', 'foo');
32 new Promise(function(resolve) {
35 }).then(function(result) {
36 global.result = result;
37 testPassed('fulfilled');
38 shouldBeEqualToString('result', 'hello');
41 global.result = result;
42 testFailed('rejected');