3 <script src=
"../../http/tests/inspector/inspector-test.js"></script>
4 <script src=
"heap-snapshot-test.js"></script>
9 function createHeapSnapshot()
11 var builder
= new InspectorTest
.HeapSnapshotBuilder();
13 for (type
in InspectorTest
.HeapNode
.Type
) {
14 if (!InspectorTest
.HeapNode
.Type
.hasOwnProperty(type
)) continue;
15 if (type
=== InspectorTest
.HeapNode
.Type
.synthetic
) continue;
16 if (type
=== InspectorTest
.HeapNode
.Type
.number
) continue;
18 var size
= index
* Math
.pow(10, index
- 1);
19 var node
= new InspectorTest
.HeapNode(type
, size
, InspectorTest
.HeapNode
.Type
[type
]);
20 InspectorTest
.addResult(type
+ " node size: " + size
);
21 builder
.rootNode
.linkNode(node
, InspectorTest
.HeapEdge
.Type
.internal, type
+ "Link");
23 var jsArrayNode
= new InspectorTest
.HeapNode("Array", 8, InspectorTest
.HeapNode
.Type
.object
);
24 builder
.rootNode
.linkNode(jsArrayNode
, InspectorTest
.HeapEdge
.Type
.internal, "JSArrayLink");
25 var jsArrayContentsNode
= new InspectorTest
.HeapNode("", 12, InspectorTest
.HeapNode
.Type
.array
);
26 jsArrayNode
.linkNode(jsArrayContentsNode
, InspectorTest
.HeapEdge
.Type
.internal, "elements");
27 var gcRootsNode
= new InspectorTest
.HeapNode("(GC roots)", 0, InspectorTest
.HeapNode
.Type
.synthetic
);
28 builder
.rootNode
.linkNode(gcRootsNode
, InspectorTest
.HeapEdge
.Type
.internal, "0");
29 var strongRoots
= new InspectorTest
.HeapNode("(Strong roots)", 0, InspectorTest
.HeapNode
.Type
.synthetic
);
30 gcRootsNode
.linkNode(strongRoots
, InspectorTest
.HeapEdge
.Type
.internal, "0");
31 var systemObj
= new InspectorTest
.HeapNode("SystemObject", 900000000, InspectorTest
.HeapNode
.Type
.object
);
32 strongRoots
.linkNode(systemObj
, InspectorTest
.HeapEdge
.Type
.internal, "0");
33 return builder
.generateSnapshot();
36 InspectorTest
.runHeapSnapshotTestSuite([
37 function testStatistics(next
)
39 InspectorTest
.addSniffer(WebInspector
.HeapSnapshotView
.prototype, "_gotStatistics", step1
, true);
40 InspectorTest
.takeAndOpenSnapshot(createHeapSnapshot
, function() {});
42 function step1(statistics
)
44 InspectorTest
.addResult(JSON
.stringify(statistics
));
53 <body onload=
"runTest()">
55 Tests Statistics view of detailed heap snapshots.