tor-browser

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

test_census-tree-node-10.js (1323B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 "use strict";
      4 
      5 /**
      6 * Test when multiple leaves in the census report map to the same node in an
      7 * inverted CensusReportTree.
      8 */
      9 
     10 function run_test() {
     11  const BREAKDOWN = {
     12    by: "coarseType",
     13    objects: {
     14      by: "objectClass",
     15      then: { by: "count", count: true, bytes: true },
     16    },
     17    other: {
     18      by: "internalType",
     19      then: { by: "count", count: true, bytes: true },
     20    },
     21    strings: { by: "count", count: true, bytes: true },
     22    scripts: { by: "count", count: true, bytes: true },
     23    domNode: { by: "count", count: true, bytes: true },
     24  };
     25 
     26  const REPORT = {
     27    objects: {
     28      Array: { count: 1, bytes: 10 },
     29    },
     30    other: {
     31      Array: { count: 1, bytes: 10 },
     32    },
     33    strings: { count: 0, bytes: 0 },
     34    scripts: { count: 0, bytes: 0 },
     35    domNode: { count: 0, bytes: 0 },
     36  };
     37 
     38  const node = censusReportToCensusTreeNode(BREAKDOWN, REPORT, {
     39    invert: true,
     40  });
     41 
     42  equal(node.children[0].name, "Array");
     43  equal(node.children[0].reportLeafIndex.size, 2);
     44  dumpn(
     45    `node.children[0].reportLeafIndex = ${[
     46      ...node.children[0].reportLeafIndex,
     47    ]}`
     48  );
     49  ok(node.children[0].reportLeafIndex.has(2));
     50  ok(node.children[0].reportLeafIndex.has(6));
     51 }