test_HeapSnapshot_describeNode_01.js (1094B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 "use strict"; 4 5 // Test that we can describe nodes with a breakdown. 6 7 function run_test() { 8 const path = saveNewHeapSnapshot(); 9 const snapshot = ChromeUtils.readHeapSnapshot(path); 10 ok(snapshot.describeNode); 11 equal(typeof snapshot.describeNode, "function"); 12 13 const dt = snapshot.computeDominatorTree(); 14 15 let threw = false; 16 try { 17 snapshot.describeNode(undefined, dt.root); 18 } catch (_) { 19 threw = true; 20 } 21 ok(threw, "Should require a breakdown"); 22 23 const breakdown = { 24 by: "coarseType", 25 objects: { by: "objectClass" }, 26 scripts: { by: "internalType" }, 27 strings: { by: "internalType" }, 28 other: { by: "internalType" }, 29 }; 30 31 threw = false; 32 try { 33 snapshot.describeNode(breakdown, 0); 34 } catch (_) { 35 threw = true; 36 } 37 ok(threw, "Should throw when given an invalid node id"); 38 39 const description = snapshot.describeNode(breakdown, dt.root); 40 ok(description); 41 ok(description.other); 42 ok(description.other["JS::ubi::RootList"]); 43 }