browser_perf-overview-render-03.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 overview graphs share the exact same width and scaling.
  6. */
  7. const { SIMPLE_URL } = require("devtools/client/performance/test/helpers/urls");
  8. const { UI_ENABLE_MEMORY_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 { waitUntil } = require("devtools/client/performance/test/helpers/wait-utils");
  12. add_task(function* () {
  13. let { panel } = yield initPerformanceInNewTab({
  14. url: SIMPLE_URL,
  15. win: window
  16. });
  17. let { PerformanceController, OverviewView } = panel.panelWin;
  18. // Enable memory to test.
  19. Services.prefs.setBoolPref(UI_ENABLE_MEMORY_PREF, true);
  20. let doChecks = () => {
  21. let markers = OverviewView.graphs.get("timeline");
  22. let framerate = OverviewView.graphs.get("framerate");
  23. let memory = OverviewView.graphs.get("memory");
  24. ok(markers.width > 0,
  25. "The overview's markers graph has a width.");
  26. ok(markers.dataScaleX > 0,
  27. "The overview's markers graph has a data scale factor.");
  28. ok(memory.width > 0,
  29. "The overview's memory graph has a width.");
  30. ok(memory.dataDuration > 0,
  31. "The overview's memory graph has a data duration.");
  32. ok(memory.dataScaleX > 0,
  33. "The overview's memory graph has a data scale factor.");
  34. ok(framerate.width > 0,
  35. "The overview's framerate graph has a width.");
  36. ok(framerate.dataDuration > 0,
  37. "The overview's framerate graph has a data duration.");
  38. ok(framerate.dataScaleX > 0,
  39. "The overview's framerate graph has a data scale factor.");
  40. is(markers.width, memory.width,
  41. "The markers and memory graphs widths are the same.");
  42. is(markers.width, framerate.width,
  43. "The markers and framerate graphs widths are the same.");
  44. is(memory.dataDuration, framerate.dataDuration,
  45. "The memory and framerate graphs data duration are the same.");
  46. is(markers.dataScaleX, memory.dataScaleX,
  47. "The markers and memory graphs data scale are the same.");
  48. is(markers.dataScaleX, framerate.dataScaleX,
  49. "The markers and framerate graphs data scale are the same.");
  50. };
  51. yield startRecording(panel);
  52. doChecks();
  53. yield waitUntil(() => PerformanceController.getCurrentRecording().getMarkers().length);
  54. yield waitUntil(() => PerformanceController.getCurrentRecording().getMemory().length);
  55. yield waitUntil(() => PerformanceController.getCurrentRecording().getTicks().length);
  56. doChecks();
  57. yield stopRecording(panel);
  58. doChecks();
  59. yield teardownToolboxAndRemoveTab(panel);
  60. });