summaryrefslogtreecommitdiffstats
path: root/devtools/shared/heapsnapshot/tests/unit/test_DominatorTreeNode_insert_01.js
blob: 979232ff498a9c73717e6ce7707994c362fc37be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

// Test that we can insert new children into an existing DominatorTreeNode tree.

const tree = makeTestDominatorTreeNode({ nodeId: 1000 }, [
  makeTestDominatorTreeNode({}),
  makeTestDominatorTreeNode({ nodeId: 2000 }, [
    makeTestDominatorTreeNode({}),
    makeTestDominatorTreeNode({ nodeId: 3000 }),
    makeTestDominatorTreeNode({}),
  ]),
  makeTestDominatorTreeNode({}),
]);

const path = [1000, 2000, 3000];

const newChildren = [
  makeTestDominatorTreeNode({ parentId: 3000 }),
  makeTestDominatorTreeNode({ parentId: 3000 }),
];

const moreChildrenAvailable = false;

const expected = {
  nodeId: 1000,
  parentId: undefined,
  label: undefined,
  shallowSize: 1,
  retainedSize: 7,
  children: [
    {
      nodeId: 0,
      label: undefined,
      shallowSize: 1,
      retainedSize: 1,
      parentId: 1000,
      moreChildrenAvailable: true,
      children: undefined,
    },
    {
      nodeId: 2000,
      label: undefined,
      shallowSize: 1,
      retainedSize: 4,
      parentId: 1000,
      children: [
        {
          nodeId: 1,
          label: undefined,
          shallowSize: 1,
          retainedSize: 1,
          parentId: 2000,
          moreChildrenAvailable: true,
          children: undefined,
        },
        {
          nodeId: 3000,
          label: undefined,
          shallowSize: 1,
          retainedSize: 1,
          parentId: 2000,
          children: [
            {
              nodeId: 7,
              parentId: 3000,
              label: undefined,
              shallowSize: 1,
              retainedSize: 1,
              moreChildrenAvailable: true,
              children: undefined,
            },
            {
              nodeId: 8,
              parentId: 3000,
              label: undefined,
              shallowSize: 1,
              retainedSize: 1,
              moreChildrenAvailable: true,
              children: undefined,
            },
          ],
          moreChildrenAvailable: false
        },
        {
          nodeId: 3,
          label: undefined,
          shallowSize: 1,
          retainedSize: 1,
          parentId: 2000,
          moreChildrenAvailable: true,
          children: undefined,
        },
      ],
      moreChildrenAvailable: true
    },
    {
      nodeId: 5,
      label: undefined,
      shallowSize: 1,
      retainedSize: 1,
      parentId: 1000,
      moreChildrenAvailable: true,
      children: undefined,
    }
  ],
  moreChildrenAvailable: true
};

function run_test() {
  assertDominatorTreeNodeInsertion(tree, path, newChildren, moreChildrenAvailable, expected);
}