summaryrefslogtreecommitdiff
path: root/browser/devtools/profiler/test/browser_profiler_shared-front-04.js
blob: f3f6be6f5786d1e0673623f1e62f09d73e82c480 (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
/* 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).
 */

let test = Task.async(function*() {
  // Ensure the profiler is already running when the test starts.
  let ENTRIES = 1000000;
  let INTERVAL = 1;
  let FEATURES = ["js"];
  nsIProfilerModule.StartProfiler(ENTRIES, INTERVAL, FEATURES, FEATURES.length);

  let [,, firstPanel] = yield initFrontend(SIMPLE_URL);
  let firstFront = firstPanel.panelWin.gFront;

  let alredyActive = firstFront.once("profiler-already-active");
  yield firstFront.startRecording();
  yield alredyActive;
  ok(firstFront._profilingStartTime > 0, "The profiler was not restarted.");

  let [,, secondPanel] = yield initFrontend(SIMPLE_URL);
  let secondFront = secondPanel.panelWin.gFront;

  let alreadyActive = secondFront.once("profiler-already-active");
  yield secondFront.startRecording();
  yield alreadyActive;
  ok(secondFront._profilingStartTime > 0, "The profiler was not restarted.");

  yield teardown(firstPanel);
  ok(nsIProfilerModule.IsActive(),
    "The built-in profiler module should still be active.");

  yield teardown(secondPanel);
  ok(!nsIProfilerModule.IsActive(),
    "The built-in profiler module should have been automatically stoped.");

  finish();
});