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

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

Issue 2648873002: [inspector] added creation frame for async call chains for promises (Closed)
Patch Set: add test for setTimeout Created 3 years, 11 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
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 print('Checks that async stacks works good with different limits'); 5 print('Checks that async stacks works good with different limits');
6 6
7 InspectorTest.addScript(` 7 InspectorTest.addScript(`
8 var resolveTest; 8 var resolveTest;
9 9
10 function foo1() { 10 function foo1() {
(...skipping 24 matching lines...) Expand all
35 resolve2(); 35 resolve2();
36 return Promise.all([p3, p4]); 36 return Promise.all([p3, p4]);
37 } 37 }
38 38
39 function twoSetTimeout() { 39 function twoSetTimeout() {
40 setTimeout(foo1, 0); 40 setTimeout(foo1, 0);
41 setTimeout(foo2, 0); 41 setTimeout(foo2, 0);
42 return new Promise(resolve => resolveTest = resolve); 42 return new Promise(resolve => resolveTest = resolve);
43 } 43 }
44 44
45 function threeSetTimeout() {
46 setTimeout(foo1, 0);
47 setTimeout(foo2, 0);
48 return new Promise(resolve => resolveTest = resolve);
49 }
50
51 function twentySetTimeout() { 45 function twentySetTimeout() {
52 var resolve1; 46 var resolve1;
53 var p1 = new Promise(resolve => resolve1 = resolve); 47 var p1 = new Promise(resolve => resolve1 = resolve);
54 for (var i = 1; i <= 19; ++i) 48 for (var i = 1; i <= 19; ++i)
55 setTimeout('(function foo' + i + '(){debugger;})()',0); 49 setTimeout('(function foo' + i + '(){debugger;})()',0);
56 setTimeout(resolve1, 0); 50 setTimeout(resolve1, 0);
57 return p1; 51 return p1;
58 } 52 }
59 53
60 //# sourceURL=test.js`, 7, 26); 54 //# sourceURL=test.js`, 7, 26);
(...skipping 17 matching lines...) Expand all
78 function testZeroLimit(next) { 72 function testZeroLimit(next) {
79 Protocol.Runtime.evaluate({ 73 Protocol.Runtime.evaluate({
80 expression: 'setMaxAsyncTaskStacks(0)//# sourceURL=expr.js'}) 74 expression: 'setMaxAsyncTaskStacks(0)//# sourceURL=expr.js'})
81 .then(() => Protocol.Runtime.evaluate({ 75 .then(() => Protocol.Runtime.evaluate({
82 expression: 'promise()//# sourceURL=expr.js', awaitPromise: true 76 expression: 'promise()//# sourceURL=expr.js', awaitPromise: true
83 })) 77 }))
84 .then(() => cancelAllAsyncTasks()) 78 .then(() => cancelAllAsyncTasks())
85 .then(next); 79 .then(next);
86 }, 80 },
87 81
88 function testOneLimit(next) { 82 function testTwoLimit(next) {
89 Protocol.Runtime.evaluate({ 83 // we need one stack for parent task and one for next task.
90 expression: 'setMaxAsyncTaskStacks(1)//# sourceURL=expr.js'}) 84 Protocol.Runtime
91 .then(() => Protocol.Runtime.evaluate({ 85 .evaluate({expression: 'setMaxAsyncTaskStacks(2)//# sourceURL=expr.js'})
92 expression: 'promise()//# sourceURL=expr.js', awaitPromise: true 86 .then(() => Protocol.Runtime.evaluate({
93 })) 87 expression: 'promise()//# sourceURL=expr.js',
94 .then(() => cancelAllAsyncTasks()) 88 awaitPromise: true
95 .then(next); 89 }))
90 .then(() => cancelAllAsyncTasks())
91 .then(next);
96 }, 92 },
97 93
98 function testOneLimitTwoPromises(next) { 94 function testOneLimitTwoPromises(next) {
99 // Should be no async stacks because when first microtask is finished 95 // Should be no async stacks because when first microtask is finished
100 // it will resolve and schedule p3 - will remove async stack for scheduled 96 // it will resolve and schedule p3 - will remove async stack for scheduled
101 // p2. 97 // p2.
102 Protocol.Runtime.evaluate({ 98 Protocol.Runtime.evaluate({
103 expression: 'setMaxAsyncTaskStacks(1)//# sourceURL=expr.js'}) 99 expression: 'setMaxAsyncTaskStacks(1)//# sourceURL=expr.js'})
104 .then(() => Protocol.Runtime.evaluate({ 100 .then(() => Protocol.Runtime.evaluate({
105 expression: 'twoPromises()//# sourceURL=expr.js', awaitPromise: true 101 expression: 'twoPromises()//# sourceURL=expr.js', awaitPromise: true
106 })) 102 }))
107 .then(() => cancelAllAsyncTasks()) 103 .then(() => cancelAllAsyncTasks())
108 .then(next); 104 .then(next);
109 }, 105 },
110 106
111 function testTwoLimitTwoPromises(next) { 107 function testFourLimitTwoPromises(next) {
108 Protocol.Runtime
109 .evaluate({expression: 'setMaxAsyncTaskStacks(4)//# sourceURL=expr.js'})
110 .then(() => Protocol.Runtime.evaluate({
111 expression: 'twoPromises()//# sourceURL=expr.js',
112 awaitPromise: true
113 }))
114 .then(() => cancelAllAsyncTasks())
115 .then(next);
116 },
117
118 function testSixLimitTwoPromises(next) {
119 Protocol.Runtime
120 .evaluate({expression: 'setMaxAsyncTaskStacks(6)//# sourceURL=expr.js'})
121 .then(() => Protocol.Runtime.evaluate({
122 expression: 'twoPromises()//# sourceURL=expr.js',
123 awaitPromise: true
124 }))
125 .then(() => cancelAllAsyncTasks())
126 .then(next);
127 },
128
129 function testTwoLimitTwoSetTimeouts(next) {
112 Protocol.Runtime.evaluate({ 130 Protocol.Runtime.evaluate({
113 expression: 'setMaxAsyncTaskStacks(2)//# sourceURL=expr.js'}) 131 expression: 'setMaxAsyncTaskStacks(2)//# sourceURL=expr.js'})
114 .then(() => Protocol.Runtime.evaluate({ 132 .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 133 expression: 'twoSetTimeout()//# sourceURL=expr.js', awaitPromise: true
126 })) 134 }))
127 .then(() => cancelAllAsyncTasks()) 135 .then(() => cancelAllAsyncTasks())
128 .then(next); 136 .then(next);
129 }, 137 },
130 138
131 function testTwoLimitTwoSetTimeouts(next) { 139 function testThreeLimitTwoSetTimeouts(next) {
132 Protocol.Runtime.evaluate({ 140 Protocol.Runtime.evaluate({
133 expression: 'setMaxAsyncTaskStacks(2)//# sourceURL=expr.js'}) 141 expression: 'setMaxAsyncTaskStacks(3)//# sourceURL=expr.js'})
134 .then(() => Protocol.Runtime.evaluate({ 142 .then(() => Protocol.Runtime.evaluate({
135 expression: 'twoSetTimeout()//# sourceURL=expr.js', awaitPromise: true 143 expression: 'twoSetTimeout()//# sourceURL=expr.js', awaitPromise: true
136 })) 144 }))
137 .then(() => cancelAllAsyncTasks()) 145 .then(() => cancelAllAsyncTasks())
138 .then(next); 146 .then(next);
139 }, 147 },
140 148
141 function testTenLimitTwentySetTimeouts(next) { 149 function testTenLimitTwentySetTimeouts(next) {
142 Protocol.Runtime.evaluate({ 150 Protocol.Runtime.evaluate({
143 expression: 'setMaxAsyncTaskStacks(10)//# sourceURL=expr.js'}) 151 expression: 'setMaxAsyncTaskStacks(10)//# sourceURL=expr.js'})
144 .then(() => Protocol.Runtime.evaluate({ 152 .then(() => Protocol.Runtime.evaluate({
145 expression: 'twentySetTimeout()//# sourceURL=expr.js', 153 expression: 'twentySetTimeout()//# sourceURL=expr.js',
146 awaitPromise: true 154 awaitPromise: true
147 })) 155 }))
148 .then(() => cancelAllAsyncTasks()) 156 .then(() => cancelAllAsyncTasks())
149 .then(next); 157 .then(next);
150 } 158 }
151 ]); 159 ]);
152 160
153 function cancelAllAsyncTasks() { 161 function cancelAllAsyncTasks() {
154 return Protocol.Debugger.setAsyncCallStackDepth({ maxDepth: 0 }) 162 return Protocol.Debugger.setAsyncCallStackDepth({ maxDepth: 0 })
155 .then(() => Protocol.Debugger.setAsyncCallStackDepth({ maxDepth: 128 })); 163 .then(() => Protocol.Debugger.setAsyncCallStackDepth({ maxDepth: 128 }));
156 } 164 }
OLDNEW
« no previous file with comments | « test/inspector/debugger/async-stack-for-promise-expected.txt ('k') | test/inspector/debugger/async-stacks-limit-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698