browser_memory_allocationStackDisplay_02.js (1767B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 // Sanity test that we can show allocation stack work when loading a new page 5 6 "use strict"; 7 8 const { 9 toggleRecordingAllocationStacks, 10 } = require("resource://devtools/client/memory/actions/allocations.js"); 11 const { 12 takeSnapshotAndCensus, 13 } = require("resource://devtools/client/memory/actions/snapshot.js"); 14 const censusDisplayActions = require("resource://devtools/client/memory/actions/census-display.js"); 15 const { viewState } = require("resource://devtools/client/memory/constants.js"); 16 const { 17 changeView, 18 } = require("resource://devtools/client/memory/actions/view.js"); 19 20 const TEST_URL = 21 "https://example.com/browser/devtools/client/memory/test/browser/doc_steady_allocation.html"; 22 23 this.test = makeMemoryTest("about:blank", async function ({ panel }) { 24 const heapWorker = panel.panelWin.gHeapAnalysesClient; 25 const { getState, dispatch } = panel.panelWin.gStore; 26 const doc = panel.panelWin.document; 27 28 dispatch(changeView(viewState.CENSUS)); 29 30 dispatch( 31 censusDisplayActions.setCensusDisplay( 32 censusDisplays.invertedAllocationStack 33 ) 34 ); 35 is(getState().censusDisplay.breakdown.by, "allocationStack"); 36 37 await dispatch(toggleRecordingAllocationStacks(panel._commands)); 38 ok(getState().allocations.recording); 39 40 await navigateTo(TEST_URL); 41 42 const front = getState().front; 43 await dispatch(takeSnapshotAndCensus(front, heapWorker)); 44 45 const names = [...doc.querySelectorAll(".frame-link-function-display-name")]; 46 ok(names.length, "Should have rendered some allocation stack tree items"); 47 ok( 48 names.some(e => !!e.textContent.trim()), 49 "And at least some of them should have functionDisplayNames" 50 ); 51 });