Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 const URL = "data:text/html;charset=utf8,<p>JavaScript Profiler test</p>";
6 let gTab, gPanel;
8 function test() {
9 waitForExplicitFinish();
11 setUp(URL, function onSetUp(tab, browser, panel) {
12 gTab = tab;
13 gPanel = panel;
15 testInactive(startFirstProfile);
16 });
17 }
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 }
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 }
35 function startFirstProfile() {
36 gPanel.controller.start("Profile 1", function (err) {
37 ok(!err, "Profile 1 started without errors");
38 testActive(startSecondProfile);
39 });
40 }
42 function startSecondProfile() {
43 gPanel.controller.start("Profile 2", function (err) {
44 ok(!err, "Profile 2 started without errors");
45 testActive(stopFirstProfile);
46 });
47 }
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");
54 testActive(stopSecondProfile);
55 });
56 }
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 }