summaryrefslogtreecommitdiffstats
path: root/devtools/client/performance-new/test/browser/browser_aboutprofiling-env-restart-button.js
blob: 28ea3798a2e5da5d7734d5b9c5260f0817e94c67 (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
/* 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 the popup offers to restart the browser to set an enviroment flag."
  );

  if (!Services.profiler.GetFeatures().includes("jstracer")) {
    ok(
      true,
      "JS tracer is not supported on this platform, or is currently disabled. Skip the rest of the test."
    );
    return;
  }

  {
    info("Ensure that JS Tracer is not currently enabled.");
    ok(
      !Services.env.get("JS_TRACE_LOGGING"),
      "The JS_TRACE_LOGGING is not currently enabled."
    );
  }

  ok(
    false,
    "This test was migrated from the initial popup implementation to " +
      "about:profiling, however JS Tracer was disabled at the time. When " +
      "re-enabling JS Tracer, please audit that this text works as expected, " +
      "especially in the UI."
  );

  await withAboutProfiling(async document => {
    {
      info(
        "Test that there is offer to restart the browser when first loading up the popup."
      );
      const noRestartButton = maybeGetElementFromDocumentByText(
        document,
        "Restart"
      );
      ok(!noRestartButton, "There is no button to restart the browser.");
    }

    const jsTracerFeature = await getElementFromDocumentByText(
      document,
      "JSTracer"
    );

    {
      info("Toggle the jstracer feature on.");
      jsTracerFeature.click();

      const restartButton = await getElementFromDocumentByText(
        document,
        "Restart"
      );
      ok(
        restartButton,
        "There is now a button to offer to restart the browser"
      );
    }

    {
      info("Toggle the jstracer feature back off.");
      jsTracerFeature.click();

      const noRestartButton = maybeGetElementFromDocumentByText(
        document,
        "Restart"
      );
      ok(!noRestartButton, "The offer to restart the browser goes away.");
    }
  });
});