|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 const URL = "data:text/html;charset=utf8,<p>JavaScript Profiler test</p>"; |
|
5 |
|
6 let gTab, gPanel; |
|
7 |
|
8 function test() { |
|
9 waitForExplicitFinish(); |
|
10 |
|
11 setUp(URL, function onSetUp(tab, browser, panel) { |
|
12 gTab = tab; |
|
13 gPanel = panel; |
|
14 |
|
15 testInactive(startFirstProfile); |
|
16 }); |
|
17 } |
|
18 |
|
19 function testInactive(next=function(){}) { |
|
20 gPanel.controller.isActive(function (err, isActive) { |
|
21 ok(!err, "isActive didn't return any errors"); |
|
22 ok(!isActive, "Profiler is not active"); |
|
23 next(); |
|
24 }); |
|
25 } |
|
26 |
|
27 function testActive(next=function(){}) { |
|
28 gPanel.controller.isActive(function (err, isActive) { |
|
29 ok(!err, "isActive didn't return any errors"); |
|
30 ok(isActive, "Profiler is active"); |
|
31 next(); |
|
32 }); |
|
33 } |
|
34 |
|
35 function startFirstProfile() { |
|
36 gPanel.controller.start("Profile 1", function (err) { |
|
37 ok(!err, "Profile 1 started without errors"); |
|
38 testActive(startSecondProfile); |
|
39 }); |
|
40 } |
|
41 |
|
42 function startSecondProfile() { |
|
43 gPanel.controller.start("Profile 2", function (err) { |
|
44 ok(!err, "Profile 2 started without errors"); |
|
45 testActive(stopFirstProfile); |
|
46 }); |
|
47 } |
|
48 |
|
49 function stopFirstProfile() { |
|
50 gPanel.controller.stop("Profile 1", function (err, data) { |
|
51 ok(!err, "Profile 1 stopped without errors"); |
|
52 ok(data, "Profiler returned some data"); |
|
53 |
|
54 testActive(stopSecondProfile); |
|
55 }); |
|
56 } |
|
57 |
|
58 function stopSecondProfile() { |
|
59 gPanel.controller.stop("Profile 2", function (err, data) { |
|
60 ok(!err, "Profile 2 stopped without errors"); |
|
61 ok(data, "Profiler returned some data"); |
|
62 testInactive(tearDown.call(null, gTab, function () gTab = gPanel = null)); |
|
63 }); |
|
64 } |