browser_perf-range-changed-render.js 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 detail views are rerendered after the range changes.
  6. */
  7. const { SIMPLE_URL } = require("devtools/client/performance/test/helpers/urls");
  8. const { initPerformanceInNewTab, teardownToolboxAndRemoveTab } = require("devtools/client/performance/test/helpers/panel-utils");
  9. const { startRecording, stopRecording } = require("devtools/client/performance/test/helpers/actions");
  10. const { once } = require("devtools/client/performance/test/helpers/event-utils");
  11. add_task(function* () {
  12. let { panel } = yield initPerformanceInNewTab({
  13. url: SIMPLE_URL,
  14. win: window
  15. });
  16. let {
  17. EVENTS,
  18. OverviewView,
  19. DetailsView,
  20. WaterfallView,
  21. JsCallTreeView,
  22. JsFlameGraphView
  23. } = panel.panelWin;
  24. let updatedWaterfall = 0;
  25. let updatedCallTree = 0;
  26. let updatedFlameGraph = 0;
  27. let updateWaterfall = () => updatedWaterfall++;
  28. let updateCallTree = () => updatedCallTree++;
  29. let updateFlameGraph = () => updatedFlameGraph++;
  30. WaterfallView.on(EVENTS.UI_WATERFALL_RENDERED, updateWaterfall);
  31. JsCallTreeView.on(EVENTS.UI_JS_CALL_TREE_RENDERED, updateCallTree);
  32. JsFlameGraphView.on(EVENTS.UI_JS_FLAMEGRAPH_RENDERED, updateFlameGraph);
  33. yield startRecording(panel);
  34. yield stopRecording(panel);
  35. let rendered = once(WaterfallView, EVENTS.UI_WATERFALL_RENDERED);
  36. OverviewView.emit(EVENTS.UI_OVERVIEW_RANGE_SELECTED, { startTime: 0, endTime: 10 });
  37. yield rendered;
  38. ok(true, "Waterfall rerenders when a range in the overview graph is selected.");
  39. rendered = once(JsCallTreeView, EVENTS.UI_JS_CALL_TREE_RENDERED);
  40. yield DetailsView.selectView("js-calltree");
  41. yield rendered;
  42. ok(true, "Call tree rerenders after its corresponding pane is shown.");
  43. rendered = once(JsFlameGraphView, EVENTS.UI_JS_FLAMEGRAPH_RENDERED);
  44. yield DetailsView.selectView("js-flamegraph");
  45. yield rendered;
  46. ok(true, "Flamegraph rerenders after its corresponding pane is shown.");
  47. rendered = once(JsFlameGraphView, EVENTS.UI_JS_FLAMEGRAPH_RENDERED);
  48. OverviewView.emit(EVENTS.UI_OVERVIEW_RANGE_SELECTED);
  49. yield rendered;
  50. ok(true, "Flamegraph rerenders when a range in the overview graph is removed.");
  51. rendered = once(JsCallTreeView, EVENTS.UI_JS_CALL_TREE_RENDERED);
  52. yield DetailsView.selectView("js-calltree");
  53. yield rendered;
  54. ok(true, "Call tree rerenders after its corresponding pane is shown.");
  55. rendered = once(WaterfallView, EVENTS.UI_WATERFALL_RENDERED);
  56. yield DetailsView.selectView("waterfall");
  57. yield rendered;
  58. ok(true, "Waterfall rerenders after its corresponding pane is shown.");
  59. is(updatedWaterfall, 3, "WaterfallView rerendered 3 times.");
  60. is(updatedCallTree, 2, "JsCallTreeView rerendered 2 times.");
  61. is(updatedFlameGraph, 2, "JsFlameGraphView rerendered 2 times.");
  62. WaterfallView.off(EVENTS.UI_WATERFALL_RENDERED, updateWaterfall);
  63. JsCallTreeView.off(EVENTS.UI_JS_CALL_TREE_RENDERED, updateCallTree);
  64. JsFlameGraphView.off(EVENTS.UI_JS_FLAMEGRAPH_RENDERED, updateFlameGraph);
  65. yield teardownToolboxAndRemoveTab(panel);
  66. });