browser_perf-states.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. "use strict";
  4. /**
  5. * Tests that view states and lazy component intialization works.
  6. */
  7. const { SIMPLE_URL } = require("devtools/client/performance/test/helpers/urls");
  8. const { UI_ENABLE_MEMORY_PREF, UI_ENABLE_ALLOCATIONS_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. add_task(function* () {
  12. let { panel } = yield initPerformanceInNewTab({
  13. url: SIMPLE_URL,
  14. win: window
  15. });
  16. let { PerformanceView, OverviewView, DetailsView } = panel.panelWin;
  17. is(PerformanceView.getState(), "empty",
  18. "The intial state of the performance panel view is correct.");
  19. ok(!(OverviewView.graphs.get("timeline")),
  20. "The markers graph should not have been created yet.");
  21. ok(!(OverviewView.graphs.get("memory")),
  22. "The memory graph should not have been created yet.");
  23. ok(!(OverviewView.graphs.get("framerate")),
  24. "The framerate graph should not have been created yet.");
  25. ok(!DetailsView.components.waterfall.initialized,
  26. "The waterfall detail view should not have been created yet.");
  27. ok(!DetailsView.components["js-calltree"].initialized,
  28. "The js-calltree detail view should not have been created yet.");
  29. ok(!DetailsView.components["js-flamegraph"].initialized,
  30. "The js-flamegraph detail view should not have been created yet.");
  31. ok(!DetailsView.components["memory-calltree"].initialized,
  32. "The memory-calltree detail view should not have been created yet.");
  33. ok(!DetailsView.components["memory-flamegraph"].initialized,
  34. "The memory-flamegraph detail view should not have been created yet.");
  35. Services.prefs.setBoolPref(UI_ENABLE_MEMORY_PREF, true);
  36. Services.prefs.setBoolPref(UI_ENABLE_ALLOCATIONS_PREF, true);
  37. ok(!(OverviewView.graphs.get("timeline")),
  38. "The markers graph should still not have been created yet.");
  39. ok(!(OverviewView.graphs.get("memory")),
  40. "The memory graph should still not have been created yet.");
  41. ok(!(OverviewView.graphs.get("framerate")),
  42. "The framerate graph should still not have been created yet.");
  43. yield startRecording(panel);
  44. is(PerformanceView.getState(), "recording",
  45. "The current state of the performance panel view is 'recording'.");
  46. ok(OverviewView.graphs.get("memory"),
  47. "The memory graph should have been created now.");
  48. ok(OverviewView.graphs.get("framerate"),
  49. "The framerate graph should have been created now.");
  50. yield stopRecording(panel);
  51. is(PerformanceView.getState(), "recorded",
  52. "The current state of the performance panel view is 'recorded'.");
  53. ok(!DetailsView.components["js-calltree"].initialized,
  54. "The js-calltree detail view should still not have been created yet.");
  55. ok(!DetailsView.components["js-flamegraph"].initialized,
  56. "The js-flamegraph detail view should still not have been created yet.");
  57. ok(!DetailsView.components["memory-calltree"].initialized,
  58. "The memory-calltree detail view should still not have been created yet.");
  59. ok(!DetailsView.components["memory-flamegraph"].initialized,
  60. "The memory-flamegraph detail view should still not have been created yet.");
  61. yield DetailsView.selectView("js-calltree");
  62. is(PerformanceView.getState(), "recorded",
  63. "The current state of the performance panel view is still 'recorded'.");
  64. ok(DetailsView.components["js-calltree"].initialized,
  65. "The js-calltree detail view should still have been created now.");
  66. ok(!DetailsView.components["js-flamegraph"].initialized,
  67. "The js-flamegraph detail view should still not have been created yet.");
  68. ok(!DetailsView.components["memory-calltree"].initialized,
  69. "The memory-calltree detail view should still not have been created yet.");
  70. ok(!DetailsView.components["memory-flamegraph"].initialized,
  71. "The memory-flamegraph detail view should still not have been created yet.");
  72. yield DetailsView.selectView("memory-calltree");
  73. is(PerformanceView.getState(), "recorded",
  74. "The current state of the performance panel view is still 'recorded'.");
  75. ok(DetailsView.components["js-calltree"].initialized,
  76. "The js-calltree detail view should still register as being created.");
  77. ok(!DetailsView.components["js-flamegraph"].initialized,
  78. "The js-flamegraph detail view should still not have been created yet.");
  79. ok(DetailsView.components["memory-calltree"].initialized,
  80. "The memory-calltree detail view should still have been created now.");
  81. ok(!DetailsView.components["memory-flamegraph"].initialized,
  82. "The memory-flamegraph detail view should still not have been created yet.");
  83. yield teardownToolboxAndRemoveTab(panel);
  84. });