test_HeapAnalyses_takeCensus_03.js (1405B)
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} bubbles errors properly when things 6 // go wrong. 7 8 add_task(async function () { 9 const client = new HeapAnalysesClient(); 10 11 // Snapshot file path to a file that doesn't exist. 12 let failed = false; 13 try { 14 await client.readHeapSnapshot( 15 getFilePath("foo-bar-baz" + Math.random(), true) 16 ); 17 } catch (e) { 18 failed = true; 19 } 20 ok(failed, "should not read heap snapshots that do not exist"); 21 22 // Snapshot file path to a file that is not a heap snapshot. 23 failed = false; 24 try { 25 await client.readHeapSnapshot( 26 getFilePath("test_HeapAnalyses_takeCensus_03.js") 27 ); 28 } catch (e) { 29 failed = true; 30 } 31 ok( 32 failed, 33 "should not be able to read a file " + 34 "that is not a heap snapshot as a heap snapshot" 35 ); 36 37 const snapshotFilePath = saveNewHeapSnapshot(); 38 await client.readHeapSnapshot(snapshotFilePath); 39 ok(true, "Should have read the heap snapshot"); 40 41 // Bad census breakdown options. 42 failed = false; 43 try { 44 await client.takeCensus(snapshotFilePath, { 45 breakdown: { by: "some classification that we do not have" }, 46 }); 47 } catch (e) { 48 failed = true; 49 } 50 ok(failed, "should not be able to breakdown by an unknown classification"); 51 52 client.destroy(); 53 });