summaryrefslogtreecommitdiffstats
path: root/dom/heapsnapshot/tests/unit/test_DominatorTreeNode_insert_03.js
blob: f8cb5eec38954fd0cec04a6d541bd9e1e8ad68b4 (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
113
114
115
116
117
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

// Test inserting new children into an existing DominatorTreeNode at the root.

const tree = makeTestDominatorTreeNode({ nodeId: 666 }, [
  makeTestDominatorTreeNode({}),
  makeTestDominatorTreeNode({}, [
    makeTestDominatorTreeNode({}),
    makeTestDominatorTreeNode({}),
    makeTestDominatorTreeNode({}),
  ]),
  makeTestDominatorTreeNode({}),
]);

const path = [666];

const newChildren = [
  makeTestDominatorTreeNode({
    nodeId: 777,
    parentId: 666
  }),
  makeTestDominatorTreeNode({
    nodeId: 888,
    parentId: 666
  }),
];

const moreChildrenAvailable = false;

const expected = {
  nodeId: 666,
  label: undefined,
  parentId: undefined,
  shallowSize: 1,
  retainedSize: 7,
  children: [
    {
      nodeId: 0,
      label: undefined,
      shallowSize: 1,
      retainedSize: 1,
      parentId: 666,
      moreChildrenAvailable: true,
      children: undefined
    },
    {
      nodeId: 4,
      label: undefined,
      shallowSize: 1,
      retainedSize: 4,
      parentId: 666,
      children: [
        {
          nodeId: 1,
          label: undefined,
          shallowSize: 1,
          retainedSize: 1,
          parentId: 4,
          moreChildrenAvailable: true,
          children: undefined
        },
        {
          nodeId: 2,
          label: undefined,
          shallowSize: 1,
          retainedSize: 1,
          parentId: 4,
          moreChildrenAvailable: true,
          children: undefined
        },
        {
          nodeId: 3,
          label: undefined,
          shallowSize: 1,
          retainedSize: 1,
          parentId: 4,
          moreChildrenAvailable: true,
          children: undefined
        }
      ],
      moreChildrenAvailable: true
    },
    {
      nodeId: 5,
      label: undefined,
      shallowSize: 1,
      retainedSize: 1,
      parentId: 666,
      moreChildrenAvailable: true,
      children: undefined
    },
    {
      nodeId: 777,
      label: undefined,
      shallowSize: 1,
      retainedSize: 1,
      parentId: 666,
      moreChildrenAvailable: true,
      children: undefined
    },
    {
      nodeId: 888,
      label: undefined,
      shallowSize: 1,
      retainedSize: 1,
      parentId: 666,
      moreChildrenAvailable: true,
      children: undefined
    }
  ],
  moreChildrenAvailable: false
};

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