Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: LayoutTests/fast/js/resources/Promise-catch-in-workers.js

Issue 24980002: Implement AP2 Promises (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 var reject; 8 var reject;
9 9
10 var firstPromise = new Promise(function(newResolve, newReject) { 10 var firstPromise = new Promise(function(newResolve, newReject) {
11 global.thisInInit = this; 11 global.thisInInit = this;
12 reject = newReject; 12 reject = newReject;
13 }); 13 });
14 14
15 var secondPromise = firstPromise.catch(function(result) { 15 var secondPromise = firstPromise.catch(function(result) {
16 global.thisInFulfillCallback = this; 16 global.thisInFulfillCallback = this;
17 shouldBeFalse('thisInFulfillCallback === firstPromise'); 17 shouldBeFalse('thisInFulfillCallback === firstPromise');
18 shouldBeTrue('thisInFulfillCallback === secondPromise'); 18 shouldBeFalse('thisInFulfillCallback === secondPromise');
19 shouldBeTrue('thisInFulfillCallback === global');
19 global.result = result; 20 global.result = result;
20 shouldBeEqualToString('result', 'hello'); 21 shouldBeEqualToString('result', 'hello');
21 return 'bye'; 22 return 'bye';
22 }); 23 });
23 24
24 secondPromise.then(function(result) { 25 secondPromise.then(function(result) {
25 global.result = result; 26 global.result = result;
26 shouldBeEqualToString('result', 'bye'); 27 shouldBeEqualToString('result', 'bye');
27 testPassed('fulfilled'); 28 testPassed('fulfilled');
28 finishJSTest(); 29 finishJSTest();
29 }, function() { 30 }, function() {
30 testFailed('rejected'); 31 testFailed('rejected');
31 finishJSTest(); 32 finishJSTest();
32 }, function() { 33 }, function() {
33 }); 34 });
34 35
35 shouldBeTrue('thisInInit === firstPromise'); 36 shouldBeFalse('thisInInit === firstPromise');
37 shouldBeTrue('thisInInit === global');
36 shouldBeTrue('firstPromise instanceof Promise'); 38 shouldBeTrue('firstPromise instanceof Promise');
37 shouldBeTrue('secondPromise instanceof Promise'); 39 shouldBeTrue('secondPromise instanceof Promise');
38 40
39 shouldThrow('firstPromise.catch(null)', '"TypeError: rejectCallback must be a fu nction or undefined"'); 41 shouldThrow('firstPromise.catch(null)', '"TypeError: onRejected must be a functi on or undefined"');
40 shouldThrow('firstPromise.catch(37)', '"TypeError: rejectCallback must be a func tion or undefined"'); 42 shouldThrow('firstPromise.catch(37)', '"TypeError: onRejected must be a function or undefined"');
41 43
42 reject('hello'); 44 reject('hello');
43 45
OLDNEW
« no previous file with comments | « LayoutTests/fast/js/Promise-then-in-workers-expected.txt ('k') | LayoutTests/fast/js/resources/Promise-init-in-workers.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698