diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /devtools/shared/heapsnapshot/tests/xpcshell/test_HeapAnalyses_getDominatorTree_01.js | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | devtools/shared/heapsnapshot/tests/xpcshell/test_HeapAnalyses_getDominatorTree_01.js | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/devtools/shared/heapsnapshot/tests/xpcshell/test_HeapAnalyses_getDominatorTree_01.js b/devtools/shared/heapsnapshot/tests/xpcshell/test_HeapAnalyses_getDominatorTree_01.js new file mode 100644 index 0000000000..9035624ca2 --- /dev/null +++ b/devtools/shared/heapsnapshot/tests/xpcshell/test_HeapAnalyses_getDominatorTree_01.js @@ -0,0 +1,87 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + +// Test the HeapAnalyses{Client,Worker} "getDominatorTree" request. + +const breakdown = { + by: "coarseType", + objects: { by: "count", count: true, bytes: true }, + scripts: { by: "count", count: true, bytes: true }, + strings: { by: "count", count: true, bytes: true }, + other: { by: "count", count: true, bytes: true }, + domNode: { by: "count", count: true, bytes: true }, +}; + +add_task(async function () { + const client = new HeapAnalysesClient(); + + const snapshotFilePath = saveNewHeapSnapshot(); + await client.readHeapSnapshot(snapshotFilePath); + ok(true, "Should have read the heap snapshot"); + + const dominatorTreeId = await client.computeDominatorTree(snapshotFilePath); + equal( + typeof dominatorTreeId, + "number", + "should get a dominator tree id, and it should be a number" + ); + + const partialTree = await client.getDominatorTree({ + dominatorTreeId, + breakdown, + }); + ok(partialTree, "Should get a partial tree"); + equal(typeof partialTree, "object", "partialTree should be an object"); + + function checkTree(node) { + equal(typeof node.nodeId, "number", "each node should have an id"); + + if (node === partialTree) { + equal(node.parentId, undefined, "the root has no parent"); + } else { + equal( + typeof node.parentId, + "number", + "each node should have a parent id" + ); + } + + equal( + typeof node.retainedSize, + "number", + "each node should have a retained size" + ); + + ok( + node.children === undefined || Array.isArray(node.children), + "each node either has a list of children, " + + "or undefined meaning no children loaded" + ); + equal( + typeof node.moreChildrenAvailable, + "boolean", + "each node should indicate if there are more children available or not" + ); + + equal(typeof node.shortestPaths, "object", "Should have shortest paths"); + equal( + typeof node.shortestPaths.nodes, + "object", + "Should have shortest paths' nodes" + ); + equal( + typeof node.shortestPaths.edges, + "object", + "Should have shortest paths' edges" + ); + + if (node.children) { + node.children.forEach(checkTree); + } + } + + checkTree(partialTree); + + client.destroy(); +}); |