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 relative paths
3 // below are relative to that location.
5 if (!window.WebInspector)
6 window.WebInspector = {};
7 InspectorTest.importScript("../../../../../Source/devtools/front_end/HeapSnapshot.js");
8 InspectorTest.importScript("../../../../../Source/devtools/front_end/JSHeapSnapshot.js");
9 InspectorTest.importScript("../../../../../Source/devtools/front_end/UIString.js");
10 InspectorTest.importScript("../../../../../Source/devtools/front_end/utilities.js");
12 InspectorTest.fail = function(message)
14 InspectorTest.log("FAIL: " + message);
15 InspectorTest.completeTest();
18 InspectorTest.assert = function(result, message)
21 InspectorTest.fail(message);
24 InspectorTest.takeHeapSnapshot = function(callback)
26 InspectorTest.eventHandler["HeapProfiler.addProfileHeader"] = function(messageObject)
28 var profileId = messageObject["params"]["header"]["uid"];
29 InspectorTest.sendCommand("HeapProfiler.getHeapSnapshot", { "uid": profileId }, didGetHeapSnapshot);
32 InspectorTest.eventHandler["HeapProfiler.addHeapSnapshotChunk"] = function(messageObject)
34 chunks.push(messageObject["params"]["chunk"]);
37 function didGetHeapSnapshot(messageObject)
39 var serializedSnapshot = chunks.join("");
40 var parsed = JSON.parse(serializedSnapshot);
41 var snapshot = new WebInspector.JSHeapSnapshot(parsed, new WebInspector.HeapSnapshotProgress());
43 InspectorTest.log("SUCCESS: didGetHeapSnapshot");
44 InspectorTest.sendCommand("HeapProfiler.removeProfile", { "uid": profileId }, didRemoveSnapshot);
47 function didRemoveSnapshot(messageObject)
49 InspectorTest.completeTest();
53 InspectorTest.sendCommand("HeapProfiler.takeHeapSnapshot", {});