tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 5aef6d80ebfb1c810edc1f285d4fc9ae882de92c
parent 9d8043b2b7b07928d14e97c93d637696d21d2c4a
Author: Nazım Can Altınova <canaltinova@gmail.com>
Date:   Tue,  9 Dec 2025 12:54:03 +0000

Bug 2004134 - Remove disabled test_start.js test and enable test_run.js after modifications r=florian,profiler-reviewers

Both of these tests were disabled for a long time (probably since they
were implemented).

It looks like test_start.js test is not very useful because we already
have a more comprehensive test that checks everything that it checks:
https://searchfox.org/firefox-main/rev/39bc83bb8632d54d70542dc5d98c046a317ec99d/tools/profiler/tests/xpcshell/test_pause.js

Since this test already checks everything, we don't really need
test_start.js, that's why this patch removes it.

On the other hand, test_run.js doesn't looks very important either. But
it looks like it's actually testing Services.profiler.GetProfile()
that's not being tested anywhere else at the moment. So, I think it
makes sense to keep it around to make sure that we don't regress it.

Differential Revision: https://phabricator.services.mozilla.com/D275236

Diffstat:
Atools/profiler/tests/xpcshell/test_get_profile.js | 30++++++++++++++++++++++++++++++
Dtools/profiler/tests/xpcshell/test_run.js | 37-------------------------------------
Dtools/profiler/tests/xpcshell/test_start.js | 21---------------------
Mtools/profiler/tests/xpcshell/xpcshell.toml | 15+++++----------
4 files changed, 35 insertions(+), 68 deletions(-)

diff --git a/tools/profiler/tests/xpcshell/test_get_profile.js b/tools/profiler/tests/xpcshell/test_get_profile.js @@ -0,0 +1,30 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// Test Services.profiler.GetProfile() and Services.profiler.getProfileData(). +add_task(async () => { + Assert.ok(!Services.profiler.IsActive()); + + await Services.profiler.StartProfiler(100, 10, []); + + Assert.ok(Services.profiler.IsActive()); + + await new Promise(resolve => do_timeout(100, resolve)); + + // Check text profile format + var profileStr = Services.profiler.GetProfile(); + Assert.greater(profileStr.length, 10); + + // check json profile format + var profileObj = Services.profiler.getProfileData(); + Assert.notEqual(profileObj, null); + Assert.notEqual(profileObj.threads, null); + Assert.greaterOrEqual(profileObj.threads.length, 1); + Assert.notEqual(profileObj.threads[0].samples, null); + // NOTE: The number of samples will be empty since we + // don't have any labels in the xpcshell code + + await Services.profiler.StopProfiler(); + Assert.ok(!Services.profiler.IsActive()); +}); diff --git a/tools/profiler/tests/xpcshell/test_run.js b/tools/profiler/tests/xpcshell/test_run.js @@ -1,37 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -function run_test() { - Assert.ok(!Services.profiler.IsActive()); - - Services.profiler.StartProfiler(1000, 10, []); - - Assert.ok(Services.profiler.IsActive()); - - do_test_pending(); - - do_timeout(1000, function wait() { - // Check text profile format - var profileStr = Services.profiler.GetProfile(); - Assert.greater(profileStr.length, 10); - - // check json profile format - var profileObj = Services.profiler.getProfileData(); - Assert.notEqual(profileObj, null); - Assert.notEqual(profileObj.threads, null); - // We capture memory counters by default only when jemalloc is turned - // on (and it isn't for ASAN), so unless we can conditionalize for ASAN - // here we can't check that we're capturing memory counter data. - Assert.notEqual(profileObj.counters, null); - Assert.notEqual(profileObj.memory, null); - Assert.greaterOrEqual(profileObj.threads.length, 1); - Assert.notEqual(profileObj.threads[0].samples, null); - // NOTE: The number of samples will be empty since we - // don't have any labels in the xpcshell code - - Services.profiler.StopProfiler(); - Assert.ok(!Services.profiler.IsActive()); - do_test_finished(); - }); -} diff --git a/tools/profiler/tests/xpcshell/test_start.js b/tools/profiler/tests/xpcshell/test_start.js @@ -1,21 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -add_task(async () => { - Assert.ok(!Services.profiler.IsActive()); - - let startPromise = Services.profiler.StartProfiler(10, 100, []); - - Assert.ok(Services.profiler.IsActive()); - - await startPromise; - Assert.ok(Services.profiler.IsActive()); - - let stopPromise = Services.profiler.StopProfiler(); - - Assert.ok(!Services.profiler.IsActive()); - - await stopPromise; - Assert.ok(!Services.profiler.IsActive()); -}); diff --git a/tools/profiler/tests/xpcshell/xpcshell.toml b/tools/profiler/tests/xpcshell/xpcshell.toml @@ -111,6 +111,11 @@ skip-if = [ ["test_get_features.js"] +["test_get_profile.js"] +skip-if = [ + "tsan", # Times out on TSan, bug 1612707 +] + ["test_marker_jit_sourceindex.js"] ["test_merged_stacks.js"] @@ -135,14 +140,4 @@ skip-if = [ "tsan", # Times out on TSan, bug 1612707 ] -["test_run.js"] -run-if = [ - "false", -] - ["test_shared_library.js"] - -["test_start.js"] -run-if = [ - "false", -]