diff -r 000000000000 -r 6474c204b198 browser/devtools/profiler/test/browser_profiler_controller.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/browser/devtools/profiler/test/browser_profiler_controller.js Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,64 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +const URL = "data:text/html;charset=utf8,
JavaScript Profiler test
"; + +let gTab, gPanel; + +function test() { + waitForExplicitFinish(); + + setUp(URL, function onSetUp(tab, browser, panel) { + gTab = tab; + gPanel = panel; + + testInactive(startFirstProfile); + }); +} + +function testInactive(next=function(){}) { + gPanel.controller.isActive(function (err, isActive) { + ok(!err, "isActive didn't return any errors"); + ok(!isActive, "Profiler is not active"); + next(); + }); +} + +function testActive(next=function(){}) { + gPanel.controller.isActive(function (err, isActive) { + ok(!err, "isActive didn't return any errors"); + ok(isActive, "Profiler is active"); + next(); + }); +} + +function startFirstProfile() { + gPanel.controller.start("Profile 1", function (err) { + ok(!err, "Profile 1 started without errors"); + testActive(startSecondProfile); + }); +} + +function startSecondProfile() { + gPanel.controller.start("Profile 2", function (err) { + ok(!err, "Profile 2 started without errors"); + testActive(stopFirstProfile); + }); +} + +function stopFirstProfile() { + gPanel.controller.stop("Profile 1", function (err, data) { + ok(!err, "Profile 1 stopped without errors"); + ok(data, "Profiler returned some data"); + + testActive(stopSecondProfile); + }); +} + +function stopSecondProfile() { + gPanel.controller.stop("Profile 2", function (err, data) { + ok(!err, "Profile 2 stopped without errors"); + ok(data, "Profiler returned some data"); + testInactive(tearDown.call(null, gTab, function () gTab = gPanel = null)); + }); +} \ No newline at end of file