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

Side by Side Diff: LayoutTests/fast/js/resources/Promise-then-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 8
9 var resolve; 9 var resolve;
10 10
11 var firstPromise = new Promise(function(newResolve) { 11 var firstPromise = new Promise(function(newResolve) {
12 global.thisInInit = this; 12 global.thisInInit = this;
13 resolve = newResolve; 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 shouldBeFalse('thisInFulfillCallback === secondPromise');
20 shouldBeTrue('thisInFulfillCallback === global');
20 global.result = result; 21 global.result = result;
21 shouldBeEqualToString('result', 'hello'); 22 shouldBeEqualToString('result', 'hello');
22 finishJSTest(); 23 finishJSTest();
23 }); 24 });
24 25
25 shouldBeTrue('thisInInit === firstPromise'); 26 shouldBeFalse('thisInInit === firstPromise');
27 shouldBeTrue('thisInInit === global');
26 shouldBeTrue('firstPromise instanceof Promise'); 28 shouldBeTrue('firstPromise instanceof Promise');
27 shouldBeTrue('secondPromise instanceof Promise'); 29 shouldBeTrue('secondPromise instanceof Promise');
28 30
29 shouldThrow('firstPromise.then(null)', '"TypeError: fulfillCallback must be a fu nction or undefined"'); 31 shouldThrow('firstPromise.then(null)', '"TypeError: onFulfilled must be a functi on or undefined"');
30 shouldThrow('firstPromise.then(undefined, null)', '"TypeError: rejectCallback mu st be a function or undefined"'); 32 shouldThrow('firstPromise.then(undefined, null)', '"TypeError: onRejected must b e a function or undefined"');
31 shouldThrow('firstPromise.then(37)', '"TypeError: fulfillCallback must be a func tion or undefined"'); 33 shouldThrow('firstPromise.then(37)', '"TypeError: onFulfilled must be a function or undefined"');
32 34
33 resolve('hello'); 35 resolve('hello');
34 36
35 37
OLDNEW
« no previous file with comments | « LayoutTests/fast/js/resources/Promise-simple-in-workers.js ('k') | Source/bindings/v8/ScriptPromiseResolver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698