Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: test/inspector/debugger/max-async-call-chain-depth.js

Issue 2807273002: [inspector] store creation stack in current V8StackTraceImpl (Closed)
Patch Set: finally passed tests Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 trim async call chains correctly.');
6
7 Protocol.Debugger.enable();
8 InspectorTest.log('set async chain depth to 8');
9 Protocol.Debugger.setAsyncCallStackDepth({maxDepth: 8});
10 InspectorTest.runAsyncTestSuite([
11 async function testDebuggerPaused() {
12 runWithAsyncChain(4, 'debugger;');
13 dumpAsyncChainLength(await Protocol.Debugger.oncePaused());
14 await Protocol.Debugger.resume();
15
16 runWithAsyncChain(8, 'debugger;');
17 dumpAsyncChainLength(await Protocol.Debugger.oncePaused());
18 await Protocol.Debugger.resume();
19
20 runWithAsyncChain(9, 'debugger;');
21 dumpAsyncChainLength(await Protocol.Debugger.oncePaused());
22 await Protocol.Debugger.resume();
23
24 runWithAsyncChain(32, 'debugger;');
25 dumpAsyncChainLength(await Protocol.Debugger.oncePaused());
26 await Protocol.Debugger.resume();
27 },
28
29 async function testConsoleTrace() {
30 Protocol.Runtime.enable();
31 runWithAsyncChain(4, 'console.trace(42);');
32 dumpAsyncChainLength(await Protocol.Runtime.onceConsoleAPICalled());
33
34 runWithAsyncChain(8, 'console.trace(42);');
35 dumpAsyncChainLength(await Protocol.Runtime.onceConsoleAPICalled());
36
37 runWithAsyncChain(9, 'console.trace(42);');
38 dumpAsyncChainLength(await Protocol.Runtime.onceConsoleAPICalled());
39
40 runWithAsyncChain(32, 'console.trace(42);');
41 dumpAsyncChainLength(await Protocol.Runtime.onceConsoleAPICalled());
42 },
43
44 async function testDebuggerPausedSetTimeout() {
45 runWithAsyncChainSetTimeout(4, 'debugger;');
46 dumpAsyncChainLength(await Protocol.Debugger.oncePaused());
47 await Protocol.Debugger.resume();
48
49 runWithAsyncChainSetTimeout(8, 'debugger;');
50 dumpAsyncChainLength(await Protocol.Debugger.oncePaused());
51 await Protocol.Debugger.resume();
52
53 runWithAsyncChainSetTimeout(9, 'debugger;');
54 dumpAsyncChainLength(await Protocol.Debugger.oncePaused());
55 await Protocol.Debugger.resume();
56
57 runWithAsyncChainSetTimeout(32, 'debugger;');
58 dumpAsyncChainLength(await Protocol.Debugger.oncePaused());
59 await Protocol.Debugger.resume();
60 },
61
62 async function testConsoleTraceSetTimeout() {
63 runWithAsyncChainSetTimeout(4, 'console.trace(42);');
64 dumpAsyncChainLength(await Protocol.Runtime.onceConsoleAPICalled());
65
66 runWithAsyncChainSetTimeout(8, 'console.trace(42);');
67 dumpAsyncChainLength(await Protocol.Runtime.onceConsoleAPICalled());
68
69 runWithAsyncChainSetTimeout(9, 'console.trace(42);');
70 dumpAsyncChainLength(await Protocol.Runtime.onceConsoleAPICalled());
71
72 runWithAsyncChainSetTimeout(32, 'console.trace(42);');
73 dumpAsyncChainLength(await Protocol.Runtime.onceConsoleAPICalled());
74 },
75
76 async function testConsoleTraceWithEmptySync() {
77 Protocol.Runtime.evaluate({
78 expression: 'new Promise(resolve => setTimeout(resolve, 0)).then(() => con sole.trace(42))'
79 });
80 InspectorTest.logMessage((await Protocol.Runtime.onceConsoleAPICalled()).par ams.stackTrace);
81 },
82
83 async function testDebuggerPausedThenableJob() {
84 runWithThenableJob(4, 'debugger;');
85 dumpAsyncChainLength(await Protocol.Debugger.oncePaused());
86 await Protocol.Debugger.resume();
87
88 runWithThenableJob(8, 'debugger;');
89 dumpAsyncChainLength(await Protocol.Debugger.oncePaused());
90 await Protocol.Debugger.resume();
91
92 runWithThenableJob(9, 'debugger;');
93 dumpAsyncChainLength(await Protocol.Debugger.oncePaused());
94 await Protocol.Debugger.resume();
95
96 runWithThenableJob(32, 'debugger;');
97 dumpAsyncChainLength(await Protocol.Debugger.oncePaused());
98 await Protocol.Debugger.resume();
99 },
100
101 async function testConsoleTraceThenableJob() {
102 runWithThenableJob(4, 'console.trace(42);');
103 dumpAsyncChainLength(await Protocol.Runtime.onceConsoleAPICalled());
104
105 runWithThenableJob(8, 'console.trace(42);');
106 dumpAsyncChainLength(await Protocol.Runtime.onceConsoleAPICalled());
107
108 runWithThenableJob(9, 'console.trace(42);');
109 dumpAsyncChainLength(await Protocol.Runtime.onceConsoleAPICalled());
110
111 runWithThenableJob(32, 'console.trace(42);');
112 dumpAsyncChainLength(await Protocol.Runtime.onceConsoleAPICalled());
113 },
114
115 async function twoConsoleAssert() {
116 Protocol.Runtime.evaluate({
117 expression: 'setTimeout(' +
118 'setTimeout.bind(null, ' +
119 'setTimeout.bind(null, () => { console.assert(); setTimeout(console.as sert, 0) }, 0), 0), 0)'
120 });
121 dumpAsyncChainLength(await Protocol.Runtime.onceConsoleAPICalled());
122 dumpAsyncChainLength(await Protocol.Runtime.onceConsoleAPICalled());
123 }
124 ]);
125
126 function runWithAsyncChain(len, source) {
127 InspectorTest.log(`Run expression '${source}' with async chain len: ${len}`);
128 let then = '.then(() => 1)';
129 let pause = `.then(() => { ${source} })`;
130 Protocol.Runtime.evaluate({
131 expression: `Promise.resolve()${then.repeat(len - 1)}${pause}`
132 });
133 }
134
135 function runWithAsyncChainSetTimeout(len, source) {
136 InspectorTest.log(`Run expression '${source}' with async chain len: ${len}`);
137 let setTimeout = 'setTimeout(() => {';
138 let suffix = '}, 0)';
139 Protocol.Runtime.evaluate({
140 expression: `${setTimeout.repeat(len)}${source}${suffix.repeat(len)}`
141 });
142 }
143
144 function runWithThenableJob(len, source) {
145 InspectorTest.log(`Run expression '${source}' with async chain len: ${len}`);
146 let then = '.then(Promise.resolve.bind(Promise, 0))';
147 let pause = `.then(() => { ${source} })`;
148 Protocol.Runtime.evaluate({
149 expression: `Promise.resolve()${then.repeat(len - 1)}${pause}`
150 });
151 }
152
153 function dumpAsyncChainLength(message) {
154 let stackTrace = message.params.asyncStackTrace || message.params.stackTrace.p arent;
155 let asyncChainCount = 0;
156 while (stackTrace) {
157 ++asyncChainCount;
158 stackTrace = stackTrace.parent;
159 }
160 InspectorTest.log(`actual async chain len: ${asyncChainCount}`);
161 }
OLDNEW
« no previous file with comments | « src/inspector/v8-stack-trace-impl.cc ('k') | test/inspector/debugger/max-async-call-chain-depth-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698