OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 // Flags: --harmony-promises --expose-debug-as debug | |
6 | |
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. | |
9 // Expectation: | |
10 // - no debug event is triggered. | |
11 | |
12 Debug = debug.Debug; | |
13 | |
14 var p = new Promise(function(resolve, reject) { | |
15 resolve(); | |
16 }); | |
17 | |
18 var q = p.chain( | |
19 function() { | |
20 throw new Error("caught"); | |
21 }); | |
22 | |
23 q.catch( | |
24 function(e) { | |
25 assertEquals("caught", e.message); | |
26 }); | |
27 | |
28 function listener(event, exec_state, event_data, data) { | |
29 try { | |
30 if (event == Debug.DebugEvent.Exception) { | |
31 assertUnreachable(); | |
32 } else if (event == Debug.DebugEvent.PendingExceptionInPromise) { | |
rossberg
2014/04/24 14:33:47
Use a single if with ||
Yang
2014/04/24 14:44:53
Done.
| |
33 assertUnreachable(); | |
34 } | |
35 } catch (e) { | |
36 // Signal a failure with exit code 1. This is necessary since the | |
37 // debugger swallows exceptions and we expect the chained function | |
38 // and this listener to be executed after the main script is finished. | |
39 print("Unexpected exception: " + e + "\n" + e.stack); | |
40 quit(1); | |
41 } | |
42 } | |
43 | |
44 Debug.setBreakOnUncaughtException(); | |
45 Debug.setListener(listener); | |
OLD | NEW |