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

Side by Side Diff: test/inspector/debugger/async-stacks-limit.js

Issue 2579403002: [inspector] introduce limit for amount of stored async stacks (Closed)
Patch Set: addressed comments Created 4 years 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
« no previous file with comments | « test/inspector/DEPS ('k') | test/inspector/debugger/async-stacks-limit-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 print('Checks that async stacks works good with different limits');
6
7 InspectorTest.addScript(`
8 var resolveTest;
9
10 function foo1() {
11 debugger;
12 }
13
14 function foo2() {
15 debugger;
16 if (resolveTest) resolveTest();
17 }
18
19 function promise() {
20 var resolve1;
21 var p1 = new Promise(resolve => resolve1 = resolve);
22 var p2 = p1.then(foo1);
23 resolve1();
24 return p2;
25 }
26
27 function twoPromises() {
28 var resolve1;
29 var resolve2;
30 var p1 = new Promise(resolve => resolve1 = resolve);
31 var p2 = new Promise(resolve => resolve2 = resolve);
32 var p3 = p1.then(foo1);
33 var p4 = p2.then(foo2);
34 resolve1();
35 resolve2();
36 return Promise.all([p3, p4]);
37 }
38
39 function twoSetTimeout() {
40 setTimeout(foo1, 0);
41 setTimeout(foo2, 0);
42 return new Promise(resolve => resolveTest = resolve);
43 }
44
45 function threeSetTimeout() {
46 setTimeout(foo1, 0);
47 setTimeout(foo2, 0);
48 return new Promise(resolve => resolveTest = resolve);
49 }
50
51 function twentySetTimeout() {
52 var resolve1;
53 var p1 = new Promise(resolve => resolve1 = resolve);
54 for (var i = 1; i <= 19; ++i)
55 setTimeout('(function foo' + i + '(){debugger;})()',0);
56 setTimeout(resolve1, 0);
57 return p1;
58 }
59
60 //# sourceURL=test.js`, 7, 26);
61
62 InspectorTest.setupScriptMap();
63 Protocol.Debugger.onPaused(message => {
64 InspectorTest.logCallFrames(message.params.callFrames);
65 var asyncStackTrace = message.params.asyncStackTrace;
66 while (asyncStackTrace) {
67 InspectorTest.log(`-- ${asyncStackTrace.description} --`);
68 InspectorTest.logCallFrames(asyncStackTrace.callFrames);
69 asyncStackTrace = asyncStackTrace.parent;
70 }
71 InspectorTest.log('');
72 Protocol.Debugger.resume();
73 });
74
75 Protocol.Debugger.enable();
76 Protocol.Debugger.setAsyncCallStackDepth({ maxDepth: 128 });
77 InspectorTest.runTestSuite([
78 function testZeroLimit(next) {
79 Protocol.Runtime.evaluate({
80 expression: 'setMaxAsyncTaskStacks(0)//# sourceURL=expr.js'})
81 .then(() => Protocol.Runtime.evaluate({
82 expression: 'promise()//# sourceURL=expr.js', awaitPromise: true
83 }))
84 .then(() => cancelAllAsyncTasks())
85 .then(next);
86 },
87
88 function testOneLimit(next) {
89 Protocol.Runtime.evaluate({
90 expression: 'setMaxAsyncTaskStacks(1)//# sourceURL=expr.js'})
91 .then(() => Protocol.Runtime.evaluate({
92 expression: 'promise()//# sourceURL=expr.js', awaitPromise: true
93 }))
94 .then(() => cancelAllAsyncTasks())
95 .then(next);
96 },
97
98 function testOneLimitTwoPromises(next) {
99 // Should be no async stacks because when first microtask is finished
100 // it will resolve and schedule p3 - will remove async stack for scheduled
101 // p2.
102 Protocol.Runtime.evaluate({
103 expression: 'setMaxAsyncTaskStacks(1)//# sourceURL=expr.js'})
104 .then(() => Protocol.Runtime.evaluate({
105 expression: 'twoPromises()//# sourceURL=expr.js', awaitPromise: true
106 }))
107 .then(() => cancelAllAsyncTasks())
108 .then(next);
109 },
110
111 function testTwoLimitTwoPromises(next) {
112 Protocol.Runtime.evaluate({
113 expression: 'setMaxAsyncTaskStacks(2)//# sourceURL=expr.js'})
114 .then(() => Protocol.Runtime.evaluate({
115 expression: 'twoPromises()//# sourceURL=expr.js', awaitPromise: true
116 }))
117 .then(() => cancelAllAsyncTasks())
118 .then(next);
119 },
120
121 function testOneLimitTwoSetTimeouts(next) {
122 Protocol.Runtime.evaluate({
123 expression: 'setMaxAsyncTaskStacks(1)//# sourceURL=expr.js'})
124 .then(() => Protocol.Runtime.evaluate({
125 expression: 'twoSetTimeout()//# sourceURL=expr.js', awaitPromise: true
126 }))
127 .then(() => cancelAllAsyncTasks())
128 .then(next);
129 },
130
131 function testTwoLimitTwoSetTimeouts(next) {
132 Protocol.Runtime.evaluate({
133 expression: 'setMaxAsyncTaskStacks(2)//# sourceURL=expr.js'})
134 .then(() => Protocol.Runtime.evaluate({
135 expression: 'twoSetTimeout()//# sourceURL=expr.js', awaitPromise: true
136 }))
137 .then(() => cancelAllAsyncTasks())
138 .then(next);
139 },
140
141 function testTenLimitTwentySetTimeouts(next) {
142 Protocol.Runtime.evaluate({
143 expression: 'setMaxAsyncTaskStacks(10)//# sourceURL=expr.js'})
144 .then(() => Protocol.Runtime.evaluate({
145 expression: 'twentySetTimeout()//# sourceURL=expr.js',
146 awaitPromise: true
147 }))
148 .then(() => cancelAllAsyncTasks())
149 .then(next);
150 }
151 ]);
152
153 function cancelAllAsyncTasks() {
154 return Protocol.Debugger.setAsyncCallStackDepth({ maxDepth: 0 })
155 .then(() => Protocol.Debugger.setAsyncCallStackDepth({ maxDepth: 128 }));
156 }
OLDNEW
« no previous file with comments | « test/inspector/DEPS ('k') | test/inspector/debugger/async-stacks-limit-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698