tor-browser

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

test_HeapAnalyses_deleteHeapSnapshot_01.js (1539B)


      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 delete heap snapshots.
      6 
      7 const breakdown = {
      8  by: "coarseType",
      9  objects: { by: "count", count: true, bytes: true },
     10  scripts: { by: "count", count: true, bytes: true },
     11  strings: { by: "count", count: true, bytes: true },
     12  other: { by: "count", count: true, bytes: true },
     13 };
     14 
     15 add_task(async function () {
     16  const client = new HeapAnalysesClient();
     17 
     18  const snapshotFilePath = saveNewHeapSnapshot();
     19  await client.readHeapSnapshot(snapshotFilePath);
     20  ok(true, "Should have read the heap snapshot");
     21 
     22  const dominatorTreeId = await client.computeDominatorTree(snapshotFilePath);
     23  ok(true, "Should have computed the dominator tree");
     24 
     25  await client.deleteHeapSnapshot(snapshotFilePath);
     26  ok(true, "Should have deleted the snapshot");
     27 
     28  let threw = false;
     29  try {
     30    await client.getDominatorTree({
     31      dominatorTreeId,
     32      breakdown,
     33    });
     34  } catch (_) {
     35    threw = true;
     36  }
     37  ok(threw, "getDominatorTree on deleted tree should throw an error");
     38 
     39  threw = false;
     40  try {
     41    await client.computeDominatorTree(snapshotFilePath);
     42  } catch (_) {
     43    threw = true;
     44  }
     45  ok(threw, "computeDominatorTree on deleted snapshot should throw an error");
     46 
     47  threw = false;
     48  try {
     49    await client.takeCensus(snapshotFilePath);
     50  } catch (_) {
     51    threw = true;
     52  }
     53  ok(threw, "takeCensus on deleted tree should throw an error");
     54 
     55  client.destroy();
     56 });