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

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

Issue 23567043: Promise init callback takes resolve and reject functions (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 3 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 var global = this; 3 var global = this;
4 global.jsTestIsAsync = true; 4 global.jsTestIsAsync = true;
5 5
6 description('Test Promise.'); 6 description('Test Promise.');
7 7
8 var thisInInit; 8 var thisInInit;
9 var resolver; 9 var resolve, reject;
10 var promise = new Promise(function(r) { 10 var promise = new Promise(function(newResolve, newReject) {
11 thisInInit = this; 11 thisInInit = this;
12 resolver = r; 12 resolve = newResolve;
13 reject = newReject;
13 }); 14 });
14 15
15 shouldBeTrue('promise instanceof Promise'); 16 shouldBeTrue('promise instanceof Promise');
16 shouldBe('promise.constructor', 'Promise'); 17 shouldBe('promise.constructor', 'Promise');
17 shouldBe('thisInInit', 'promise'); 18 shouldBe('thisInInit', 'promise');
18 shouldBeTrue('resolver instanceof PromiseResolver'); 19 shouldBeTrue('resolve instanceof Function');
19 shouldBe('resolver.constructor', 'PromiseResolver'); 20 shouldBeTrue('reject instanceof Function');
20 21
21 shouldThrow('new Promise()', '"TypeError: Promise constructor takes a function a rgument"'); 22 shouldThrow('new Promise()', '"TypeError: Promise constructor takes a function a rgument"');
22 shouldThrow('new Promise(37)', '"TypeError: Promise constructor takes a function argument"'); 23 shouldThrow('new Promise(37)', '"TypeError: Promise constructor takes a function argument"');
23 24
24 shouldNotThrow('promise = new Promise(function() { throw Error("foo"); })'); 25 shouldNotThrow('promise = new Promise(function() { throw Error("foo"); })');
25 promise.then(undefined, function(result) { 26 promise.then(undefined, function(result) {
26 global.result = result; 27 global.result = result;
27 shouldBeEqualToString('result.message', 'foo'); 28 shouldBeEqualToString('result.message', 'foo');
28 }); 29 });
29 30
30 new Promise(function(resolver) { 31 new Promise(function(resolve) {
31 resolver.fulfill("hello"); 32 resolve("hello");
32 throw Error("foo"); 33 throw Error("foo");
33 }).then(function(result) { 34 }).then(function(result) {
34 global.result = result; 35 global.result = result;
35 testPassed('fulfilled'); 36 testPassed('fulfilled');
36 shouldBeEqualToString('result', 'hello'); 37 shouldBeEqualToString('result', 'hello');
37 finishJSTest(); 38 finishJSTest();
38 }, function(result) { 39 }, function(result) {
39 global.result = result; 40 global.result = result;
40 testFailed('rejected'); 41 testFailed('rejected');
41 finishJSTest(); 42 finishJSTest();
42 }); 43 });
43 44
44 45
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698