Chromium Code Reviews| OLD | NEW |
|---|---|
| (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((result) => InspectorTest.logMessage(result)) | |
|
kozy
2017/02/21 17:57:29
.then(InspectorTest.logMessage)
| |
| 35 .then(() => Protocol.Runtime.takePreciseCoverage()) | |
| 36 .then((result) => InspectorTest.logMessage(result)) | |
| 37 .then(ClearAndGC) | |
| 38 .then(() => Protocol.Runtime.stopPreciseCoverage()) | |
| 39 .then(() => Protocol.Runtime.disable()) | |
| 40 .then(() => next()); | |
| 41 }, | |
| 42 function testPreciseCoverageFail(next) | |
| 43 { | |
| 44 Protocol.Runtime.enable() | |
| 45 .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL : "2", persistScript: true })) | |
| 46 .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scr iptId })) | |
| 47 .then((result) => InspectorTest.logMessage(result)) | |
| 48 .then(ClearAndGC) | |
| 49 .then(() => Protocol.Runtime.takePreciseCoverage()) | |
| 50 .then((result) => InspectorTest.logMessage(result)) | |
| 51 .then(ClearAndGC) | |
| 52 .then(() => Protocol.Runtime.disable()) | |
| 53 .then(() => next()); | |
|
kozy
2017/02/21 17:57:30
.then(next)
| |
| 54 }, | |
| 55 function testBestEffortCoverage(next) | |
| 56 { | |
| 57 Protocol.Runtime.enable() | |
| 58 .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL : "3", persistScript: true })) | |
| 59 .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scr iptId })) | |
| 60 .then((result) => InspectorTest.logMessage(result)) | |
| 61 .then(ClearAndGC) | |
| 62 .then(() => Protocol.Runtime.takeBestEffortCoverage()) | |
| 63 .then((result) => InspectorTest.logMessage(result)) | |
| 64 .then(ClearAndGC) | |
| 65 .then(() => Protocol.Runtime.disable()) | |
| 66 .then(() => next()); | |
| 67 }, | |
| 68 function testBestEffortCoveragePrecise(next) | |
| 69 { | |
| 70 Protocol.Runtime.enable() | |
| 71 .then(() => Protocol.Runtime.startPreciseCoverage()) | |
| 72 .then(() => Protocol.Runtime.compileScript({ expression: source, sourceURL : "4", persistScript: true })) | |
| 73 .then((result) => Protocol.Runtime.runScript({ scriptId: result.result.scr iptId })) | |
| 74 .then((result) => InspectorTest.logMessage(result)) | |
| 75 .then(ClearAndGC) | |
| 76 .then(() => Protocol.Runtime.takeBestEffortCoverage()) | |
| 77 .then((result) => InspectorTest.logMessage(result)) | |
| 78 .then(ClearAndGC) | |
| 79 .then(() => Protocol.Runtime.stopPreciseCoverage()) | |
| 80 .then(() => Protocol.Runtime.disable()) | |
| 81 .then(() => next()); | |
| 82 }, | |
| 83 ]); | |
| OLD | NEW |