| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script src="../../http/tests/inspector/inspector-test.js"></script> | 3 <script src="../../http/tests/inspector/inspector-test.js"></script> |
| 4 <script src="heap-snapshot-test.js"></script> | 4 <script src="heap-snapshot-test.js"></script> |
| 5 <script> | 5 <script> |
| 6 | 6 |
| 7 function test() | 7 function test() |
| 8 { | 8 { |
| 9 var source = InspectorTest.createHeapSnapshotMockRaw(); | 9 var source = InspectorTest.createHeapSnapshotMockRaw(); |
| 10 var sourceStringified = JSON.stringify(source); | 10 var sourceStringified = JSON.stringify(source); |
| 11 var partSize = sourceStringified.length >> 3; | 11 var partSize = sourceStringified.length >> 3; |
| 12 | 12 |
| 13 function injectMockProfile(callback) { | 13 function injectMockProfile(callback) { |
| 14 var dispatcher = InspectorTest.mainTarget._dispatchers["HeapProfiler"]._
dispatchers[0]; | 14 var dispatcher = InspectorTest.mainTarget._dispatchers["HeapProfiler"]._
dispatchers[0]; |
| 15 var panel = UI.panels.heap_profiler; | 15 var panel = UI.panels.heap_profiler; |
| 16 panel._reset(); | 16 panel._reset(); |
| 17 | 17 |
| 18 var profileType = Profiler.ProfileTypeRegistry.instance.heapSnapshotPro
fileType; | 18 var profileType = Profiler.ProfileTypeRegistry.instance.heapSnapshotPro
fileType; |
| 19 | 19 |
| 20 InspectorTest.override(InspectorTest.HeapProfilerAgent, "takeHeapSnapsho
t", takeHeapSnapshotMock); | 20 InspectorTest.override(InspectorTest.HeapProfilerAgent, "takeHeapSnapsho
t", takeHeapSnapshotMock); |
| 21 function takeHeapSnapshotMock(reportProgress, callback) { | 21 function takeHeapSnapshotMock(reportProgress) { |
| 22 if (reportProgress) { | 22 if (reportProgress) { |
| 23 profileType._reportHeapSnapshotProgress({data: {done: 50, total:
100, finished: false}}); | 23 profileType._reportHeapSnapshotProgress({data: {done: 50, total:
100, finished: false}}); |
| 24 profileType._reportHeapSnapshotProgress({data: {done: 100, total
: 100, finished: true}}); | 24 profileType._reportHeapSnapshotProgress({data: {done: 100, total
: 100, finished: true}}); |
| 25 } | 25 } |
| 26 for (var i = 0, l = sourceStringified.length; i < l; i += partSize) | 26 for (var i = 0, l = sourceStringified.length; i < l; i += partSize) |
| 27 dispatcher.addHeapSnapshotChunk(sourceStringified.slice(i, i + p
artSize)); | 27 dispatcher.addHeapSnapshotChunk(sourceStringified.slice(i, i + p
artSize)); |
| 28 return Promise.resolve(callback(null)); | 28 return Promise.resolve(); |
| 29 } | 29 } |
| 30 | 30 |
| 31 function tempFileReady() | 31 function tempFileReady() |
| 32 { | 32 { |
| 33 callback(this); | 33 callback(this); |
| 34 } | 34 } |
| 35 InspectorTest.addSniffer(Profiler.HeapProfileHeader.prototype, "_didWrit
eToTempFile", tempFileReady); | 35 InspectorTest.addSniffer(Profiler.HeapProfileHeader.prototype, "_didWrit
eToTempFile", tempFileReady); |
| 36 profileType._takeHeapSnapshot(function() {}); | 36 profileType._takeHeapSnapshot(); |
| 37 } | 37 } |
| 38 | 38 |
| 39 Common.console.log = function(message) { | 39 Common.console.log = function(message) { |
| 40 InspectorTest.addResult("InspectorTest.consoleModel.log: " + message); | 40 InspectorTest.addResult("InspectorTest.consoleModel.log: " + message); |
| 41 } | 41 } |
| 42 | 42 |
| 43 InspectorTest.runTestSuite([ | 43 InspectorTest.runTestSuite([ |
| 44 function heapSnapshotSaveToFileTest(next) | 44 function heapSnapshotSaveToFileTest(next) |
| 45 { | 45 { |
| 46 function snapshotLoaded(profileHeader) | 46 function snapshotLoaded(profileHeader) |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 </script> | 134 </script> |
| 135 </head> | 135 </head> |
| 136 | 136 |
| 137 <body onload="runTest()"> | 137 <body onload="runTest()"> |
| 138 <p> | 138 <p> |
| 139 This test checks HeapSnapshots loader. | 139 This test checks HeapSnapshots loader. |
| 140 </p> | 140 </p> |
| 141 | 141 |
| 142 </body> | 142 </body> |
| 143 </html> | 143 </html> |
| OLD | NEW |