browser_perf-telemetry-03.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 performance telemetry module records events at appropriate times.
  6. * Specifically the destruction of certain views.
  7. */
  8. const { SIMPLE_URL } = require("devtools/client/performance/test/helpers/urls");
  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 {
  18. EVENTS,
  19. PerformanceController,
  20. DetailsView,
  21. JsCallTreeView,
  22. JsFlameGraphView
  23. } = panel.panelWin;
  24. let telemetry = PerformanceController._telemetry;
  25. let logs = telemetry.getLogs();
  26. let VIEWS = "DEVTOOLS_PERFTOOLS_SELECTED_VIEW_MS";
  27. yield startRecording(panel);
  28. yield stopRecording(panel);
  29. let calltreeRendered = once(JsCallTreeView, EVENTS.UI_JS_CALL_TREE_RENDERED);
  30. let flamegraphRendered = once(JsFlameGraphView, EVENTS.UI_JS_FLAMEGRAPH_RENDERED);
  31. // Go through some views to check later.
  32. yield DetailsView.selectView("js-calltree");
  33. yield calltreeRendered;
  34. yield DetailsView.selectView("js-flamegraph");
  35. yield flamegraphRendered;
  36. yield teardownToolboxAndRemoveTab(panel);
  37. // Check views after destruction to ensure `js-flamegraph` gets called
  38. // with a time during destruction.
  39. ok(logs[VIEWS].find(r => r[0] === "waterfall" && typeof r[1] === "number"),
  40. `${VIEWS} for waterfall view and time.`);
  41. ok(logs[VIEWS].find(r => r[0] === "js-calltree" && typeof r[1] === "number"),
  42. `${VIEWS} for js-calltree view and time.`);
  43. ok(logs[VIEWS].find(r => r[0] === "js-flamegraph" && typeof r[1] === "number"),
  44. `${VIEWS} for js-flamegraph view and time.`);
  45. });