test_HeapAnalyses_takeCensus_05.js (1211B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 "use strict"; 4 5 // Test that the HeapAnalyses{Client,Worker} can take censuses and return 6 // a CensusTreeNode. 7 8 const BREAKDOWN = { 9 by: "internalType", 10 then: { by: "count", count: true, bytes: true }, 11 }; 12 13 add_task(async function () { 14 const client = new HeapAnalysesClient(); 15 16 const snapshotFilePath = saveNewHeapSnapshot(); 17 await client.readHeapSnapshot(snapshotFilePath); 18 ok(true, "Should have read the heap snapshot"); 19 20 const { report } = await client.takeCensus(snapshotFilePath, { 21 breakdown: BREAKDOWN, 22 }); 23 24 const { report: treeNode } = await client.takeCensus( 25 snapshotFilePath, 26 { 27 breakdown: BREAKDOWN, 28 }, 29 { 30 asTreeNode: true, 31 } 32 ); 33 34 ok(!!treeNode.children.length, "treeNode has children"); 35 ok( 36 treeNode.children.every(type => { 37 return "name" in type && "bytes" in type && "count" in type; 38 }), 39 "all of tree node's children have name, bytes, count" 40 ); 41 42 compareCensusViewData( 43 BREAKDOWN, 44 report, 45 treeNode, 46 "Returning census as a tree node represents same data as the report" 47 ); 48 49 client.destroy(); 50 });