browser_perf-options-enable-framerate-01.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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-framerate` toggles the visibility of the fps graph,
  6. * as well as enabling ticks data on the PerformanceFront.
  7. */
  8. const { SIMPLE_URL } = require("devtools/client/performance/test/helpers/urls");
  9. const { UI_ENABLE_FRAMERATE_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 framerate to test.
  20. Services.prefs.setBoolPref(UI_ENABLE_FRAMERATE_PREF, false);
  21. yield startRecording(panel);
  22. yield stopRecording(panel);
  23. is(PerformanceController.getCurrentRecording().getConfiguration().withTicks, false,
  24. "PerformanceFront started without ticks recording.");
  25. ok(!isVisible($("#time-framerate")),
  26. "The fps graph is hidden when ticks disabled.");
  27. // Re-enable framerate.
  28. Services.prefs.setBoolPref(UI_ENABLE_FRAMERATE_PREF, true);
  29. is(PerformanceController.getCurrentRecording().getConfiguration().withTicks, false,
  30. "PerformanceFront still marked without ticks recording.");
  31. ok(!isVisible($("#time-framerate")),
  32. "The fps graph is still hidden if recording does not contain ticks.");
  33. yield startRecording(panel);
  34. yield stopRecording(panel);
  35. is(PerformanceController.getCurrentRecording().getConfiguration().withTicks, true,
  36. "PerformanceFront started with ticks recording.");
  37. ok(isVisible($("#time-framerate")),
  38. "The fps graph is not hidden when ticks enabled before recording.");
  39. yield teardownToolboxAndRemoveTab(panel);
  40. });