tor-browser

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

test_census-tree-node-07.js (4702B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 "use strict";
      4 
      5 /**
      6 * Test inverting CensusTreeNode with a non-allocation stack breakdown.
      7 */
      8 
      9 function run_test() {
     10  const BREAKDOWN = {
     11    by: "coarseType",
     12    objects: {
     13      by: "objectClass",
     14      then: { by: "count", count: true, bytes: true },
     15      other: { by: "count", count: true, bytes: true },
     16    },
     17    scripts: {
     18      by: "internalType",
     19      then: { by: "count", count: true, bytes: true },
     20    },
     21    strings: {
     22      by: "internalType",
     23      then: { by: "count", count: true, bytes: true },
     24    },
     25    other: {
     26      by: "internalType",
     27      then: { by: "count", count: true, bytes: true },
     28    },
     29    domNode: {
     30      by: "descriptiveType",
     31      then: { by: "count", count: true, bytes: true },
     32    },
     33  };
     34 
     35  const REPORT = {
     36    objects: {
     37      Array: { bytes: 50, count: 5 },
     38      other: { bytes: 0, count: 0 },
     39    },
     40    scripts: {
     41      "js::jit::JitScript": { bytes: 30, count: 3 },
     42    },
     43    strings: {
     44      JSAtom: { bytes: 60, count: 6 },
     45    },
     46    other: {
     47      "js::Shape": { bytes: 80, count: 8 },
     48    },
     49    domNode: {},
     50  };
     51 
     52  const EXPECTED = {
     53    name: null,
     54    bytes: 0,
     55    totalBytes: 220,
     56    count: 0,
     57    totalCount: 22,
     58    children: [
     59      {
     60        name: "js::Shape",
     61        bytes: 80,
     62        totalBytes: 80,
     63        count: 8,
     64        totalCount: 8,
     65        children: [
     66          {
     67            name: "other",
     68            bytes: 0,
     69            totalBytes: 80,
     70            count: 0,
     71            totalCount: 8,
     72            children: [
     73              {
     74                name: null,
     75                bytes: 0,
     76                totalBytes: 220,
     77                count: 0,
     78                totalCount: 22,
     79                children: undefined,
     80                id: 15,
     81                parent: 14,
     82                reportLeafIndex: undefined,
     83              },
     84            ],
     85            id: 14,
     86            parent: 13,
     87            reportLeafIndex: undefined,
     88          },
     89        ],
     90        id: 13,
     91        parent: 12,
     92        reportLeafIndex: 9,
     93      },
     94      {
     95        name: "JSAtom",
     96        bytes: 60,
     97        totalBytes: 60,
     98        count: 6,
     99        totalCount: 6,
    100        children: [
    101          {
    102            name: "strings",
    103            bytes: 0,
    104            totalBytes: 60,
    105            count: 0,
    106            totalCount: 6,
    107            children: [
    108              {
    109                name: null,
    110                bytes: 0,
    111                totalBytes: 220,
    112                count: 0,
    113                totalCount: 22,
    114                children: undefined,
    115                id: 18,
    116                parent: 17,
    117                reportLeafIndex: undefined,
    118              },
    119            ],
    120            id: 17,
    121            parent: 16,
    122            reportLeafIndex: undefined,
    123          },
    124        ],
    125        id: 16,
    126        parent: 12,
    127        reportLeafIndex: 7,
    128      },
    129      {
    130        name: "Array",
    131        bytes: 50,
    132        totalBytes: 50,
    133        count: 5,
    134        totalCount: 5,
    135        children: [
    136          {
    137            name: "objects",
    138            bytes: 0,
    139            totalBytes: 50,
    140            count: 0,
    141            totalCount: 5,
    142            children: [
    143              {
    144                name: null,
    145                bytes: 0,
    146                totalBytes: 220,
    147                count: 0,
    148                totalCount: 22,
    149                children: undefined,
    150                id: 21,
    151                parent: 20,
    152                reportLeafIndex: undefined,
    153              },
    154            ],
    155            id: 20,
    156            parent: 19,
    157            reportLeafIndex: undefined,
    158          },
    159        ],
    160        id: 19,
    161        parent: 12,
    162        reportLeafIndex: 2,
    163      },
    164      {
    165        name: "js::jit::JitScript",
    166        bytes: 30,
    167        totalBytes: 30,
    168        count: 3,
    169        totalCount: 3,
    170        children: [
    171          {
    172            name: "scripts",
    173            bytes: 0,
    174            totalBytes: 30,
    175            count: 0,
    176            totalCount: 3,
    177            children: [
    178              {
    179                name: null,
    180                bytes: 0,
    181                totalBytes: 220,
    182                count: 0,
    183                totalCount: 22,
    184                children: undefined,
    185                id: 24,
    186                parent: 23,
    187                reportLeafIndex: undefined,
    188              },
    189            ],
    190            id: 23,
    191            parent: 22,
    192            reportLeafIndex: undefined,
    193          },
    194        ],
    195        id: 22,
    196        parent: 12,
    197        reportLeafIndex: 5,
    198      },
    199    ],
    200    id: 12,
    201    parent: undefined,
    202    reportLeafIndex: undefined,
    203  };
    204 
    205  compareCensusViewData(BREAKDOWN, REPORT, EXPECTED, { invert: true });
    206 }