OLD | NEW |
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 and |
8 // there is a catch handler for the exception thrown in a Promise. | 8 // there is a catch handler for the exception thrown in a Promise. |
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() { |
20 throw new Error("caught"); | 19 throw new Error("caught"); |
21 }); | 20 }); |
22 | 21 |
23 q.catch( | 22 q.catch( |
24 function(e) { | 23 function(e) { |
25 assertEquals("caught", e.message); | 24 assertEquals("caught", e.message); |
26 }); | 25 }); |
27 | 26 |
28 function listener(event, exec_state, event_data, data) { | 27 function listener(event, exec_state, event_data, data) { |
29 try { | 28 try { |
30 assertTrue(event != Debug.DebugEvent.Exception); | 29 assertTrue(event != Debug.DebugEvent.Exception); |
31 assertTrue(event != Debug.DebugEvent.PendingExceptionInPromise); | |
32 } catch (e) { | 30 } catch (e) { |
33 // Signal a failure with exit code 1. This is necessary since the | 31 // Signal a failure with exit code 1. This is necessary since the |
34 // debugger swallows exceptions and we expect the chained function | 32 // debugger swallows exceptions and we expect the chained function |
35 // and this listener to be executed after the main script is finished. | 33 // and this listener to be executed after the main script is finished. |
36 print("Unexpected exception: " + e + "\n" + e.stack); | 34 print("Unexpected exception: " + e + "\n" + e.stack); |
37 quit(1); | 35 quit(1); |
38 } | 36 } |
39 } | 37 } |
40 | 38 |
41 Debug.setBreakOnUncaughtException(); | 39 Debug.setBreakOnUncaughtException(); |
42 Debug.setListener(listener); | 40 Debug.setListener(listener); |
OLD | NEW |