test_HeapSnapshot_computeShortestPaths_02.js (1202B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 "use strict"; 4 5 // Test computing shortest paths with invalid arguments. 6 7 function run_test() { 8 const path = ChromeUtils.saveHeapSnapshot({ runtime: true }); 9 const snapshot = ChromeUtils.readHeapSnapshot(path); 10 11 const dominatorTree = snapshot.computeDominatorTree(); 12 const target = dominatorTree 13 .getImmediatelyDominated(dominatorTree.root) 14 .pop(); 15 ok(target); 16 17 let threw = false; 18 try { 19 snapshot.computeShortestPaths(0, [target], 2); 20 } catch (_) { 21 threw = true; 22 } 23 ok(threw, "invalid start node should throw"); 24 25 threw = false; 26 try { 27 snapshot.computeShortestPaths(dominatorTree.root, [0], 2); 28 } catch (_) { 29 threw = true; 30 } 31 ok(threw, "invalid target nodes should throw"); 32 33 threw = false; 34 try { 35 snapshot.computeShortestPaths(dominatorTree.root, [], 2); 36 } catch (_) { 37 threw = true; 38 } 39 ok(threw, "empty target nodes should throw"); 40 41 threw = false; 42 try { 43 snapshot.computeShortestPaths(dominatorTree.root, [target], 0); 44 } catch (_) { 45 threw = true; 46 } 47 ok(threw, "0 max paths should throw"); 48 49 do_test_finished(); 50 }