OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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: --expose-debug-as debug --allow-natives-syntax | |
6 | 5 |
7 // Test debug events when we only listen to uncaught exceptions and a | 6 // Test debug events when we only listen to uncaught exceptions and a |
8 // Promise p3 created by Promise.race has no catch handler, and is rejected | 7 // Promise p3 created by Promise.race has no catch handler, and is rejected |
9 // because one of the Promises p2 passed to Promise.race is rejected. | 8 // because one of the Promises p2 passed to Promise.race is rejected. |
10 // We expect one event for p2; the system recognizes the rejection of p3 | 9 // We expect one event for p2; the system recognizes the rejection of p3 |
11 // to be redundant and based on the rejection of p2 and does not trigger | 10 // to be redundant and based on the rejection of p2 and does not trigger |
12 // an additional rejection. | 11 // an additional rejection. |
13 | 12 |
14 var Debug = debug.Debug; | 13 var Debug = debug.Debug; |
15 | 14 |
16 var expected_events = 1; | 15 var expected_events = 1; |
17 var log = []; | 16 var log = []; |
18 | 17 |
19 function listener(event, exec_state, event_data, data) { | 18 function listener(event, exec_state, event_data, data) { |
20 if (event != Debug.DebugEvent.Exception) return; | 19 if (event != Debug.DebugEvent.Exception) return; |
21 try { | 20 try { |
22 expected_events--; | 21 expected_events--; |
23 assertTrue(expected_events >= 0); | 22 assertTrue(expected_events >= 0); |
24 assertEquals("uncaught", event_data.exception().message); | 23 assertEquals("uncaught", event_data.exception().message); |
25 assertTrue(event_data.promise() instanceof Promise); | |
26 // Assert that the debug event is triggered at the throw site. | 24 // Assert that the debug event is triggered at the throw site. |
27 assertTrue(exec_state.frame(0).sourceLineText().indexOf("// event") > 0); | 25 assertTrue(exec_state.frame(0).sourceLineText().indexOf("// event") > 0); |
28 assertEquals("p2", event_data.promise().name); | |
29 assertTrue(event_data.uncaught()); | 26 assertTrue(event_data.uncaught()); |
30 } catch (e) { | 27 } catch (e) { |
31 %AbortJS(e + "\n" + e.stack); | 28 %AbortJS(e + "\n" + e.stack); |
32 } | 29 } |
33 } | 30 } |
34 | 31 |
35 Debug.setBreakOnUncaughtException(); | 32 Debug.setBreakOnUncaughtException(); |
36 Debug.setListener(listener); | 33 Debug.setListener(listener); |
37 | 34 |
38 var p1 = Promise.resolve(); | 35 var p1 = Promise.resolve(); |
(...skipping 22 matching lines...) Expand all Loading... |
61 } | 58 } |
62 } catch (e) { | 59 } catch (e) { |
63 %AbortJS(e + "\n" + e.stack); | 60 %AbortJS(e + "\n" + e.stack); |
64 } | 61 } |
65 } | 62 } |
66 | 63 |
67 %EnqueueMicrotask(checkResult); | 64 %EnqueueMicrotask(checkResult); |
68 } | 65 } |
69 | 66 |
70 testDone(0); | 67 testDone(0); |
OLD | NEW |