Files
Florian Quèze f6a574996a Bug 2044390 - Make devtools tests pass with the Gecko profiler enabled by default, r=devtools-reviewers,ochameau.
With the profiler started by default during mochitests (MOZ_PROFILER_STARTUP=1),
opening the devtools performance panel reports a "recording" state, so closing
the toolbox makes ProfilerEventHandling.componentWillUnmount issue a
stopProfilerAndDiscardProfile request that races the connection teardown and
rejects. The toolbox tests don't use the profiler themselves, so they allow that
harmless rejection (see bug 2044383) and keep the profiler running. The
about:debugging profiler dialog test does drive the profiler, so it stops any
already-running profiler first via ProfilerTestUtils.assertProfilerInactive.

Differential Revision: https://phabricator.services.mozilla.com/D304133
2026-06-03 12:40:38 +00:00

45 lines
1.3 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const { PromiseTestUtils } = ChromeUtils.importESModule(
"resource://testing-common/PromiseTestUtils.sys.mjs"
);
// Closing the toolbox makes the performance panel try to stop the profiler;
// when it's already running (MOZ_PROFILER_STARTUP=1) that request races the
// connection teardown and rejects harmlessly. See bug 2044383.
PromiseTestUtils.allowMatchingRejectionsGlobally(
/Connection closed, pending request to .*stopProfilerAndDiscardProfile/
);
requestLongerTimeout(5);
async function performChecks(tab) {
let toolbox;
const toolIds = await getSupportedToolIds(tab);
for (const toolId of toolIds) {
info("About to open " + toolId);
toolbox = await gDevTools.showToolboxForTab(tab, { toolId });
ok(toolbox, "toolbox exists for " + toolId);
is(toolbox.currentToolId, toolId, "currentToolId should be " + toolId);
const panel = toolbox.getCurrentPanel();
ok(panel, toolId + " panel has been registered in the toolbox");
}
await toolbox.destroy();
}
function test() {
(async function () {
toggleAllTools(true);
const tab = await addTab("about:blank");
await performChecks(tab);
gBrowser.removeCurrentTab();
toggleAllTools(false);
finish();
})();
}