browser_perf-options-enable-memory-01.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. "use strict";
  4. /**
  5. * Tests that `enable-memory` toggles the visibility of the memory graph,
  6. * as well as enabling memory data on the PerformanceFront.
  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. const { isVisible } = require("devtools/client/performance/test/helpers/dom-utils");
  13. add_task(function* () {
  14. let { panel } = yield initPerformanceInNewTab({
  15. url: SIMPLE_URL,
  16. win: window
  17. });
  18. let { $, PerformanceController } = panel.panelWin;
  19. // Disable memory to test.
  20. Services.prefs.setBoolPref(UI_ENABLE_MEMORY_PREF, false);
  21. yield startRecording(panel);
  22. yield stopRecording(panel);
  23. is(PerformanceController.getCurrentRecording().getConfiguration().withMemory, false,
  24. "PerformanceFront started without memory recording.");
  25. is(PerformanceController.getCurrentRecording().getConfiguration().withAllocations,
  26. false, "PerformanceFront started without allocations recording.");
  27. ok(!isVisible($("#memory-overview")),
  28. "The memory graph is hidden when memory disabled.");
  29. // Re-enable memory.
  30. Services.prefs.setBoolPref(UI_ENABLE_MEMORY_PREF, true);
  31. is(PerformanceController.getCurrentRecording().getConfiguration().withMemory, false,
  32. "PerformanceFront still marked without memory recording.");
  33. is(PerformanceController.getCurrentRecording().getConfiguration().withAllocations,
  34. false, "PerformanceFront still marked without allocations recording.");
  35. ok(!isVisible($("#memory-overview")), "memory graph is still hidden after enabling " +
  36. "if recording did not start recording memory");
  37. yield startRecording(panel);
  38. yield stopRecording(panel);
  39. is(PerformanceController.getCurrentRecording().getConfiguration().withMemory, true,
  40. "PerformanceFront started with memory recording.");
  41. is(PerformanceController.getCurrentRecording().getConfiguration().withAllocations,
  42. false, "PerformanceFront did not record with allocations.");
  43. ok(isVisible($("#memory-overview")),
  44. "The memory graph is not hidden when memory enabled before recording.");
  45. yield teardownToolboxAndRemoveTab(panel);
  46. });