browser_memory_allocationStackDisplay_01.js (1786B)
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 displays in the tree. 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 "http://example.com/browser/devtools/client/memory/test/browser/doc_steady_allocation.html"; 22 23 this.test = makeMemoryTest(TEST_URL, async function ({ panel }) { 24 const heapWorker = panel.panelWin.gHeapAnalysesClient; 25 const { getState, dispatch } = panel.panelWin.gStore; 26 const front = getState().front; 27 const doc = panel.panelWin.document; 28 29 dispatch(changeView(viewState.CENSUS)); 30 31 dispatch( 32 censusDisplayActions.setCensusDisplay( 33 censusDisplays.invertedAllocationStack 34 ) 35 ); 36 is(getState().censusDisplay.breakdown.by, "allocationStack"); 37 38 await dispatch(toggleRecordingAllocationStacks(panel._commands)); 39 ok(getState().allocations.recording); 40 41 // Let some allocations build up. 42 await waitForTime(500); 43 44 await dispatch(takeSnapshotAndCensus(front, heapWorker)); 45 46 const names = [...doc.querySelectorAll(".frame-link-function-display-name")]; 47 ok(names.length, "Should have rendered some allocation stack tree items"); 48 ok( 49 names.some(e => !!e.textContent.trim()), 50 "And at least some of them should have functionDisplayNames" 51 ); 52 });