| OLD | NEW |
| 1 // This script is supposed to be evaluated in dummy inspector front-end which is
loaded from | 1 // This script is supposed to be evaluated in dummy inspector front-end which is
loaded from |
| 2 // ../../../http/tests/inspector-protocol/resources/protocol-test.html and the r
elative paths | 2 // ../../../http/tests/inspector-protocol/resources/protocol-test.html and the r
elative paths |
| 3 // below are relative to that location. | 3 // below are relative to that location. |
| 4 | 4 |
| 5 if (!window.WebInspector) | 5 if (!window.WebInspector) |
| 6 window.WebInspector = {}; | 6 window.WebInspector = {}; |
| 7 InspectorTest.importScript("../../../../../Source/devtools/front_end/HeapSnapsho
t.js"); | 7 InspectorTest.importScript("../../../../../Source/devtools/front_end/HeapSnapsho
t.js"); |
| 8 InspectorTest.importScript("../../../../../Source/devtools/front_end/JSHeapSnaps
hot.js"); | 8 InspectorTest.importScript("../../../../../Source/devtools/front_end/JSHeapSnaps
hot.js"); |
| 9 InspectorTest.importScript("../../../../../Source/devtools/front_end/UIString.js
"); | 9 InspectorTest.importScript("../../../../../Source/devtools/front_end/UIString.js
"); |
| 10 InspectorTest.importScript("../../../../../Source/devtools/front_end/utilities.j
s"); | 10 InspectorTest.importScript("../../../../../Source/devtools/front_end/utilities.j
s"); |
| 11 | 11 |
| 12 InspectorTest.fail = function(message) | 12 InspectorTest.fail = function(message) |
| 13 { | 13 { |
| 14 InspectorTest.log("FAIL: " + message); | 14 InspectorTest.log("FAIL: " + message); |
| 15 InspectorTest.completeTest(); | 15 InspectorTest.completeTest(); |
| 16 } | 16 } |
| 17 | 17 |
| 18 InspectorTest.assert = function(result, message) | 18 InspectorTest.assert = function(result, message) |
| 19 { | 19 { |
| 20 if (!result) | 20 if (!result) |
| 21 InspectorTest.fail(message); | 21 InspectorTest.fail(message); |
| 22 } | 22 } |
| 23 | 23 |
| 24 InspectorTest.takeHeapSnapshot = function(callback) | 24 InspectorTest.takeHeapSnapshot = function(callback) |
| 25 { | 25 { |
| 26 InspectorTest.eventHandler["HeapProfiler.addProfileHeader"] = function(messa
geObject) | 26 var chunks = []; |
| 27 InspectorTest.eventHandler["HeapProfiler.addHeapSnapshotChunk"] = function(m
essageObject) |
| 27 { | 28 { |
| 28 var profileId = messageObject["params"]["header"]["uid"]; | 29 chunks.push(messageObject["params"]["chunk"]); |
| 29 InspectorTest.sendCommand("HeapProfiler.getHeapSnapshot", { "uid": profi
leId }, didGetHeapSnapshot); | |
| 30 | |
| 31 var chunks = []; | |
| 32 InspectorTest.eventHandler["HeapProfiler.addHeapSnapshotChunk"] = functi
on(messageObject) | |
| 33 { | |
| 34 chunks.push(messageObject["params"]["chunk"]); | |
| 35 } | |
| 36 | |
| 37 function didGetHeapSnapshot(messageObject) | |
| 38 { | |
| 39 var serializedSnapshot = chunks.join(""); | |
| 40 var parsed = JSON.parse(serializedSnapshot); | |
| 41 var snapshot = new WebInspector.JSHeapSnapshot(parsed, new WebInspec
tor.HeapSnapshotProgress()); | |
| 42 callback(snapshot); | |
| 43 InspectorTest.log("SUCCESS: didGetHeapSnapshot"); | |
| 44 InspectorTest.sendCommand("HeapProfiler.removeProfile", { "uid": pro
fileId }, didRemoveSnapshot); | |
| 45 } | |
| 46 | |
| 47 function didRemoveSnapshot(messageObject) | |
| 48 { | |
| 49 InspectorTest.completeTest(); | |
| 50 } | |
| 51 } | 30 } |
| 52 | 31 |
| 53 InspectorTest.sendCommand("HeapProfiler.takeHeapSnapshot", {}); | 32 function didTakeHeapSnapshot(messageObject) |
| 33 { |
| 34 var serializedSnapshot = chunks.join(""); |
| 35 var parsed = JSON.parse(serializedSnapshot); |
| 36 var snapshot = new WebInspector.JSHeapSnapshot(parsed, new WebInspector.
HeapSnapshotProgress()); |
| 37 callback(snapshot); |
| 38 InspectorTest.log("SUCCESS: didGetHeapSnapshot"); |
| 39 InspectorTest.completeTest(); |
| 40 } |
| 41 InspectorTest.sendCommand("HeapProfiler.takeHeapSnapshot", {}, didTakeHeapSn
apshot); |
| 54 } | 42 } |
| OLD | NEW |