3 <script src="../../http/tests/inspector/inspector-test.js"></script>
4 <script src="heap-snapshot-test.js"></script>
9 InspectorTest.runHeapSnapshotTestSuite([
10 function testWeakReferencesDoNotAffectRetainedSize(next)
12 function createHeapSnapshot()
14 // Mocking results of running the following code:
15 // root = [new Uint8Array(1000), new Uint8Array(1000), new Uint8Array(1000)]
16 var builder = new InspectorTest.HeapSnapshotBuilder();
17 var rootNode = builder.rootNode;
19 var gcRootsNode = new InspectorTest.HeapNode("(GC roots)");
20 rootNode.linkNode(gcRootsNode, InspectorTest.HeapEdge.Type.element);
22 var windowNode = new InspectorTest.HeapNode("Window", 20);
23 rootNode.linkNode(windowNode, InspectorTest.HeapEdge.Type.shortcut);
24 gcRootsNode.linkNode(windowNode, InspectorTest.HeapEdge.Type.element);
26 var arrayNode = new InspectorTest.HeapNode("Array", 10);
27 windowNode.linkNode(arrayNode, InspectorTest.HeapEdge.Type.property, "root");
28 var prevBufferNode = null;
29 for (var i = 0; i < 3; i++) {
30 var typedArrayNode = new InspectorTest.HeapNode("Uint8Array", 100);
31 arrayNode.linkNode(typedArrayNode, InspectorTest.HeapEdge.Type.element);
33 var bufferNode = new InspectorTest.HeapNode("ArrayBuffer", 1000);
34 typedArrayNode.linkNode(bufferNode, InspectorTest.HeapEdge.Type.internal);
36 prevBufferNode.linkNode(bufferNode, InspectorTest.HeapEdge.Type.weak, "weak_next");
37 prevBufferNode = bufferNode;
40 return builder.generateSnapshot();
43 InspectorTest.takeAndOpenSnapshot(createHeapSnapshot, step1);
47 InspectorTest.switchToView("Summary", step2);
52 var row = InspectorTest.findRow("Array");
53 InspectorTest.assertEquals(true, !!row, "\"Array\" row");
54 InspectorTest.expandRow(row, step3);
59 InspectorTest.assertEquals(1, row._count);
60 InspectorTest.assertEquals(3310, row._retainedSize);
61 InspectorTest.assertEquals(10, row._shallowSize);
62 InspectorTest.expandRow(row.children[0], step4);
65 function step4(arrayInstanceRow)
67 InspectorTest.assertEquals(2, arrayInstanceRow._distance);
68 InspectorTest.assertEquals(3310, arrayInstanceRow._retainedSize);
69 InspectorTest.assertEquals(10, arrayInstanceRow._shallowSize);
71 var children = arrayInstanceRow.children;
72 InspectorTest.assertEquals(3, children.length);
74 for (var i = 0; i < children.length; i++) {
75 InspectorTest.assertEquals("Uint8Array", children[i]._name);
76 InspectorTest.assertEquals(100, children[i]._shallowSize);
77 InspectorTest.assertEquals(1100, children[i]._retainedSize);
87 <body onload="runTest()">
89 Tests that weak references are ignored when dominators are calculated and that weak references won't affect object's retained size.