browser_perf-options-show-idle-blocks-02.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. "use strict";
  4. /**
  5. * Tests that the memory flamegraphs get rerendered when toggling `show-idle-blocks`.
  6. */
  7. const { SIMPLE_URL } = require("devtools/client/performance/test/helpers/urls");
  8. const { UI_ENABLE_ALLOCATIONS_PREF, UI_SHOW_IDLE_BLOCKS_PREF } = require("devtools/client/performance/test/helpers/prefs");
  9. const { initPerformanceInNewTab, teardownToolboxAndRemoveTab } = require("devtools/client/performance/test/helpers/panel-utils");
  10. const { startRecording, stopRecording } = require("devtools/client/performance/test/helpers/actions");
  11. const { once } = require("devtools/client/performance/test/helpers/event-utils");
  12. add_task(function* () {
  13. let { panel } = yield initPerformanceInNewTab({
  14. url: SIMPLE_URL,
  15. win: window
  16. });
  17. let { EVENTS, DetailsView, MemoryFlameGraphView } = panel.panelWin;
  18. // Enable allocations to test.
  19. Services.prefs.setBoolPref(UI_ENABLE_ALLOCATIONS_PREF, true);
  20. Services.prefs.setBoolPref(UI_SHOW_IDLE_BLOCKS_PREF, true);
  21. yield startRecording(panel);
  22. yield stopRecording(panel);
  23. let rendered = once(MemoryFlameGraphView, EVENTS.UI_MEMORY_FLAMEGRAPH_RENDERED);
  24. yield DetailsView.selectView("memory-flamegraph");
  25. yield rendered;
  26. rendered = once(MemoryFlameGraphView, EVENTS.UI_MEMORY_FLAMEGRAPH_RENDERED);
  27. Services.prefs.setBoolPref(UI_SHOW_IDLE_BLOCKS_PREF, false);
  28. yield rendered;
  29. ok(true, "MemoryFlameGraphView rerendered when toggling show-idle-blocks.");
  30. rendered = once(MemoryFlameGraphView, EVENTS.UI_MEMORY_FLAMEGRAPH_RENDERED);
  31. Services.prefs.setBoolPref(UI_SHOW_IDLE_BLOCKS_PREF, true);
  32. yield rendered;
  33. ok(true, "MemoryFlameGraphView rerendered when toggling back show-idle-blocks.");
  34. yield teardownToolboxAndRemoveTab(panel);
  35. });