tor-browser

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

test_census-tree-node-08.js (3162B)


      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: "filename",
     12    then: {
     13      by: "internalType",
     14      then: { by: "count", count: true, bytes: true },
     15    },
     16    noFilename: {
     17      by: "internalType",
     18      then: { by: "count", count: true, bytes: true },
     19    },
     20  };
     21 
     22  const REPORT = {
     23    "http://example.com/app.js": {
     24      JSScript: { count: 10, bytes: 100 },
     25    },
     26    "http://example.com/ads.js": {
     27      "js::LazyScript": { count: 20, bytes: 200 },
     28    },
     29    "http://example.com/trackers.js": {
     30      JSScript: { count: 30, bytes: 300 },
     31    },
     32    noFilename: {
     33      "js::jit::JitCode": { count: 40, bytes: 400 },
     34    },
     35  };
     36 
     37  const EXPECTED = {
     38    name: null,
     39    bytes: 0,
     40    totalBytes: 1000,
     41    count: 0,
     42    totalCount: 100,
     43    children: [
     44      {
     45        name: "noFilename",
     46        bytes: 0,
     47        totalBytes: 400,
     48        count: 0,
     49        totalCount: 40,
     50        children: [
     51          {
     52            name: "js::jit::JitCode",
     53            bytes: 400,
     54            totalBytes: 400,
     55            count: 40,
     56            totalCount: 40,
     57            children: undefined,
     58            id: 9,
     59            parent: 8,
     60            reportLeafIndex: 8,
     61          },
     62        ],
     63        id: 8,
     64        parent: 1,
     65        reportLeafIndex: undefined,
     66      },
     67      {
     68        name: "http://example.com/trackers.js",
     69        bytes: 0,
     70        totalBytes: 300,
     71        count: 0,
     72        totalCount: 30,
     73        children: [
     74          {
     75            name: "JSScript",
     76            bytes: 300,
     77            totalBytes: 300,
     78            count: 30,
     79            totalCount: 30,
     80            children: undefined,
     81            id: 7,
     82            parent: 6,
     83            reportLeafIndex: 6,
     84          },
     85        ],
     86        id: 6,
     87        parent: 1,
     88        reportLeafIndex: undefined,
     89      },
     90      {
     91        name: "http://example.com/ads.js",
     92        bytes: 0,
     93        totalBytes: 200,
     94        count: 0,
     95        totalCount: 20,
     96        children: [
     97          {
     98            name: "js::LazyScript",
     99            bytes: 200,
    100            totalBytes: 200,
    101            count: 20,
    102            totalCount: 20,
    103            children: undefined,
    104            id: 5,
    105            parent: 4,
    106            reportLeafIndex: 4,
    107          },
    108        ],
    109        id: 4,
    110        parent: 1,
    111        reportLeafIndex: undefined,
    112      },
    113      {
    114        name: "http://example.com/app.js",
    115        bytes: 0,
    116        totalBytes: 100,
    117        count: 0,
    118        totalCount: 10,
    119        children: [
    120          {
    121            name: "JSScript",
    122            bytes: 100,
    123            totalBytes: 100,
    124            count: 10,
    125            totalCount: 10,
    126            children: undefined,
    127            id: 3,
    128            parent: 2,
    129            reportLeafIndex: 2,
    130          },
    131        ],
    132        id: 2,
    133        parent: 1,
    134        reportLeafIndex: undefined,
    135      },
    136    ],
    137    id: 1,
    138    parent: undefined,
    139    reportLeafIndex: undefined,
    140  };
    141 
    142  compareCensusViewData(BREAKDOWN, REPORT, EXPECTED);
    143 }