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

Side by Side Diff: test/mjsunit/es6/debug-promises-caught-late.js

Issue 266533003: Reland "Trigger exception debug event for promises at the throw site." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix 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
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 we only listen to uncaught exceptions and 7 // Test debug events when we only listen to uncaught exceptions, the Promise
8 // there is a catch handler for the exception thrown in a Promise. 8 // throws, and a catch handler is installed right before throwing.
9 // Expectation: 9 // We expect no debug event to be triggered.
10 // - no debug event is triggered.
11 10
12 Debug = debug.Debug; 11 Debug = debug.Debug;
13 12
14 var p = new Promise(function(resolve, reject) { 13 var p = new Promise(function(resolve, reject) {
15 resolve(); 14 resolve();
16 }); 15 });
17 16
18 var q = p.chain( 17 var q = p.chain(
19 function() { 18 function() {
19 q.catch(function(e) {
20 assertEquals("caught", e.message);
21 });
20 throw new Error("caught"); 22 throw new Error("caught");
21 }); 23 });
22 24
23 q.catch(
24 function(e) {
25 assertEquals("caught", e.message);
26 });
27
28 function listener(event, exec_state, event_data, data) { 25 function listener(event, exec_state, event_data, data) {
29 try { 26 try {
30 assertTrue(event != Debug.DebugEvent.Exception); 27 assertTrue(event != Debug.DebugEvent.Exception);
31 assertTrue(event != Debug.DebugEvent.PendingExceptionInPromise);
32 } catch (e) { 28 } catch (e) {
33 // Signal a failure with exit code 1. This is necessary since the 29 // Signal a failure with exit code 1. This is necessary since the
34 // debugger swallows exceptions and we expect the chained function 30 // debugger swallows exceptions and we expect the chained function
35 // and this listener to be executed after the main script is finished. 31 // and this listener to be executed after the main script is finished.
36 print("Unexpected exception: " + e + "\n" + e.stack); 32 print("Unexpected exception: " + e + "\n" + e.stack);
37 quit(1); 33 quit(1);
38 } 34 }
39 } 35 }
40 36
41 Debug.setBreakOnUncaughtException(); 37 Debug.setBreakOnUncaughtException();
42 Debug.setListener(listener); 38 Debug.setListener(listener);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698