summaryrefslogtreecommitdiffstats
path: root/devtools/client/performance/test/browser_perf-recording-selected-04.js
blob: 014ef5bddb2b0c360d84804f9ca897107f42dd6f (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
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";

/**
 * Tests that all components can get rerendered for a profile when switching.
 */

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, waitForAllWidgetsRendered } = require("devtools/client/performance/test/helpers/actions");
const { setSelectedRecording } = require("devtools/client/performance/test/helpers/recording-utils");

add_task(function* () {
  let { panel } = yield initPerformanceInNewTab({
    url: SIMPLE_URL,
    win: window
  });

  let { DetailsView, DetailsSubview } = panel.panelWin;

  // Enable memory to test the memory overview.
  Services.prefs.setBoolPref(UI_ENABLE_MEMORY_PREF, true);

  // Enable allocations to test the memory-calltree and memory-flamegraph.
  Services.prefs.setBoolPref(UI_ENABLE_ALLOCATIONS_PREF, true);

  yield startRecording(panel);
  yield stopRecording(panel);

  // Ållow widgets to be updated while hidden, to make testing easier.
  DetailsSubview.canUpdateWhileHidden = true;

  // Cycle through all the views to initialize them. The waterfall is shown
  // by default, but all the other views are created lazily, so won't emit
  // any events.
  yield DetailsView.selectView("js-calltree");
  yield DetailsView.selectView("js-flamegraph");
  yield DetailsView.selectView("memory-calltree");
  yield DetailsView.selectView("memory-flamegraph");

  yield startRecording(panel);
  yield stopRecording(panel);

  let rerender = waitForAllWidgetsRendered(panel);
  setSelectedRecording(panel, 0);
  yield rerender;

  ok(true, "All widgets were rendered when selecting the first recording.");

  rerender = waitForAllWidgetsRendered(panel);
  setSelectedRecording(panel, 1);
  yield rerender;

  ok(true, "All widgets were rendered when selecting the second recording.");

  yield teardownToolboxAndRemoveTab(panel);
});