tor-browser

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

test_census-tree-node-02.js (2814B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 "use strict";
      4 
      5 /**
      6 * Tests CensusTreeNode with `coarseType` breakdown.
      7 */
      8 
      9 const countBreakdown = { by: "count", count: true, bytes: true };
     10 
     11 const BREAKDOWN = {
     12  by: "coarseType",
     13  objects: { by: "objectClass", then: countBreakdown },
     14  strings: countBreakdown,
     15  scripts: countBreakdown,
     16  other: { by: "internalType", then: countBreakdown },
     17  domNode: countBreakdown,
     18 };
     19 
     20 const REPORT = {
     21  objects: {
     22    Function: { bytes: 10, count: 1 },
     23    Array: { bytes: 20, count: 2 },
     24  },
     25  strings: { bytes: 10, count: 1 },
     26  scripts: { bytes: 1, count: 1 },
     27  other: {
     28    "js::Shape": { bytes: 30, count: 3 },
     29    "js::Shape2": { bytes: 40, count: 4 },
     30  },
     31  domNode: { bytes: 0, count: 0 },
     32 };
     33 
     34 const EXPECTED = {
     35  name: null,
     36  bytes: 0,
     37  totalBytes: 111,
     38  count: 0,
     39  totalCount: 12,
     40  children: [
     41    {
     42      name: "other",
     43      count: 0,
     44      totalCount: 7,
     45      bytes: 0,
     46      totalBytes: 70,
     47      children: [
     48        {
     49          name: "js::Shape2",
     50          bytes: 40,
     51          totalBytes: 40,
     52          count: 4,
     53          totalCount: 4,
     54          children: undefined,
     55          id: 9,
     56          parent: 7,
     57          reportLeafIndex: 8,
     58        },
     59        {
     60          name: "js::Shape",
     61          bytes: 30,
     62          totalBytes: 30,
     63          count: 3,
     64          totalCount: 3,
     65          children: undefined,
     66          id: 8,
     67          parent: 7,
     68          reportLeafIndex: 7,
     69        },
     70      ],
     71      id: 7,
     72      parent: 1,
     73      reportLeafIndex: undefined,
     74    },
     75    {
     76      name: "objects",
     77      count: 0,
     78      totalCount: 3,
     79      bytes: 0,
     80      totalBytes: 30,
     81      children: [
     82        {
     83          name: "Array",
     84          bytes: 20,
     85          totalBytes: 20,
     86          count: 2,
     87          totalCount: 2,
     88          children: undefined,
     89          id: 4,
     90          parent: 2,
     91          reportLeafIndex: 3,
     92        },
     93        {
     94          name: "Function",
     95          bytes: 10,
     96          totalBytes: 10,
     97          count: 1,
     98          totalCount: 1,
     99          children: undefined,
    100          id: 3,
    101          parent: 2,
    102          reportLeafIndex: 2,
    103        },
    104      ],
    105      id: 2,
    106      parent: 1,
    107      reportLeafIndex: undefined,
    108    },
    109    {
    110      name: "strings",
    111      count: 1,
    112      totalCount: 1,
    113      bytes: 10,
    114      totalBytes: 10,
    115      children: undefined,
    116      id: 6,
    117      parent: 1,
    118      reportLeafIndex: 5,
    119    },
    120    {
    121      name: "scripts",
    122      count: 1,
    123      totalCount: 1,
    124      bytes: 1,
    125      totalBytes: 1,
    126      children: undefined,
    127      id: 5,
    128      parent: 1,
    129      reportLeafIndex: 4,
    130    },
    131  ],
    132  id: 1,
    133  parent: undefined,
    134  reportLeafIndex: undefined,
    135 };
    136 
    137 function run_test() {
    138  compareCensusViewData(BREAKDOWN, REPORT, EXPECTED);
    139 }