| OLD | NEW |
| 1 importScripts('./js-test-pre.js'); | 1 importScripts('./js-test-pre.js'); |
| 2 | 2 |
| 3 description('Test Promise.'); | 3 description('Test Promise.'); |
| 4 | 4 |
| 5 var global = this; | 5 var global = this; |
| 6 | 6 |
| 7 global.jsTestIsAsync = true; | 7 global.jsTestIsAsync = true; |
| 8 | 8 |
| 9 var resolver; | 9 var resolve; |
| 10 | 10 |
| 11 var firstPromise = new Promise(function(newResolver) { | 11 var firstPromise = new Promise(function(newResolve) { |
| 12 global.thisInInit = this; | 12 global.thisInInit = this; |
| 13 resolver = newResolver; | 13 resolve = newResolve; |
| 14 }); | 14 }); |
| 15 | 15 |
| 16 var secondPromise = firstPromise.then(function(result) { | 16 var secondPromise = firstPromise.then(function(result) { |
| 17 global.thisInFulfillCallback = this; | 17 global.thisInFulfillCallback = this; |
| 18 shouldBeFalse('thisInFulfillCallback === firstPromise'); | 18 shouldBeFalse('thisInFulfillCallback === firstPromise'); |
| 19 shouldBeTrue('thisInFulfillCallback === secondPromise'); | 19 shouldBeTrue('thisInFulfillCallback === secondPromise'); |
| 20 global.result = result; | 20 global.result = result; |
| 21 shouldBeEqualToString('result', 'hello'); | 21 shouldBeEqualToString('result', 'hello'); |
| 22 finishJSTest(); | 22 finishJSTest(); |
| 23 }); | 23 }); |
| 24 | 24 |
| 25 shouldBeTrue('thisInInit === firstPromise'); | 25 shouldBeTrue('thisInInit === firstPromise'); |
| 26 shouldBeTrue('firstPromise instanceof Promise'); | 26 shouldBeTrue('firstPromise instanceof Promise'); |
| 27 shouldBeTrue('secondPromise instanceof Promise'); | 27 shouldBeTrue('secondPromise instanceof Promise'); |
| 28 | 28 |
| 29 shouldThrow('firstPromise.then(null)', '"TypeError: fulfillCallback must be a fu
nction or undefined"'); | 29 shouldThrow('firstPromise.then(null)', '"TypeError: fulfillCallback must be a fu
nction or undefined"'); |
| 30 shouldThrow('firstPromise.then(undefined, null)', '"TypeError: rejectCallback mu
st be a function or undefined"'); | 30 shouldThrow('firstPromise.then(undefined, null)', '"TypeError: rejectCallback mu
st be a function or undefined"'); |
| 31 shouldThrow('firstPromise.then(37)', '"TypeError: fulfillCallback must be a func
tion or undefined"'); | 31 shouldThrow('firstPromise.then(37)', '"TypeError: fulfillCallback must be a func
tion or undefined"'); |
| 32 | 32 |
| 33 resolver.fulfill('hello'); | 33 resolve('hello'); |
| 34 | 34 |
| 35 | 35 |
| OLD | NEW |