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/common/UIString.js");
8 InspectorTest.importScript("../../../../../Source/devtools/front_end/common/utilities.js");
9 InspectorTest.importScript("../../../../../Source/devtools/front_end/profiler/HeapSnapshotCommon.js");
10 InspectorTest.importScript("../../../../../Source/devtools/front_end/profiler/heap_snapshot_worker/HeapSnapshot.js");
11 InspectorTest.importScript("../../../../../Source/devtools/front_end/profiler/heap_snapshot_worker/JSHeapSnapshot.js");
13 InspectorTest.fail = function(message)
15 InspectorTest.log("FAIL: " + message);
16 InspectorTest.completeTest();
19 InspectorTest.assert = function(result, message)
22 InspectorTest.fail(message);
25 InspectorTest.takeHeapSnapshot = function(callback)
28 InspectorTest.eventHandler["HeapProfiler.addHeapSnapshotChunk"] = function(messageObject)
30 chunks.push(messageObject["params"]["chunk"]);
33 function didTakeHeapSnapshot(messageObject)
35 var serializedSnapshot = chunks.join("");
36 var parsed = JSON.parse(serializedSnapshot);
37 parsed.nodes = new Uint32Array(parsed.nodes);
38 parsed.edges = new Uint32Array(parsed.edges);
39 var snapshot = new WebInspector.JSHeapSnapshot(parsed, new WebInspector.HeapSnapshotProgress());
41 InspectorTest.log("SUCCESS: didGetHeapSnapshot");
42 InspectorTest.completeTest();
44 InspectorTest.sendCommand("HeapProfiler.takeHeapSnapshot", {}, didTakeHeapSnapshot);