summaryrefslogtreecommitdiffstats
path: root/devtools/server/tests/browser/browser_perf-profiler-03.js
blob: 8550fea83212a0714f71dfb6d17b065299f4c9e3 (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
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

/**
 * Tests if the built-in profiler module is not reactivated if no other
 * consumer was using it over the remote debugger protocol, and ensures
 * that the actor will work properly even in such cases (e.g. the Gecko Profiler
 * addon was installed and automatically activated the profiler module).
 */

"use strict";

const {
  pmmIsProfilerActive,
  pmmStartProfiler,
  pmmInitWithBrowser,
} = require("devtools/client/performance/test/helpers/profiler-mm-utils");

add_task(async function() {
  // Ensure the profiler is already running when the test starts.
  pmmInitWithBrowser(gBrowser);
  const entries = 1000000;
  const interval = 1;
  const features = ["js"];
  await pmmStartProfiler({ entries, interval, features });

  ok(
    await pmmIsProfilerActive(),
    "The built-in profiler module should still be active."
  );

  const target1 = await addTabTarget(MAIN_DOMAIN + "doc_perf.html");
  const firstFront = await target1.getFront("performance");

  await firstFront.startRecording();

  const target2 = await addTabTarget(MAIN_DOMAIN + "doc_perf.html");
  const secondFront = await target2.getFront("performance");
  await secondFront.connect();

  await target2.destroy();
  ok(
    await pmmIsProfilerActive(),
    "The built-in profiler module should still be active."
  );

  await target1.destroy();
  ok(
    !(await pmmIsProfilerActive()),
    "The built-in profiler module should have been automatically stopped."
  );

  gBrowser.removeCurrentTab();
  gBrowser.removeCurrentTab();
});