test_action-toggle-recording-allocations.js (1692B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 /** 7 * Test toggling the recording of allocation stacks. 8 */ 9 10 const { 11 toggleRecordingAllocationStacks, 12 } = require("resource://devtools/client/memory/actions/allocations.js"); 13 14 add_task(async function () { 15 const front = new StubbedMemoryFront(); 16 await front.attach(); 17 // Implement the minimal mock, doing nothing to make toggleRecordingAllocationStacks pass 18 const commands = { 19 targetCommand: { 20 hasTargetWatcherSupport() { 21 return true; 22 }, 23 }, 24 targetConfigurationCommand: { 25 updateConfiguration() {}, 26 }, 27 }; 28 const store = Store(); 29 const { getState, dispatch } = store; 30 31 equal(getState().allocations.recording, false, "not recording by default"); 32 equal( 33 getState().allocations.togglingInProgress, 34 false, 35 "not in the process of toggling by default" 36 ); 37 38 dispatch(toggleRecordingAllocationStacks(commands)); 39 await waitUntilState(store, () => getState().allocations.togglingInProgress); 40 ok(true, "`togglingInProgress` set to true when toggling on"); 41 await waitUntilState(store, () => !getState().allocations.togglingInProgress); 42 43 equal(getState().allocations.recording, true, "now we are recording"); 44 45 dispatch(toggleRecordingAllocationStacks(commands)); 46 await waitUntilState(store, () => getState().allocations.togglingInProgress); 47 ok(true, "`togglingInProgress` set to true when toggling off"); 48 await waitUntilState(store, () => !getState().allocations.togglingInProgress); 49 50 equal(getState().allocations.recording, false, "now we are not recording"); 51 52 await front.detach(); 53 });