1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 Assert
.ok(!Services
.profiler
.IsActive());
7 Assert
.ok(!Services
.profiler
.IsPaused());
9 let startPromise
= Services
.profiler
.StartProfiler(1000, 10, []);
11 // Default: Active and not paused.
12 Assert
.ok(Services
.profiler
.IsActive());
13 Assert
.ok(!Services
.profiler
.IsPaused());
14 Assert
.ok(!Services
.profiler
.IsSamplingPaused());
17 Assert
.ok(Services
.profiler
.IsActive());
18 Assert
.ok(!Services
.profiler
.IsPaused());
19 Assert
.ok(!Services
.profiler
.IsSamplingPaused());
21 // Pause everything, implicitly pauses sampling.
22 let pausePromise
= Services
.profiler
.Pause();
24 Assert
.ok(Services
.profiler
.IsActive());
25 Assert
.ok(Services
.profiler
.IsPaused());
26 Assert
.ok(Services
.profiler
.IsSamplingPaused());
29 Assert
.ok(Services
.profiler
.IsActive());
30 Assert
.ok(Services
.profiler
.IsPaused());
31 Assert
.ok(Services
.profiler
.IsSamplingPaused());
33 // While fully paused, pause and resume sampling only, no expected changes.
34 let pauseSamplingPromise
= Services
.profiler
.PauseSampling();
36 Assert
.ok(Services
.profiler
.IsActive());
37 Assert
.ok(Services
.profiler
.IsPaused());
38 Assert
.ok(Services
.profiler
.IsSamplingPaused());
40 await pauseSamplingPromise
;
41 Assert
.ok(Services
.profiler
.IsActive());
42 Assert
.ok(Services
.profiler
.IsPaused());
43 Assert
.ok(Services
.profiler
.IsSamplingPaused());
45 let resumeSamplingPromise
= Services
.profiler
.ResumeSampling();
47 Assert
.ok(Services
.profiler
.IsActive());
48 Assert
.ok(Services
.profiler
.IsPaused());
49 Assert
.ok(Services
.profiler
.IsSamplingPaused());
51 await resumeSamplingPromise
;
52 Assert
.ok(Services
.profiler
.IsActive());
53 Assert
.ok(Services
.profiler
.IsPaused());
54 Assert
.ok(Services
.profiler
.IsSamplingPaused());
57 let resumePromise
= Services
.profiler
.Resume();
59 Assert
.ok(Services
.profiler
.IsActive());
60 Assert
.ok(!Services
.profiler
.IsPaused());
61 Assert
.ok(!Services
.profiler
.IsSamplingPaused());
64 Assert
.ok(Services
.profiler
.IsActive());
65 Assert
.ok(!Services
.profiler
.IsPaused());
66 Assert
.ok(!Services
.profiler
.IsSamplingPaused());
68 // Pause sampling only.
69 let pauseSampling2Promise
= Services
.profiler
.PauseSampling();
71 Assert
.ok(Services
.profiler
.IsActive());
72 Assert
.ok(!Services
.profiler
.IsPaused());
73 Assert
.ok(Services
.profiler
.IsSamplingPaused());
75 await pauseSampling2Promise
;
76 Assert
.ok(Services
.profiler
.IsActive());
77 Assert
.ok(!Services
.profiler
.IsPaused());
78 Assert
.ok(Services
.profiler
.IsSamplingPaused());
80 // While sampling is paused, pause everything.
81 let pause2Promise
= Services
.profiler
.Pause();
83 Assert
.ok(Services
.profiler
.IsActive());
84 Assert
.ok(Services
.profiler
.IsPaused());
85 Assert
.ok(Services
.profiler
.IsSamplingPaused());
88 Assert
.ok(Services
.profiler
.IsActive());
89 Assert
.ok(Services
.profiler
.IsPaused());
90 Assert
.ok(Services
.profiler
.IsSamplingPaused());
92 // Resume, but sampling is still paused separately.
93 let resume2promise
= Services
.profiler
.Resume();
95 Assert
.ok(Services
.profiler
.IsActive());
96 Assert
.ok(!Services
.profiler
.IsPaused());
97 Assert
.ok(Services
.profiler
.IsSamplingPaused());
100 Assert
.ok(Services
.profiler
.IsActive());
101 Assert
.ok(!Services
.profiler
.IsPaused());
102 Assert
.ok(Services
.profiler
.IsSamplingPaused());
104 // Resume sampling only.
105 let resumeSampling2Promise
= Services
.profiler
.ResumeSampling();
107 Assert
.ok(Services
.profiler
.IsActive());
108 Assert
.ok(!Services
.profiler
.IsPaused());
109 Assert
.ok(!Services
.profiler
.IsSamplingPaused());
111 await resumeSampling2Promise
;
112 Assert
.ok(Services
.profiler
.IsActive());
113 Assert
.ok(!Services
.profiler
.IsPaused());
114 Assert
.ok(!Services
.profiler
.IsSamplingPaused());
116 let stopPromise
= Services
.profiler
.StopProfiler();
117 Assert
.ok(!Services
.profiler
.IsActive());
118 // Stopping is not pausing.
119 Assert
.ok(!Services
.profiler
.IsPaused());
120 Assert
.ok(!Services
.profiler
.IsSamplingPaused());
123 Assert
.ok(!Services
.profiler
.IsActive());
124 Assert
.ok(!Services
.profiler
.IsPaused());
125 Assert
.ok(!Services
.profiler
.IsSamplingPaused());