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

Side by Side Diff: LayoutTests/fast/js/Promise-init.html

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 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="resources/js-test-pre.js"></script> 4 <script src="resources/js-test-pre.js"></script>
5 </head> 5 </head>
6 <body> 6 <body>
7 <div id="description"></div> 7 <div id="description"></div>
8 <div id="console"></div> 8 <div id="console"></div>
9 <script> 9 <script>
10 window.jsTestIsAsync = true; 10 window.jsTestIsAsync = true;
11 11
12 description('Test Promise.'); 12 description('Test Promise.');
13 13
14 var thisInInit; 14 var thisInInit;
15 var resolver; 15 var resolve, reject;
16 var promise = new Promise(function(r) { 16 var promise = new Promise(function(newResolve, newReject) {
17 thisInInit = this; 17 thisInInit = this;
18 resolver = r; 18 resolve = newResolve;
19 reject = newReject;
19 }); 20 });
20 21
21 shouldBeTrue('promise instanceof Promise'); 22 shouldBeTrue('promise instanceof Promise');
22 shouldBe('promise.constructor', 'Promise'); 23 shouldBe('promise.constructor', 'Promise');
23 shouldBe('thisInInit', 'promise'); 24 shouldBe('thisInInit', 'promise');
24 shouldBeTrue('resolver instanceof PromiseResolver'); 25 shouldBeTrue('resolve instanceof Function');
25 shouldBe('resolver.constructor', 'PromiseResolver'); 26 shouldBeTrue('reject instanceof Function');
26 27
27 shouldThrow('new Promise()', '"TypeError: Promise constructor takes a function a rgument"'); 28 shouldThrow('new Promise()', '"TypeError: Promise constructor takes a function a rgument"');
28 shouldThrow('new Promise(37)', '"TypeError: Promise constructor takes a function argument"'); 29 shouldThrow('new Promise(37)', '"TypeError: Promise constructor takes a function argument"');
29 30
30 shouldNotThrow('promise = new Promise(function() { throw Error("foo"); })'); 31 shouldNotThrow('promise = new Promise(function() { throw Error("foo"); })');
31 promise.then(undefined, function(result) { 32 promise.then(undefined, function(result) {
32 window.result = result; 33 window.result = result;
33 shouldBeEqualToString('result.message', 'foo'); 34 shouldBeEqualToString('result.message', 'foo');
34 }); 35 });
35 36
36 new Promise(function(resolver) { 37 new Promise(function(resolve) {
37 resolver.fulfill("hello"); 38 resolve("hello");
38 throw Error("foo"); 39 throw Error("foo");
39 }).then(function(result) { 40 }).then(function(result) {
40 window.result = result; 41 window.result = result;
41 testPassed('fulfilled'); 42 testPassed('fulfilled');
42 shouldBeEqualToString('result', 'hello'); 43 shouldBeEqualToString('result', 'hello');
43 finishJSTest(); 44 finishJSTest();
44 }, function(result) { 45 }, function(result) {
45 window.result = result; 46 window.result = result;
46 testFailed('rejected'); 47 testFailed('rejected');
47 finishJSTest(); 48 finishJSTest();
48 }); 49 });
49 50
50 </script> 51 </script>
51 <script src="resources/js-test-post.js"></script> 52 <script src="resources/js-test-post.js"></script>
52 </body> 53 </body>
53 </html> 54 </html>
OLDNEW
« no previous file with comments | « LayoutTests/fast/js/Promise-fulfill-in-workers-expected.txt ('k') | LayoutTests/fast/js/Promise-init-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698