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

Unified Diff: test/inspector/runtime/coverage.js

Issue 2700743002: [inspector] extend protocol for code coverage. (Closed)
Patch Set: comments Created 3 years, 10 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/runtime/coverage.js
diff --git a/test/inspector/runtime/coverage.js b/test/inspector/runtime/coverage.js
new file mode 100644
index 0000000000000000000000000000000000000000..5f9200de7ea66d66a42193c2dd5c4d03fa439fe3
--- /dev/null
+++ b/test/inspector/runtime/coverage.js
@@ -0,0 +1,32 @@
+// 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.
+
+var source =
+`
+function fib(x) {
+ if (x < 2) return 1;
+ return fib(x-1) + fib(x-2);
+}
+fib(5);
+`;
+
+var url = "fib.js"
+
+print("Test collecting code coverage data with Runtime.collectCoverage.");
+
+InspectorTest.runTestSuite([
+ function testCoverage(next)
+ {
+ Protocol.Runtime.enable()
+ .then(() => Protocol.Runtime.startPreciseCoverage())
+ .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL: url, persistScript: true }))
kozy 2017/02/16 16:47:19 You can just add //# sourceURL=fib.js to your sour
Yang 2017/02/20 11:24:42 I also like to pass the URL though.
+ .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scriptId }))
+ .then((result) => InspectorTest.logMessage(result))
+ .then(() => Protocol.Runtime.collectCoverage())
+ .then((result) => InspectorTest.logMessage(result))
+ .then(() => Protocol.Runtime.stopPreciseCoverage())
+ .then(() => Protocol.Runtime.disable())
+ .then(() => next());
+ }
+]);

Powered by Google App Engine
This is Rietveld 408576698