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

Side by Side Diff: LayoutTests/fast/js/resources/Promise-init-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 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 resolve, reject; 9 var resolve, reject;
10 var promise = new Promise(function(newResolve, newReject) { 10 var promise = new Promise(function(newResolve, newReject) {
11 thisInInit = this; 11 thisInInit = this;
12 resolve = newResolve; 12 resolve = newResolve;
13 reject = newReject; 13 reject = newReject;
14 }); 14 });
15 15
16 shouldBeTrue('promise instanceof Promise'); 16 shouldBeTrue('promise instanceof Promise');
17 shouldBe('promise.constructor', 'Promise'); 17 shouldBe('promise.constructor', 'Promise');
18 shouldBe('thisInInit', 'promise'); 18 shouldBeFalse('thisInInit === promise');
19 shouldBeTrue('thisInInit === global');
19 shouldBeTrue('resolve instanceof Function'); 20 shouldBeTrue('resolve instanceof Function');
20 shouldBeTrue('reject instanceof Function'); 21 shouldBeTrue('reject instanceof Function');
21 22
22 shouldThrow('new Promise()', '"TypeError: Promise constructor takes a function a rgument"'); 23 shouldThrow('new Promise()', '"TypeError: Promise constructor takes a function a rgument"');
23 shouldThrow('new Promise(37)', '"TypeError: Promise constructor takes a function argument"'); 24 shouldThrow('new Promise(37)', '"TypeError: Promise constructor takes a function argument"');
24 25
25 shouldNotThrow('promise = new Promise(function() { throw Error("foo"); })'); 26 shouldNotThrow('promise = new Promise(function() { throw Error("foo"); })');
26 promise.then(undefined, function(result) { 27 promise.then(undefined, function(result) {
27 global.result = result; 28 global.result = result;
28 shouldBeEqualToString('result.message', 'foo'); 29 shouldBeEqualToString('result.message', 'foo');
29 }); 30 });
30 31
31 new Promise(function(resolve) { 32 new Promise(function(resolve) {
32 resolve("hello"); 33 resolve("hello");
33 throw Error("foo"); 34 throw Error("foo");
34 }).then(function(result) { 35 }).then(function(result) {
35 global.result = result; 36 global.result = result;
36 testPassed('fulfilled'); 37 testPassed('fulfilled');
37 shouldBeEqualToString('result', 'hello'); 38 shouldBeEqualToString('result', 'hello');
38 finishJSTest(); 39 finishJSTest();
39 }, function(result) { 40 }, function(result) {
40 global.result = result; 41 global.result = result;
41 testFailed('rejected'); 42 testFailed('rejected');
42 finishJSTest(); 43 finishJSTest();
43 }); 44 });
44 45
45 46
OLDNEW
« no previous file with comments | « LayoutTests/fast/js/resources/Promise-catch-in-workers.js ('k') | LayoutTests/fast/js/resources/Promise-resolve-in-workers.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698