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

Unified Diff: test/inspector/cpu-profiler/coverage.js

Issue 2764073004: [debug] do not report unnecessary coverage data. (Closed)
Patch Set: Created 3 years, 9 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/cpu-profiler/coverage.js
diff --git a/test/inspector/cpu-profiler/coverage.js b/test/inspector/cpu-profiler/coverage.js
index b50180e69af125f4572efc663f8e196b4c925dec..c1b8a95c1b57ccaae165cfc2f18297bf431f99f1 100644
--- a/test/inspector/cpu-profiler/coverage.js
+++ b/test/inspector/cpu-profiler/coverage.js
@@ -34,6 +34,22 @@ function h() {
f(3);
`;
+var nested =
+`
+var f = (function outer() {
+ function nested_0() {
+ return function nested_1() {
+ return function nested_2() {
+ return function nested_3() {}
+ }
+ }
+ }
+ function nested_4() {}
+ return nested_0();
+})();
+f()()();
+`;
+
InspectorTest.log("Test collecting code coverage data with Profiler.collectCoverage.");
function ClearAndGC() {
@@ -78,8 +94,8 @@ InspectorTest.runTestSuite([
.then(Protocol.Profiler.startPreciseCoverage)
.then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL: "1", persistScript: true }))
.then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scriptId }))
- .then(ClearAndGC)
.then(InspectorTest.logMessage)
+ .then(ClearAndGC)
.then(Protocol.Profiler.takePreciseCoverage)
.then(LogSorted)
.then(Protocol.Profiler.takePreciseCoverage)
@@ -188,4 +204,44 @@ InspectorTest.runTestSuite([
.then(ClearAndGC)
.then(next);
},
+ function testPreciseEmptyScriptCoverageEntries(next)
+ {
+ // Enabling the debugger holds onto script objects even though its
+ // functions can be garbage collected. We would get empty ScriptCoverage
+ // entires unless we remove them.
+ Protocol.Debugger.enable()
+ .then(Protocol.Runtime.enable)
+ .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL: "7", persistScript: true }))
+ .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scriptId }))
+ .then(ClearAndGC)
+ .then(Protocol.Profiler.enable)
+ .then(() => Protocol.Profiler.startPreciseCoverage({binary: true}))
+ .then(Protocol.Profiler.takePreciseCoverage)
+ .then(LogSorted)
+ .then(Protocol.Profiler.stopPreciseCoverage)
+ .then(Protocol.Profiler.disable)
+ .then(Protocol.Runtime.disable)
+ .then(Protocol.Debugger.disable)
+ .then(ClearAndGC)
+ .then(next);
+ },
+ function testPreciseCoveragePartial(next)
+ {
+ Protocol.Runtime.enable()
+ .then(Protocol.Profiler.enable)
+ .then(Protocol.Profiler.startPreciseCoverage)
+ .then(() => Protocol.Runtime.compileScript({ expression: nested, sourceURL: "1", persistScript: true }))
+ .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scriptId }))
+ .then(InspectorTest.logMessage)
+ .then(Protocol.Profiler.takePreciseCoverage)
+ .then(LogSorted)
+ .then(() => Protocol.Runtime.evaluate({ expression: "f()" }))
+ .then(Protocol.Profiler.takePreciseCoverage)
+ .then(LogSorted)
+ .then(Protocol.Profiler.stopPreciseCoverage)
+ .then(Protocol.Profiler.disable)
+ .then(Protocol.Runtime.disable)
+ .then(ClearAndGC)
+ .then(next);
+ },
]);

Powered by Google App Engine
This is Rietveld 408576698