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

Unified Diff: test/inspector/debugger/set-async-call-stack-depth.js

Issue 2816043006: [inspector] avoid cloning of async call chains (Closed)
Patch Set: lines and columns in stack string should be 1-based 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 side-by-side diff with in-line comments
Download patch
Index: test/inspector/debugger/set-async-call-stack-depth.js
diff --git a/test/inspector/debugger/set-async-call-stack-depth.js b/test/inspector/debugger/set-async-call-stack-depth.js
new file mode 100644
index 0000000000000000000000000000000000000000..444c10591a32a4ed1f2c7e0f70c3f2fd3cdaf5f2
--- /dev/null
+++ b/test/inspector/debugger/set-async-call-stack-depth.js
@@ -0,0 +1,77 @@
+// Copyright 2017 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+InspectorTest.log('Checks that we report not more then maxDepth call chains.');
+
+InspectorTest.addScript(`
+function promisesChain(num) {
+ var p = Promise.resolve();
+ for (var i = 0; i < num - 1; ++i) {
+ p = p.then(() => 42);
+ }
+ return p;
+}
+`);
+
+Protocol.Debugger.enable();
+InspectorTest.runAsyncTestSuite([
+ async function testPaused() {
+ let callback = '() => { debugger; }';
+ startTest({ generated: 8, limit: 16, callback});
+ dumpCaptured((await Protocol.Debugger.oncePaused()).params.asyncStackTrace);
+ await Protocol.Debugger.resume();
+
+ startTest({ generated: 8, limit: 8, callback});
+ dumpCaptured((await Protocol.Debugger.oncePaused()).params.asyncStackTrace);
+ await Protocol.Debugger.resume();
+
+ startTest({ generated: 8, limit: 7, callback});
+ dumpCaptured((await Protocol.Debugger.oncePaused()).params.asyncStackTrace);
+ await Protocol.Debugger.resume();
+
+ startTest({ generated: 8, limit: 0, callback});
+ dumpCaptured((await Protocol.Debugger.oncePaused()).params.asyncStackTrace);
+ await Protocol.Debugger.resume();
+ },
+
+ async function testConsoleTrace() {
+ await Protocol.Runtime.enable();
+ let callback = '() => { console.trace(42); }';
+ startTest({ generated: 8, limit: 16, callback});
+ let msg = await Protocol.Runtime.onceConsoleAPICalled();
+ dumpCaptured(msg.params.stackTrace.parent);
+
+ startTest({ generated: 8, limit: 8, callback});
+ msg = await Protocol.Runtime.onceConsoleAPICalled();
+ dumpCaptured(msg.params.stackTrace.parent);
+
+ startTest({ generated: 8, limit: 7, callback});
+ msg = await Protocol.Runtime.onceConsoleAPICalled();
+ dumpCaptured(msg.params.stackTrace.parent);
+
+ startTest({ generated: 8, limit: 0, callback});
+ msg = await Protocol.Runtime.onceConsoleAPICalled();
+ dumpCaptured(msg.params.stackTrace.parent);
+
+ await Protocol.Runtime.disable();
+ }
+]);
+
+function startTest(params) {
+ InspectorTest.log('Actual call chain length: ' + params.generated);
+ InspectorTest.log('setAsyncCallStackDepth(maxDepth): ' + params.limit);
+
+ Protocol.Debugger.setAsyncCallStackDepth({maxDepth: params.limit});
+ Protocol.Runtime.evaluate({expression:
+ `promisesChain(${params.generated}).then(${params.callback})`});
+}
+
+function dumpCaptured(stack) {
+ let count = 0;
+ while (stack) {
+ ++count;
+ stack = stack.parent;
+ }
+ InspectorTest.log('reported: ' + count + '\n');
+}

Powered by Google App Engine
This is Rietveld 408576698