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/platform/ut
ilities.js"); | 7 InspectorTest.importScript("../../../../../Source/devtools/front_end/platform/ut
ilities.js"); |
8 InspectorTest.importScript("../../../../../Source/devtools/front_end/common/UISt
ring.js"); | 8 InspectorTest.importScript("../../../../../Source/devtools/front_end/common/UISt
ring.js"); |
9 InspectorTest.importScript("../../../../../Source/devtools/front_end/profiler/He
apSnapshotCommon.js"); | 9 InspectorTest.importScript("../../../../../Source/devtools/front_end/profiler/He
apSnapshotCommon.js"); |
10 InspectorTest.importScript("../../../../../Source/devtools/front_end/heap_snapsh
ot_worker/HeapSnapshot.js"); | 10 InspectorTest.importScript("../../../../../Source/devtools/front_end/heap_snapsh
ot_worker/HeapSnapshot.js"); |
11 InspectorTest.importScript("../../../../../Source/devtools/front_end/heap_snapsh
ot_worker/JSHeapSnapshot.js"); | 11 InspectorTest.importScript("../../../../../Source/devtools/front_end/heap_snapsh
ot_worker/JSHeapSnapshot.js"); |
12 | 12 |
13 InspectorTest.fail = function(message) | 13 InspectorTest.fail = function(message) |
14 { | 14 { |
15 InspectorTest.log("FAIL: " + message); | 15 InspectorTest.log("FAIL: " + message); |
16 InspectorTest.completeTest(); | 16 InspectorTest.completeTest(); |
17 } | 17 } |
18 | 18 |
19 InspectorTest.assert = function(result, message) | |
20 { | |
21 if (!result) | |
22 InspectorTest.fail(message); | |
23 } | |
24 | |
25 InspectorTest.takeHeapSnapshot = function(callback) | 19 InspectorTest.takeHeapSnapshot = function(callback) |
26 { | 20 { |
27 var chunks = []; | 21 var chunks = []; |
28 InspectorTest.eventHandler["HeapProfiler.addHeapSnapshotChunk"] = function(m
essageObject) | 22 InspectorTest.eventHandler["HeapProfiler.addHeapSnapshotChunk"] = function(m
essageObject) |
29 { | 23 { |
30 chunks.push(messageObject["params"]["chunk"]); | 24 chunks.push(messageObject["params"]["chunk"]); |
31 } | 25 } |
32 | 26 |
33 function didTakeHeapSnapshot(messageObject) | 27 function didTakeHeapSnapshot(messageObject) |
34 { | 28 { |
35 var serializedSnapshot = chunks.join(""); | 29 var serializedSnapshot = chunks.join(""); |
36 var parsed = JSON.parse(serializedSnapshot); | 30 var parsed = JSON.parse(serializedSnapshot); |
37 parsed.nodes = new Uint32Array(parsed.nodes); | 31 parsed.nodes = new Uint32Array(parsed.nodes); |
38 parsed.edges = new Uint32Array(parsed.edges); | 32 parsed.edges = new Uint32Array(parsed.edges); |
39 var snapshot = new WebInspector.JSHeapSnapshot(parsed, new WebInspector.
HeapSnapshotProgress()); | 33 var snapshot = new WebInspector.JSHeapSnapshot(parsed, new WebInspector.
HeapSnapshotProgress()); |
40 callback(snapshot); | 34 callback(snapshot); |
41 InspectorTest.log("SUCCESS: didGetHeapSnapshot"); | 35 InspectorTest.log("SUCCESS: didGetHeapSnapshot"); |
42 InspectorTest.completeTest(); | 36 InspectorTest.completeTest(); |
43 } | 37 } |
44 InspectorTest.sendCommand("HeapProfiler.takeHeapSnapshot", {}, didTakeHeapSn
apshot); | 38 InspectorTest.sendCommand("HeapProfiler.takeHeapSnapshot", {}, didTakeHeapSn
apshot); |
45 } | 39 } |
OLD | NEW |