browser_perf-details-02-utility-fun.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 details view utility functions work as advertised.
  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. DetailsView,
  19. WaterfallView,
  20. JsCallTreeView,
  21. JsFlameGraphView
  22. } = panel.panelWin;
  23. yield startRecording(panel);
  24. yield stopRecording(panel);
  25. ok(DetailsView.isViewSelected(WaterfallView),
  26. "The waterfall view is selected by default in the details view.");
  27. // Select js calltree view.
  28. let selected = once(DetailsView, EVENTS.UI_DETAILS_VIEW_SELECTED);
  29. yield DetailsView.selectView("js-calltree");
  30. yield selected;
  31. ok(DetailsView.isViewSelected(JsCallTreeView),
  32. "The js calltree view is now selected in the details view.");
  33. // Select js flamegraph view.
  34. selected = once(DetailsView, EVENTS.UI_DETAILS_VIEW_SELECTED);
  35. yield DetailsView.selectView("js-flamegraph");
  36. yield selected;
  37. ok(DetailsView.isViewSelected(JsFlameGraphView),
  38. "The js flamegraph view is now selected in the details view.");
  39. // Select waterfall view.
  40. selected = once(DetailsView, EVENTS.UI_DETAILS_VIEW_SELECTED);
  41. yield DetailsView.selectView("waterfall");
  42. yield selected;
  43. ok(DetailsView.isViewSelected(WaterfallView),
  44. "The waterfall view is now selected in the details view.");
  45. yield teardownToolboxAndRemoveTab(panel);
  46. });