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

Side by Side Diff: test/mjsunit/es6/debug-promises-undefined-reject.js

Issue 262533009: Revert "Trigger exception debug event for promises at the throw site." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « test/mjsunit/es6/debug-promises-uncaught-uncaught.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --harmony-promises --expose-debug-as debug 5 // Flags: --harmony-promises --expose-debug-as debug
6 6
7 // Test debug events when an exception is thrown inside a Promise, which is 7 // Test debug events when an exception is thrown inside a Promise, which is
8 // caught by a custom promise, which has no reject handler. 8 // caught by a custom promise, which has no reject handler.
9 // We expect an Exception event with a promise to be triggered. 9 // We expect a PendingExceptionInPromise event to be triggered.
10 10
11 Debug = debug.Debug; 11 Debug = debug.Debug;
12 12
13 var log = []; 13 var log = [];
14 var step = 0; 14 var step = 0;
15 15
16 var p = new Promise(function(resolve, reject) { 16 var p = new Promise(function(resolve, reject) {
17 log.push("resolve"); 17 log.push("resolve");
18 resolve(); 18 resolve();
19 }); 19 });
20 20
21 function MyPromise(resolver) { 21 function MyPromise(resolver) {
22 var reject = undefined; 22 var reject = undefined;
23 var resolve = function() { }; 23 var resolve = function() { };
24 log.push("construct"); 24 log.push("construct");
25 resolver(resolve, reject); 25 resolver(resolve, reject);
26 }; 26 };
27 27
28 MyPromise.prototype = p; 28 MyPromise.prototype = p;
29 p.constructor = MyPromise; 29 p.constructor = MyPromise;
30 30
31 var q = p.chain( 31 var q = p.chain(
32 function() { 32 function() {
33 log.push("throw caught"); 33 log.push("throw caught");
34 throw new Error("caught"); // event 34 throw new Error("caught");
35 }); 35 });
36 36
37 function listener(event, exec_state, event_data, data) { 37 function listener(event, exec_state, event_data, data) {
38 try { 38 try {
39 if (event == Debug.DebugEvent.Exception) { 39 if (event == Debug.DebugEvent.PendingExceptionInPromise) {
40 assertEquals(["resolve", "construct", "end main", "throw caught"], log); 40 assertEquals(["resolve", "construct", "end main", "throw caught"], log);
41 assertEquals("undefined is not a function", 41 assertEquals("caught", event_data.exception().message);
42 event_data.exception().message); 42 } else if (event == Debug.DebugEvent.Exception) {
43 assertEquals(q, event_data.promise()); 43 assertUnreachable();
44 } 44 }
45 } catch (e) { 45 } catch (e) {
46 // Signal a failure with exit code 1. This is necessary since the 46 // Signal a failure with exit code 1. This is necessary since the
47 // debugger swallows exceptions and we expect the chained function 47 // debugger swallows exceptions and we expect the chained function
48 // and this listener to be executed after the main script is finished. 48 // and this listener to be executed after the main script is finished.
49 print("Unexpected exception: " + e + "\n" + e.stack); 49 print("Unexpected exception: " + e + "\n" + e.stack);
50 quit(1); 50 quit(1);
51 } 51 }
52 } 52 }
53 53
54 Debug.setBreakOnUncaughtException(); 54 Debug.setBreakOnUncaughtException();
55 Debug.setListener(listener); 55 Debug.setListener(listener);
56 56
57 log.push("end main"); 57 log.push("end main");
OLDNEW
« no previous file with comments | « test/mjsunit/es6/debug-promises-uncaught-uncaught.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698