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: --expose-debug-as debug --allow-natives-syntax | |
6 | 5 |
7 // Test debug events when we only listen to uncaught exceptions and | 6 // Test debug events when we only listen to uncaught exceptions and |
8 // there is only a default reject handler for the to-be-rejected Promise. | 7 // there is only a default reject handler for the to-be-rejected Promise. |
9 // We expect only one debug event: when the first Promise is rejected | 8 // We expect only one debug event: when the first Promise is rejected |
10 // and only has default reject handlers. No event is triggered when | 9 // and only has default reject handlers. No event is triggered when |
11 // simply forwarding the rejection with .then's default handler. | 10 // simply forwarding the rejection with .then's default handler. |
12 | 11 |
13 Debug = debug.Debug; | 12 Debug = debug.Debug; |
14 | 13 |
15 var expected_events = 1; | 14 var expected_events = 1; |
(...skipping 19 matching lines...) Expand all Loading... |
35 resolve(); | 34 resolve(); |
36 }) | 35 }) |
37 | 36 |
38 | 37 |
39 function listener(event, exec_state, event_data, data) { | 38 function listener(event, exec_state, event_data, data) { |
40 try { | 39 try { |
41 if (event == Debug.DebugEvent.Exception) { | 40 if (event == Debug.DebugEvent.Exception) { |
42 expected_events--; | 41 expected_events--; |
43 assertTrue(expected_events >= 0); | 42 assertTrue(expected_events >= 0); |
44 assertTrue(event_data.uncaught()); | 43 assertTrue(event_data.uncaught()); |
45 assertTrue(event_data.promise() instanceof Promise); | |
46 // p1 is rejected, uncaught except for its default reject handler. | 44 // p1 is rejected, uncaught except for its default reject handler. |
47 assertTrue( | 45 assertTrue( |
48 exec_state.frame(0).sourceLineText().indexOf("// event") > 0); | 46 exec_state.frame(0).sourceLineText().indexOf("// event") > 0); |
49 assertSame(p1, event_data.promise()); | |
50 } | 47 } |
51 } catch (e) { | 48 } catch (e) { |
52 %AbortJS(e + "\n" + e.stack); | 49 %AbortJS(e + "\n" + e.stack); |
53 } | 50 } |
54 } | 51 } |
55 | 52 |
56 Debug.setBreakOnUncaughtException(); | 53 Debug.setBreakOnUncaughtException(); |
57 Debug.setListener(listener); | 54 Debug.setListener(listener); |
58 | 55 |
59 log.push("end main"); | 56 log.push("end main"); |
60 | 57 |
61 function testDone(iteration) { | 58 function testDone(iteration) { |
62 function checkResult() { | 59 function checkResult() { |
63 try { | 60 try { |
64 assertTrue(iteration < 10); | 61 assertTrue(iteration < 10); |
65 if (expected_events === 0) { | 62 if (expected_events === 0) { |
66 assertEquals(["resolve q", "end main", "resolve p", "p0.then"], log); | 63 assertEquals(["resolve q", "end main", "resolve p", "p0.then"], log); |
67 } else { | 64 } else { |
68 testDone(iteration + 1); | 65 testDone(iteration + 1); |
69 } | 66 } |
70 } catch (e) { | 67 } catch (e) { |
71 %AbortJS(e + "\n" + e.stack); | 68 %AbortJS(e + "\n" + e.stack); |
72 } | 69 } |
73 } | 70 } |
74 | 71 |
75 %EnqueueMicrotask(checkResult); | 72 %EnqueueMicrotask(checkResult); |
76 } | 73 } |
77 | 74 |
78 testDone(0); | 75 testDone(0); |
OLD | NEW |