OLD | NEW |
| (Empty) |
1 // Copyright 2017 the V8 project authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 InspectorTest.log('Checks that we report not more then maxDepth call chains.'); | |
6 | |
7 InspectorTest.addScript(` | |
8 function promisesChain(num) { | |
9 var p = Promise.resolve(); | |
10 for (var i = 0; i < num - 1; ++i) { | |
11 p = p.then(() => 42); | |
12 } | |
13 return p; | |
14 } | |
15 `); | |
16 | |
17 Protocol.Debugger.enable(); | |
18 InspectorTest.runAsyncTestSuite([ | |
19 async function testPaused() { | |
20 let callback = '() => { debugger; }'; | |
21 startTest({ generated: 8, limit: 16, callback}); | |
22 dumpCaptured((await Protocol.Debugger.oncePaused()).params.asyncStackTrace); | |
23 await Protocol.Debugger.resume(); | |
24 | |
25 startTest({ generated: 8, limit: 8, callback}); | |
26 dumpCaptured((await Protocol.Debugger.oncePaused()).params.asyncStackTrace); | |
27 await Protocol.Debugger.resume(); | |
28 | |
29 startTest({ generated: 8, limit: 7, callback}); | |
30 dumpCaptured((await Protocol.Debugger.oncePaused()).params.asyncStackTrace); | |
31 await Protocol.Debugger.resume(); | |
32 | |
33 startTest({ generated: 8, limit: 0, callback}); | |
34 dumpCaptured((await Protocol.Debugger.oncePaused()).params.asyncStackTrace); | |
35 await Protocol.Debugger.resume(); | |
36 }, | |
37 | |
38 async function testConsoleTrace() { | |
39 await Protocol.Runtime.enable(); | |
40 let callback = '() => { console.trace(42); }'; | |
41 startTest({ generated: 8, limit: 16, callback}); | |
42 let msg = await Protocol.Runtime.onceConsoleAPICalled(); | |
43 dumpCaptured(msg.params.stackTrace.parent); | |
44 | |
45 startTest({ generated: 8, limit: 8, callback}); | |
46 msg = await Protocol.Runtime.onceConsoleAPICalled(); | |
47 dumpCaptured(msg.params.stackTrace.parent); | |
48 | |
49 startTest({ generated: 8, limit: 7, callback}); | |
50 msg = await Protocol.Runtime.onceConsoleAPICalled(); | |
51 dumpCaptured(msg.params.stackTrace.parent); | |
52 | |
53 startTest({ generated: 8, limit: 0, callback}); | |
54 msg = await Protocol.Runtime.onceConsoleAPICalled(); | |
55 dumpCaptured(msg.params.stackTrace.parent); | |
56 | |
57 await Protocol.Runtime.disable(); | |
58 } | |
59 ]); | |
60 | |
61 function startTest(params) { | |
62 InspectorTest.log('Actual call chain length: ' + params.generated); | |
63 InspectorTest.log('setAsyncCallStackDepth(maxDepth): ' + params.limit); | |
64 | |
65 Protocol.Debugger.setAsyncCallStackDepth({maxDepth: params.limit}); | |
66 Protocol.Runtime.evaluate({expression: | |
67 `promisesChain(${params.generated}).then(${params.callback})`}); | |
68 } | |
69 | |
70 function dumpCaptured(stack) { | |
71 let count = 0; | |
72 while (stack) { | |
73 ++count; | |
74 stack = stack.parent; | |
75 } | |
76 InspectorTest.log('reported: ' + count + '\n'); | |
77 } | |
OLD | NEW |