browser_perf-options-invert-flame-graph-01.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 js flamegraphs views get rerendered when toggling `invert-flame-graph`.
  6. */
  7. const { SIMPLE_URL } = require("devtools/client/performance/test/helpers/urls");
  8. const { UI_INVERT_FLAME_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, JsFlameGraphView } = panel.panelWin;
  18. Services.prefs.setBoolPref(UI_INVERT_FLAME_PREF, true);
  19. yield startRecording(panel);
  20. yield stopRecording(panel);
  21. let rendered = once(JsFlameGraphView, EVENTS.UI_JS_FLAMEGRAPH_RENDERED);
  22. yield DetailsView.selectView("js-flamegraph");
  23. yield rendered;
  24. rendered = once(JsFlameGraphView, EVENTS.UI_JS_FLAMEGRAPH_RENDERED);
  25. Services.prefs.setBoolPref(UI_INVERT_FLAME_PREF, false);
  26. yield rendered;
  27. ok(true, "JsFlameGraphView rerendered when toggling invert-call-tree.");
  28. rendered = once(JsFlameGraphView, EVENTS.UI_JS_FLAMEGRAPH_RENDERED);
  29. Services.prefs.setBoolPref(UI_INVERT_FLAME_PREF, true);
  30. yield rendered;
  31. ok(true, "JsFlameGraphView rerendered when toggling back invert-call-tree.");
  32. yield teardownToolboxAndRemoveTab(panel);
  33. });