Chromium Code Reviews| 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()); |
| + } |
| +]); |