1 importScripts('../../../resources/js-test.js');
3 description('Test Promise.');
7 global.jsTestIsAsync = true;
11 var firstPromise = new Promise(function(newResolve) {
12 global.thisInInit = this;
16 var secondPromise = firstPromise.then(function(result) {
17 global.thisInFulfillCallback = this;
18 shouldBeFalse('thisInFulfillCallback === firstPromise');
19 shouldBeFalse('thisInFulfillCallback === secondPromise');
20 shouldBeTrue('thisInFulfillCallback === global');
21 global.result = result;
22 shouldBeEqualToString('result', 'hello');
26 shouldBeFalse('thisInInit === firstPromise');
27 shouldBeTrue('thisInInit === global');
28 shouldBeTrue('firstPromise instanceof Promise');
29 shouldBeTrue('secondPromise instanceof Promise');
31 secondPromise.then(null, 37).then(function(result) {
32 global.result = result;
33 shouldBeEqualToString('result', 'world');
35 }).then(1, 2).then(function() {
36 testFailed('resolved');
38 testPassed('rejected');
39 global.result = result;
40 shouldBeEqualToString('result', 'exception');
42 testPassed('resolved');
45 testFailed('rejected');