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 InspectorTest.log('Checks that async stack contains setTimeout'); | 5 let {session, contextGroup, Protocol} = InspectorTest.start('Checks that async s
tack contains setTimeout'); |
6 | 6 |
7 InspectorTest.addScript(` | 7 contextGroup.addScript(` |
8 var resolveCallback; | 8 var resolveCallback; |
9 function foo1() { | 9 function foo1() { |
10 function inner1() { | 10 function inner1() { |
11 debugger; | 11 debugger; |
12 resolveCallback(); | 12 resolveCallback(); |
13 } | 13 } |
14 inner1(); | 14 inner1(); |
15 } | 15 } |
16 function foo2() { | 16 function foo2() { |
17 function inner2() { | 17 function inner2() { |
18 setTimeout(foo1, 0); | 18 setTimeout(foo1, 0); |
19 } | 19 } |
20 inner2(); | 20 inner2(); |
21 } | 21 } |
22 function foo3() { | 22 function foo3() { |
23 var promise = new Promise(resolve => resolveCallback = resolve); | 23 var promise = new Promise(resolve => resolveCallback = resolve); |
24 function inner3() { | 24 function inner3() { |
25 setTimeout(foo2, 0); | 25 setTimeout(foo2, 0); |
26 } | 26 } |
27 inner3(); | 27 inner3(); |
28 return promise; | 28 return promise; |
29 } | 29 } |
30 //# sourceURL=test.js`, 7, 26); | 30 //# sourceURL=test.js`, 7, 26); |
31 | 31 |
32 InspectorTest.setupScriptMap(); | 32 session.setupScriptMap(); |
33 Protocol.Debugger.onPaused(message => { | 33 Protocol.Debugger.onPaused(message => { |
34 InspectorTest.logCallFrames(message.params.callFrames); | 34 session.logCallFrames(message.params.callFrames); |
35 var asyncStackTrace = message.params.asyncStackTrace; | 35 var asyncStackTrace = message.params.asyncStackTrace; |
36 while (asyncStackTrace) { | 36 while (asyncStackTrace) { |
37 InspectorTest.log(`-- ${asyncStackTrace.description} --`); | 37 InspectorTest.log(`-- ${asyncStackTrace.description} --`); |
38 InspectorTest.logCallFrames(asyncStackTrace.callFrames); | 38 session.logCallFrames(asyncStackTrace.callFrames); |
39 asyncStackTrace = asyncStackTrace.parent; | 39 asyncStackTrace = asyncStackTrace.parent; |
40 } | 40 } |
41 InspectorTest.log(''); | 41 InspectorTest.log(''); |
42 Protocol.Debugger.resume(); | 42 Protocol.Debugger.resume(); |
43 }); | 43 }); |
44 | 44 |
45 Protocol.Debugger.enable(); | 45 Protocol.Debugger.enable(); |
46 Protocol.Debugger.setAsyncCallStackDepth({ maxDepth: 128 }); | 46 Protocol.Debugger.setAsyncCallStackDepth({ maxDepth: 128 }); |
47 Protocol.Runtime.evaluate({ expression: "foo3()//# sourceURL=expr.js", awaitProm
ise: true }) | 47 Protocol.Runtime.evaluate({ expression: "foo3()//# sourceURL=expr.js", awaitProm
ise: true }) |
48 .then(InspectorTest.completeTest); | 48 .then(InspectorTest.completeTest); |
OLD | NEW |