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

Side by Side Diff: LayoutTests/fast/js/Promise-bindings-check-exception.html

Issue 675693002: An API returning a Promise should not throw an exceptions [overload version] (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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
« no previous file with comments | « no previous file | LayoutTests/fast/js/Promise-bindings-check-exception-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../../resources/js-test.js"></script> 2 <script src="../../resources/js-test.js"></script>
3 <div id="description"></div> 3 <div id="description"></div>
4 <div id="console"></div> 4 <div id="console"></div>
5 <script> 5 <script>
6 // http://heycam.github.io/webidl/#es-operations 6 // http://heycam.github.io/webidl/#es-operations
7 description('Operations that return a Promise type should handle exceptions ' + 7 description('Operations that return a Promise type should handle exceptions ' +
8 'by returning a rejected Promise with the exception.') 8 'by returning a rejected Promise with the exception.')
9 9
10 window.jsTestIsAsync = true; 10 window.jsTestIsAsync = true;
(...skipping 18 matching lines...) Expand all
29 testFailed('Rejected unexpectedly: ' + message); 29 testFailed('Rejected unexpectedly: ' + message);
30 reason = e; 30 reason = e;
31 shouldBeTrue('reason instanceof Error'); 31 shouldBeTrue('reason instanceof Error');
32 debug(e); 32 debug(e);
33 }); 33 });
34 } 34 }
35 35
36 var check = internals.promiseCheck.bind(internals); 36 var check = internals.promiseCheck.bind(internals);
37 var check2 = internals.promiseCheckWithoutExceptionState.bind(internals); 37 var check2 = internals.promiseCheckWithoutExceptionState.bind(internals);
38 var check3 = internals.promiseCheckRange.bind(internals); 38 var check3 = internals.promiseCheckRange.bind(internals);
39 var check4 = internals.promiseCheckOverload.bind(internals);
39 40
40 Promise.resolve().then(function() { 41 Promise.resolve().then(function() {
41 return shouldBeRejected(check(), 'no arguments'); 42 return shouldBeRejected(check(), 'no arguments');
42 }).then(function() { 43 }).then(function() {
43 return shouldBeResolved(check(3, true, {}, '', ['']), 'valid arguments'); 44 return shouldBeResolved(check(3, true, {}, '', ['']), 'valid arguments');
44 }).then(function() { 45 }).then(function() {
45 return shouldBeResolved(check(null, true, {}, '', []), 'convert(long)'); 46 return shouldBeResolved(check(null, true, {}, '', []), 'convert(long)');
46 }).then(function() { 47 }).then(function() {
47 return shouldBeResolved(check(3, {}, {}, '', []), 'convert(boolean)'); 48 return shouldBeResolved(check(3, {}, {}, '', []), 'convert(boolean)');
48 }).then(function() { 49 }).then(function() {
(...skipping 28 matching lines...) Expand all
77 return shouldBeResolved(check2({}, '', {}, 3), 'convert(String...)'); 78 return shouldBeResolved(check2({}, '', {}, 3), 'convert(String...)');
78 }).then(function() { 79 }).then(function() {
79 var x = { 80 var x = {
80 toString: function() { 81 toString: function() {
81 throw Error('Thrown from toString'); 82 throw Error('Thrown from toString');
82 } 83 }
83 }; 84 };
84 return shouldBeRejected(check2({}, '', '', x), 'conversion error(String...)' ); 85 return shouldBeRejected(check2({}, '', '', x), 'conversion error(String...)' );
85 }).then(function() { 86 }).then(function() {
86 return shouldBeRejected(check3(-1), 'range error(octet)'); 87 return shouldBeRejected(check3(-1), 'range error(octet)');
88 }).then(function() {
89 return shouldBeResolved(check4(location), 'valid argument (Location)');
90 }).then(function() {
91 return shouldBeResolved(check4(document), 'valid argument (Document)');
92 }).then(function() {
93 return shouldBeResolved(check4(location, 0, 0), 'valid argument (Location, l ong, long)');
94 }).then(function() {
95 return shouldBeRejected(check4({}), 'type error (Object)');
96 }).then(function() {
97 return shouldBeRejected(check4(location, 0), 'type error (Location, long)');
87 }).then(undefined, function(e) { 98 }).then(undefined, function(e) {
88 testFailed('An exception is thrown from a method'); 99 testFailed('An exception is thrown from a method');
89 debug(e); 100 debug(e);
90 }).then(finishJSTest, finishJSTest); 101 }).then(finishJSTest, finishJSTest);
91 </script> 102 </script>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/js/Promise-bindings-check-exception-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698