summaryrefslogtreecommitdiffstats
path: root/devtools/client/performance-new/test/browser/browser_aboutprofiling-presets-custom.js
blob: 07680d7496b4ff3d8c3b00e759bf65a0baa896e1 (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
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

"use strict";

add_task(async function test() {
  info(
    "Test that about:profiling presets override the individual settings when changed."
  );
  const supportedFeatures = Services.profiler.GetFeatures();

  if (!supportedFeatures.includes("stackwalk")) {
    ok(true, "This platform does not support stackwalking, skip this test.");
    return;
  }
  // This test assumes that the Web Developer preset is set by default, which is
  // not the case on Nightly and custom builds.
  BackgroundJSM.changePreset(
    "aboutprofiling",
    "web-developer",
    supportedFeatures
  );

  await withAboutProfiling(async document => {
    const webdevPreset = await getNearestInputFromText(
      document,
      "Web Developer"
    );
    const customPreset = await getNearestInputFromText(document, "Custom");
    const stackwalkFeature = await getNearestInputFromText(
      document,
      "Native Stacks"
    );
    const geckoMainThread = await getNearestInputFromText(
      document,
      "GeckoMain"
    );

    {
      info("Check the defaults on the about:profiling page.");
      ok(
        webdevPreset.checked,
        "By default the Web Developer preset is checked."
      );
      ok(!customPreset.checked, "By default the custom preset is not checked.");
      ok(
        !stackwalkFeature.checked,
        "Stack walking is not enabled for Web Developer."
      );
      ok(
        !activeConfigurationHasFeature("stackwalk"),
        "Stack walking is not in the active configuration."
      );
      ok(
        geckoMainThread.checked,
        "The GeckoMain thread is tracked for the Web Developer preset"
      );
      ok(
        activeConfigurationHasThread("GeckoMain"),
        "The GeckoMain thread is in the active configuration."
      );
    }

    {
      info("Change some settings, which will move the preset over to Custom.");

      info("Click stack walking.");
      stackwalkFeature.click();

      info("Click the GeckoMain thread.");
      geckoMainThread.click();
    }

    {
      info("Check that the various settings were actually updated in the UI.");
      ok(
        !webdevPreset.checked,
        "The Web Developer preset is no longer enabled."
      );
      ok(customPreset.checked, "The Custom preset is now checked.");
      ok(stackwalkFeature.checked, "Stack walking was enabled");
      ok(
        activeConfigurationHasFeature("stackwalk"),
        "Stack walking is in the active configuration."
      );
      ok(
        !geckoMainThread.checked,
        "GeckoMain was removed from tracked threads."
      );
      ok(
        !activeConfigurationHasThread("GeckoMain"),
        "The GeckoMain thread is not in the active configuration."
      );
    }

    {
      info(
        "Click the Web Developer preset, which should revert the other settings."
      );
      webdevPreset.click();
    }

    {
      info(
        "Now verify that everything was reverted back to the original settings."
      );
      ok(webdevPreset.checked, "The Web Developer preset is checked again.");
      ok(!customPreset.checked, "The custom preset is not checked.");
      ok(
        !stackwalkFeature.checked,
        "Stack walking is reverted for the Web Developer preset."
      );
      ok(
        !activeConfigurationHasFeature("stackwalk"),
        "Stack walking is not in the active configuration."
      );
      ok(
        geckoMainThread.checked,
        "GeckoMain was added back to the tracked threads."
      );
      ok(
        activeConfigurationHasThread("GeckoMain"),
        "The GeckoMain thread is in the active configuration."
      );
    }
  });
});