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 | 5 |
6 // Test debug events when we only listen to uncaught exceptions and | 6 // Test debug events when we only listen to uncaught exceptions and |
7 // there is a catch handler for the exception thrown in a Promise. | 7 // there is a catch handler for the exception thrown in a Promise. |
8 // We expect an Exception debug event with a promise to be triggered. | 8 // We expect an Exception debug event with a promise to be triggered. |
9 | 9 |
10 Debug = debug.Debug; | 10 Debug = debug.Debug; |
11 | 11 |
12 var expected_events = 1; | 12 var expected_events = 1; |
13 var log = []; | 13 var log = []; |
14 | 14 |
15 var p = new Promise(function(resolve, reject) { | 15 var p = new Promise(function(resolve, reject) { |
16 log.push("resolve"); | 16 log.push("resolve"); |
17 resolve(); | 17 resolve(); |
18 }); | 18 }); |
19 | 19 |
20 var q = p.then( | 20 var q = p.then( |
21 function() { | 21 function() { |
22 log.push("throw"); | 22 log.push("throw"); |
23 throw new Error("uncaught"); // event | 23 throw new Error("uncaught"); // event |
24 }); | 24 }); |
25 | 25 |
26 function listener(event, exec_state, event_data, data) { | 26 function listener(event, exec_state, event_data, data) { |
27 if (event == Debug.DebugEvent.AsyncTaskEvent) return; | |
28 try { | 27 try { |
29 if (event == Debug.DebugEvent.Exception) { | 28 if (event == Debug.DebugEvent.Exception) { |
30 expected_events--; | 29 expected_events--; |
31 assertTrue(expected_events >= 0); | 30 assertTrue(expected_events >= 0); |
32 assertEquals("uncaught", event_data.exception().message); | 31 assertEquals("uncaught", event_data.exception().message); |
33 assertTrue(event_data.uncaught()); | 32 assertTrue(event_data.uncaught()); |
34 // Assert that the debug event is triggered at the throw site. | 33 // Assert that the debug event is triggered at the throw site. |
35 assertTrue(exec_state.frame(0).sourceLineText().indexOf("// event") > 0); | 34 assertTrue(exec_state.frame(0).sourceLineText().indexOf("// event") > 0); |
36 } | 35 } |
37 } catch (e) { | 36 } catch (e) { |
(...skipping 17 matching lines...) Expand all Loading... |
55 } | 54 } |
56 } catch (e) { | 55 } catch (e) { |
57 %AbortJS(e + "\n" + e.stack); | 56 %AbortJS(e + "\n" + e.stack); |
58 } | 57 } |
59 } | 58 } |
60 | 59 |
61 %EnqueueMicrotask(checkResult); | 60 %EnqueueMicrotask(checkResult); |
62 } | 61 } |
63 | 62 |
64 testDone(0); | 63 testDone(0); |
OLD | NEW |