michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: function run_test() { michael@0: // If we can't get the profiler component then assume gecko was michael@0: // built without it and pass all the tests michael@0: var profilerCc = Cc["@mozilla.org/tools/profiler;1"]; michael@0: if (!profilerCc) michael@0: return; michael@0: michael@0: var profiler = Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler); michael@0: if (!profiler) michael@0: return; michael@0: michael@0: do_check_true(!profiler.IsActive()); michael@0: michael@0: profiler.StartProfiler(1000, 10, [], 0); michael@0: michael@0: do_check_true(profiler.IsActive()); michael@0: michael@0: do_test_pending(); michael@0: michael@0: do_timeout(1000, function wait() { michael@0: // Check responsiveness michael@0: var resp = profiler.GetResponsivenessTimes({}); michael@0: do_check_true(resp.length > 10); michael@0: michael@0: // Check text profile format michael@0: var profileStr = profiler.GetProfile(); michael@0: do_check_true(profileStr.length > 10); michael@0: michael@0: // check json profile format michael@0: var profileObj = profiler.getProfileData(); michael@0: do_check_neq(profileObj, null); michael@0: do_check_neq(profileObj.threads, null); michael@0: do_check_true(profileObj.threads.length >= 1); michael@0: do_check_neq(profileObj.threads[0].samples, null); michael@0: // NOTE: The number of samples will be empty since we michael@0: // don't have any labels in the xpcshell code michael@0: michael@0: profiler.StopProfiler(); michael@0: do_check_true(!profiler.IsActive()); michael@0: do_test_finished(); michael@0: }); michael@0: michael@0: michael@0: }