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

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

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 <!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 resolve, reject; 15 var resolve, reject;
16 var promise = new Promise(function(newResolve, newReject) { 16 var promise = new Promise(function(newResolve, newReject) {
17 thisInInit = this; 17 thisInInit = this;
18 resolve = newResolve; 18 resolve = newResolve;
19 reject = newReject; 19 reject = newReject;
20 }); 20 });
21 21
22 shouldBeTrue('promise instanceof Promise'); 22 shouldBeTrue('promise instanceof Promise');
23 shouldBe('promise.constructor', 'Promise'); 23 shouldBe('promise.constructor', 'Promise');
24 shouldBe('thisInInit', 'promise'); 24 shouldBeFalse('thisInInit === promise');
25 shouldBeTrue('thisInInit === window');
25 shouldBeTrue('resolve instanceof Function'); 26 shouldBeTrue('resolve instanceof Function');
26 shouldBeTrue('reject instanceof Function'); 27 shouldBeTrue('reject instanceof Function');
27 28
28 shouldThrow('new Promise()', '"TypeError: Promise constructor takes a function a rgument"'); 29 shouldThrow('new Promise()', '"TypeError: Promise constructor takes a function a rgument"');
29 shouldThrow('new Promise(37)', '"TypeError: Promise constructor takes a function argument"'); 30 shouldThrow('new Promise(37)', '"TypeError: Promise constructor takes a function argument"');
30 31
31 shouldNotThrow('promise = new Promise(function() { throw Error("foo"); })'); 32 shouldNotThrow('promise = new Promise(function() { throw Error("foo"); })');
32 promise.then(undefined, function(result) { 33 promise.then(undefined, function(result) {
33 window.result = result; 34 window.result = result;
34 shouldBeEqualToString('result.message', 'foo'); 35 shouldBeEqualToString('result.message', 'foo');
(...skipping 10 matching lines...) Expand all
45 }, function(result) { 46 }, function(result) {
46 window.result = result; 47 window.result = result;
47 testFailed('rejected'); 48 testFailed('rejected');
48 finishJSTest(); 49 finishJSTest();
49 }); 50 });
50 51
51 </script> 52 </script>
52 <script src="resources/js-test-post.js"></script> 53 <script src="resources/js-test-post.js"></script>
53 </body> 54 </body>
54 </html> 55 </html>
OLDNEW
« no previous file with comments | « LayoutTests/fast/js/Promise-exception-expected.txt ('k') | LayoutTests/fast/js/Promise-init-callback-receiver.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698