OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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-async-await --expose-debug-as debug --allow-natives-syntax | 5 // Flags: --harmony-async-await --expose-debug-as debug --allow-natives-syntax |
6 | 6 |
7 // The test observes the callbacks that async/await makes to the inspector | 7 // The test observes the callbacks that async/await makes to the inspector |
8 // to make accurate stack traces. The pattern is based on saving a stack once | 8 // to make accurate stack traces. The pattern is based on saving a stack once |
9 // with enqueueRecurring and restoring it multiple times. | 9 // with enqueueRecurring and restoring it multiple times. |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... |
36 assertTrue(expected.length > 0); | 36 assertTrue(expected.length > 0); |
37 assertEquals(expected.shift(), msg); | 37 assertEquals(expected.shift(), msg); |
38 if (!expected.length) { | 38 if (!expected.length) { |
39 Debug.setListener(null); | 39 Debug.setListener(null); |
40 } | 40 } |
41 } | 41 } |
42 | 42 |
43 function listener(event, exec_state, event_data, data) { | 43 function listener(event, exec_state, event_data, data) { |
44 if (event != Debug.DebugEvent.AsyncTaskEvent) return; | 44 if (event != Debug.DebugEvent.AsyncTaskEvent) return; |
45 try { | 45 try { |
| 46 if ("Promise.resolve" == event_data.name()) return; |
46 if (base_id < 0) | 47 if (base_id < 0) |
47 base_id = event_data.id(); | 48 base_id = event_data.id(); |
48 var id = event_data.id() - base_id + 1; | 49 var id = event_data.id() - base_id + 1; |
49 assertTrue("async function" == event_data.name()); | 50 assertTrue("async function" == event_data.name()); |
50 assertLog(event_data.type() + " #" + id); | 51 assertLog(event_data.type() + " #" + id); |
51 } catch (e) { | 52 } catch (e) { |
52 print(e + e.stack) | 53 print(e + e.stack) |
53 exception = e; | 54 exception = e; |
54 } | 55 } |
55 } | 56 } |
(...skipping 10 matching lines...) Expand all Loading... |
66 assertLog("then #1"); | 67 assertLog("then #1"); |
67 await undefined; | 68 await undefined; |
68 assertLog("then #2"); | 69 assertLog("then #2"); |
69 } | 70 } |
70 main(); | 71 main(); |
71 resolver(); | 72 resolver(); |
72 | 73 |
73 %RunMicrotasks(); | 74 %RunMicrotasks(); |
74 | 75 |
75 assertNull(exception); | 76 assertNull(exception); |
| 77 |
| 78 Debug.clearBreakOnUncaughtException(); |
| 79 Debug.setListener(null); |
| 80 |
| 81 var resolve; |
| 82 var turnOnListenerPromise = new Promise(r => resolve = r); |
| 83 async function confused() { |
| 84 await turnOnListenerPromise; |
| 85 throw foo |
| 86 } |
| 87 |
| 88 confused(); |
| 89 |
| 90 Promise.resolve().then(() => { |
| 91 Debug.setListener(listener); |
| 92 Debug.setBreakOnUncaughtException(); |
| 93 resolve(); |
| 94 }); |
| 95 |
| 96 %RunMicrotasks(); |
| 97 assertNull(exception); |
OLD | NEW |