browser_perf-options-enable-memory-02.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. "use strict";
  4. /**
  5. * Tests that toggling `enable-memory` during a recording doesn't change that
  6. * recording's state and does not break.
  7. */
  8. const { SIMPLE_URL } = require("devtools/client/performance/test/helpers/urls");
  9. const { UI_ENABLE_MEMORY_PREF } = require("devtools/client/performance/test/helpers/prefs");
  10. const { initPerformanceInNewTab, teardownToolboxAndRemoveTab } = require("devtools/client/performance/test/helpers/panel-utils");
  11. const { startRecording, stopRecording } = require("devtools/client/performance/test/helpers/actions");
  12. add_task(function* () {
  13. let { panel } = yield initPerformanceInNewTab({
  14. url: SIMPLE_URL,
  15. win: window
  16. });
  17. let { PerformanceController } = panel.panelWin;
  18. // Test starting without memory, and stopping with it.
  19. Services.prefs.setBoolPref(UI_ENABLE_MEMORY_PREF, false);
  20. yield startRecording(panel);
  21. Services.prefs.setBoolPref(UI_ENABLE_MEMORY_PREF, true);
  22. yield stopRecording(panel);
  23. is(PerformanceController.getCurrentRecording().getConfiguration().withMemory, false,
  24. "The recording finished without tracking memory.");
  25. is(PerformanceController.getCurrentRecording().getConfiguration().withAllocations,
  26. false,
  27. "The recording finished without tracking allocations.");
  28. // Test starting with memory, and stopping without it.
  29. yield startRecording(panel);
  30. Services.prefs.setBoolPref(UI_ENABLE_MEMORY_PREF, false);
  31. yield stopRecording(panel);
  32. is(PerformanceController.getCurrentRecording().getConfiguration().withMemory, true,
  33. "The recording finished with tracking memory.");
  34. is(PerformanceController.getCurrentRecording().getConfiguration().withAllocations,
  35. false,
  36. "The recording still is not recording allocations.");
  37. yield teardownToolboxAndRemoveTab(panel);
  38. });