diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /devtools/client/memory/test/xpcshell/test_action-set-display-and-refresh-02.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/memory/test/xpcshell/test_action-set-display-and-refresh-02.js')
-rw-r--r-- | devtools/client/memory/test/xpcshell/test_action-set-display-and-refresh-02.js | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/devtools/client/memory/test/xpcshell/test_action-set-display-and-refresh-02.js b/devtools/client/memory/test/xpcshell/test_action-set-display-and-refresh-02.js new file mode 100644 index 0000000000..2b2b91bc97 --- /dev/null +++ b/devtools/client/memory/test/xpcshell/test_action-set-display-and-refresh-02.js @@ -0,0 +1,74 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +/** + * Tests the task creator `setCensusDisplayAndRefreshAndRefresh()` for custom + * displays. + */ + +const { + censusState, + viewState, +} = require("resource://devtools/client/memory/constants.js"); +const { + setCensusDisplayAndRefresh, +} = require("resource://devtools/client/memory/actions/census-display.js"); +const { + takeSnapshotAndCensus, +} = require("resource://devtools/client/memory/actions/snapshot.js"); +const { + changeView, +} = require("resource://devtools/client/memory/actions/view.js"); + +const CUSTOM = { + displayName: "Custom", + tooltip: "Custom tooltip", + inverted: false, + breakdown: { + by: "internalType", + then: { by: "count", bytes: true, count: false }, + }, +}; + +add_task(async function () { + const front = new StubbedMemoryFront(); + const heapWorker = new HeapAnalysesClient(); + await front.attach(); + const store = Store(); + const { getState, dispatch } = store; + + dispatch(changeView(viewState.CENSUS)); + dispatch(setCensusDisplayAndRefresh(heapWorker, CUSTOM)); + equal( + getState().censusDisplay, + CUSTOM, + "CUSTOM display stored in display state." + ); + + dispatch(takeSnapshotAndCensus(front, heapWorker)); + await waitUntilCensusState(store, s => s.census, [censusState.SAVED]); + + equal( + getState().snapshots[0].census.display, + CUSTOM, + "New snapshot stored CUSTOM display when done taking census" + ); + ok( + getState().snapshots[0].census.report.children.length, + "Census has some children" + ); + // Ensure we don't have `count` in any results + ok( + getState().snapshots[0].census.report.children.every(c => !c.count), + "Census used CUSTOM display without counts" + ); + // Ensure we do have `bytes` in the results + ok( + getState().snapshots[0].census.report.children.every( + c => typeof c.bytes === "number" + ), + "Census used CUSTOM display with bytes" + ); +}); |