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

Side by Side Diff: test/inspector/runtime/coverage.js

Issue 2700743002: [inspector] extend protocol for code coverage. (Closed)
Patch Set: fix 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 unified diff | Download patch
« no previous file with comments | « test/cctest/test-debug.cc ('k') | test/inspector/runtime/coverage-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 2017 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 var source =
6 `
7 function fib(x) {
8 if (x < 2) return 1;
9 return fib(x-1) + fib(x-2);
10 }
11 (function iife() {
12 return 1;
13 })();
14 fib(5);
15 `;
16
17 print("Test collecting code coverage data with Runtime.collectCoverage.");
18
19 function ClearAndGC() {
20 return Protocol.Runtime.evaluate({ expression: "fib = null;" })
21 .then(() => Protocol.HeapProfiler.enable())
22 .then(() => Protocol.HeapProfiler.collectGarbage())
23 .then(() => Protocol.HeapProfiler.disable());
24 }
25
26 InspectorTest.runTestSuite([
27 function testPreciseCoverage(next)
28 {
29 Protocol.Runtime.enable()
30 .then(Protocol.Runtime.startPreciseCoverage)
31 .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL : "1", persistScript: true }))
32 .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scr iptId }))
33 .then(ClearAndGC)
34 .then(InspectorTest.logMessage)
35 .then(Protocol.Runtime.takePreciseCoverage)
36 .then(InspectorTest.logMessage)
37 .then(Protocol.Runtime.takePreciseCoverage)
38 .then(InspectorTest.logMessage)
39 .then(ClearAndGC)
40 .then(Protocol.Runtime.stopPreciseCoverage)
41 .then(Protocol.Runtime.disable)
42 .then(next);
43 },
44 function testPreciseCoverageFail(next)
45 {
46 Protocol.Runtime.enable()
47 .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL : "2", persistScript: true }))
48 .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scr iptId }))
49 .then(InspectorTest.logMessage)
50 .then(ClearAndGC)
51 .then(Protocol.Runtime.takePreciseCoverage)
52 .then(InspectorTest.logMessage)
53 .then(ClearAndGC)
54 .then(Protocol.Runtime.disable)
55 .then(next);
56 },
57 function testBestEffortCoverage(next)
58 {
59 Protocol.Runtime.enable()
60 .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL : "3", persistScript: true }))
61 .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scr iptId }))
62 .then(InspectorTest.logMessage)
63 .then(ClearAndGC)
64 .then(Protocol.Runtime.getBestEffortCoverage)
65 .then(InspectorTest.logMessage)
66 .then(Protocol.Runtime.getBestEffortCoverage)
67 .then(InspectorTest.logMessage)
68 .then(ClearAndGC)
69 .then(Protocol.Runtime.disable)
70 .then(next);
71 },
72 function testBestEffortCoveragePrecise(next)
73 {
74 Protocol.Runtime.enable()
75 .then(Protocol.Runtime.startPreciseCoverage)
76 .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL : "4", persistScript: true }))
77 .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scr iptId }))
78 .then(InspectorTest.logMessage)
79 .then(ClearAndGC)
80 .then(Protocol.Runtime.getBestEffortCoverage)
81 .then(InspectorTest.logMessage)
82 .then(Protocol.Runtime.getBestEffortCoverage)
83 .then(InspectorTest.logMessage)
84 .then(ClearAndGC)
85 .then(Protocol.Runtime.stopPreciseCoverage)
86 .then(Protocol.Runtime.disable)
87 .then(next);
88 },
89 ]);
OLDNEW
« no previous file with comments | « test/cctest/test-debug.cc ('k') | test/inspector/runtime/coverage-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698