summaryrefslogtreecommitdiffstats
path: root/devtools/client/performance/test/browser_perf-states.js
blob: d55c24872c02de915a3cd3eb1b83d4ee37f583fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";

/**
 * Tests that view states and lazy component intialization works.
 */

const { SIMPLE_URL } = require("devtools/client/performance/test/helpers/urls");
const {
  UI_ENABLE_MEMORY_PREF,
  UI_ENABLE_ALLOCATIONS_PREF,
} = require("devtools/client/performance/test/helpers/prefs");
const {
  initPerformanceInNewTab,
  teardownToolboxAndRemoveTab,
} = require("devtools/client/performance/test/helpers/panel-utils");
const {
  startRecording,
  stopRecording,
} = require("devtools/client/performance/test/helpers/actions");

add_task(async function() {
  const { panel } = await initPerformanceInNewTab({
    url: SIMPLE_URL,
    win: window,
  });

  const { PerformanceView, OverviewView, DetailsView } = panel.panelWin;

  is(
    PerformanceView.getState(),
    "empty",
    "The intial state of the performance panel view is correct."
  );

  ok(
    !OverviewView.graphs.get("timeline"),
    "The markers graph should not have been created yet."
  );
  ok(
    !OverviewView.graphs.get("memory"),
    "The memory graph should not have been created yet."
  );
  ok(
    !OverviewView.graphs.get("framerate"),
    "The framerate graph should not have been created yet."
  );

  ok(
    !DetailsView.components.waterfall.initialized,
    "The waterfall detail view should not have been created yet."
  );
  ok(
    !DetailsView.components["js-calltree"].initialized,
    "The js-calltree detail view should not have been created yet."
  );
  ok(
    !DetailsView.components["js-flamegraph"].initialized,
    "The js-flamegraph detail view should not have been created yet."
  );
  ok(
    !DetailsView.components["memory-calltree"].initialized,
    "The memory-calltree detail view should not have been created yet."
  );
  ok(
    !DetailsView.components["memory-flamegraph"].initialized,
    "The memory-flamegraph detail view should not have been created yet."
  );

  Services.prefs.setBoolPref(UI_ENABLE_MEMORY_PREF, true);
  Services.prefs.setBoolPref(UI_ENABLE_ALLOCATIONS_PREF, true);

  ok(
    !OverviewView.graphs.get("timeline"),
    "The markers graph should still not have been created yet."
  );
  ok(
    !OverviewView.graphs.get("memory"),
    "The memory graph should still not have been created yet."
  );
  ok(
    !OverviewView.graphs.get("framerate"),
    "The framerate graph should still not have been created yet."
  );

  await startRecording(panel);

  is(
    PerformanceView.getState(),
    "recording",
    "The current state of the performance panel view is 'recording'."
  );
  ok(
    OverviewView.graphs.get("memory"),
    "The memory graph should have been created now."
  );
  ok(
    OverviewView.graphs.get("framerate"),
    "The framerate graph should have been created now."
  );

  await stopRecording(panel);

  is(
    PerformanceView.getState(),
    "recorded",
    "The current state of the performance panel view is 'recorded'."
  );
  ok(
    !DetailsView.components["js-calltree"].initialized,
    "The js-calltree detail view should still not have been created yet."
  );
  ok(
    !DetailsView.components["js-flamegraph"].initialized,
    "The js-flamegraph detail view should still not have been created yet."
  );
  ok(
    !DetailsView.components["memory-calltree"].initialized,
    "The memory-calltree detail view should still not have been created yet."
  );
  ok(
    !DetailsView.components["memory-flamegraph"].initialized,
    "The memory-flamegraph detail view should still not have been created yet."
  );

  await DetailsView.selectView("js-calltree");

  is(
    PerformanceView.getState(),
    "recorded",
    "The current state of the performance panel view is still 'recorded'."
  );
  ok(
    DetailsView.components["js-calltree"].initialized,
    "The js-calltree detail view should still have been created now."
  );
  ok(
    !DetailsView.components["js-flamegraph"].initialized,
    "The js-flamegraph detail view should still not have been created yet."
  );
  ok(
    !DetailsView.components["memory-calltree"].initialized,
    "The memory-calltree detail view should still not have been created yet."
  );
  ok(
    !DetailsView.components["memory-flamegraph"].initialized,
    "The memory-flamegraph detail view should still not have been created yet."
  );

  await DetailsView.selectView("memory-calltree");

  is(
    PerformanceView.getState(),
    "recorded",
    "The current state of the performance panel view is still 'recorded'."
  );
  ok(
    DetailsView.components["js-calltree"].initialized,
    "The js-calltree detail view should still register as being created."
  );
  ok(
    !DetailsView.components["js-flamegraph"].initialized,
    "The js-flamegraph detail view should still not have been created yet."
  );
  ok(
    DetailsView.components["memory-calltree"].initialized,
    "The memory-calltree detail view should still have been created now."
  );
  ok(
    !DetailsView.components["memory-flamegraph"].initialized,
    "The memory-flamegraph detail view should still not have been created yet."
  );

  await teardownToolboxAndRemoveTab(panel);
});