1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/profiler/test/browser_profiler_controller.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,64 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +const URL = "data:text/html;charset=utf8,<p>JavaScript Profiler test</p>"; 1.8 + 1.9 +let gTab, gPanel; 1.10 + 1.11 +function test() { 1.12 + waitForExplicitFinish(); 1.13 + 1.14 + setUp(URL, function onSetUp(tab, browser, panel) { 1.15 + gTab = tab; 1.16 + gPanel = panel; 1.17 + 1.18 + testInactive(startFirstProfile); 1.19 + }); 1.20 +} 1.21 + 1.22 +function testInactive(next=function(){}) { 1.23 + gPanel.controller.isActive(function (err, isActive) { 1.24 + ok(!err, "isActive didn't return any errors"); 1.25 + ok(!isActive, "Profiler is not active"); 1.26 + next(); 1.27 + }); 1.28 +} 1.29 + 1.30 +function testActive(next=function(){}) { 1.31 + gPanel.controller.isActive(function (err, isActive) { 1.32 + ok(!err, "isActive didn't return any errors"); 1.33 + ok(isActive, "Profiler is active"); 1.34 + next(); 1.35 + }); 1.36 +} 1.37 + 1.38 +function startFirstProfile() { 1.39 + gPanel.controller.start("Profile 1", function (err) { 1.40 + ok(!err, "Profile 1 started without errors"); 1.41 + testActive(startSecondProfile); 1.42 + }); 1.43 +} 1.44 + 1.45 +function startSecondProfile() { 1.46 + gPanel.controller.start("Profile 2", function (err) { 1.47 + ok(!err, "Profile 2 started without errors"); 1.48 + testActive(stopFirstProfile); 1.49 + }); 1.50 +} 1.51 + 1.52 +function stopFirstProfile() { 1.53 + gPanel.controller.stop("Profile 1", function (err, data) { 1.54 + ok(!err, "Profile 1 stopped without errors"); 1.55 + ok(data, "Profiler returned some data"); 1.56 + 1.57 + testActive(stopSecondProfile); 1.58 + }); 1.59 +} 1.60 + 1.61 +function stopSecondProfile() { 1.62 + gPanel.controller.stop("Profile 2", function (err, data) { 1.63 + ok(!err, "Profile 2 stopped without errors"); 1.64 + ok(data, "Profiler returned some data"); 1.65 + testInactive(tearDown.call(null, gTab, function () gTab = gPanel = null)); 1.66 + }); 1.67 +} 1.68 \ No newline at end of file