tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_HeapAnalyses_takeCensus_07.js (1391B)


      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 // an inverted CensusTreeNode.
      7 
      8 const BREAKDOWN = {
      9  by: "coarseType",
     10  objects: {
     11    by: "objectClass",
     12    then: { by: "count", count: true, bytes: true },
     13    other: { by: "count", count: true, bytes: true },
     14  },
     15  scripts: {
     16    by: "internalType",
     17    then: { by: "count", count: true, bytes: true },
     18  },
     19  strings: {
     20    by: "internalType",
     21    then: { by: "count", count: true, bytes: true },
     22  },
     23  other: {
     24    by: "internalType",
     25    then: { by: "count", count: true, bytes: true },
     26  },
     27  domNode: {
     28    by: "descriptiveType",
     29    then: { by: "count", count: true, bytes: true },
     30  },
     31 };
     32 
     33 add_task(async function () {
     34  const client = new HeapAnalysesClient();
     35 
     36  const snapshotFilePath = saveNewHeapSnapshot();
     37  await client.readHeapSnapshot(snapshotFilePath);
     38  ok(true, "Should have read the heap snapshot");
     39 
     40  const { report } = await client.takeCensus(snapshotFilePath, {
     41    breakdown: BREAKDOWN,
     42  });
     43 
     44  const { report: treeNode } = await client.takeCensus(
     45    snapshotFilePath,
     46    {
     47      breakdown: BREAKDOWN,
     48    },
     49    {
     50      asInvertedTreeNode: true,
     51    }
     52  );
     53 
     54  compareCensusViewData(BREAKDOWN, report, treeNode, { invert: true });
     55 
     56  client.destroy();
     57 });