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