An intermittent timeout, nothing useful in the log, and a test that always passes locally: this used to mean days of try pushes and debug logging. This time, the profile that CI recorded for the failing test showed what was unusual about that run, and that was enough to make the test fail every time on my machine.
The symptom
The test's dashboard shows that browser_searchbar_addEngine.js timed out about 10% of the time on standalone jobs over the last 3 weeks:

The test opens a page offering search engines, clicks one of the "Add" buttons that the search bar then shows, and waits for the engine to be installed. The standalone jobs restart the browser before each test file, so each test runs in a freshly started browser. The log of a failure says this, and nothing else:
INFO - Entering test test_addEngine
INFO - TEST-PASS | browser/components/search/test/browser/browser_searchbar_addEngine.js | test_addEngine - All items are in addEngineList - 3 == 3
INFO - Waiting for engine to be installed.
INFO - TEST-FAIL | browser/components/search/test/browser/browser_searchbar_addEngine.js | test_addEngine - Test timed out
The test clicked the button and waited 45 seconds for an engine that never came.
Debugging, the old way
Locally, the test passed more than 20 times in a row: whatever happens on CI wasn't happening on my machine.
Without a local reproduction, the remaining options were to push to try with more logging, or to land the logging and wait for the next failures. The failure rate here was high enough to make try pushes usable, but each round takes hours, and the logging has to be decided in advance: guess wrong about what to log, and it's another round.
What installing an OpenSearch engine does
For security reasons, the XML description of an OpenSearch engine is processed in a hidden browser rather than in the parent process. parseInHiddenBrowser loads about:blank in that hidden browser, waits for a progress listener to report that the load finished, and then sends the XML to that page.
What the profiles show
For the last few months, mochitests have run with the profiler enabled, so when a test fails, its profile is uploaded as an artifact of the job (the log has a line saying profile uploaded in profile_browser_searchbar_addEngine.js.json.gz).
Here is the profile of one of the failing runs. Right after the test starts waiting for the engine, the markers show the hidden browser being set up: its invisible window, the <browser> element getting a content process, about:blank loading in that process, and the parent process being told that it loaded. And then nothing happens for 45 seconds, until the test times out.
For comparison, a profile of a passing run, recorded locally with ./mach mochitest --profiler, has the same sequence. Right after the test starts waiting and the same load event, the SendQuery that sends the XML to the hidden browser comes 0.1ms later. In the failing run, it never comes.
What was unusual
Zooming on the time between the load in the content process and the moment the parent process hears about it shows an orange GCMajor marker: a 41ms garbage collection, right there.

That's not a proof of anything: GCs happen all the time, and the profile can't show whether a JS object was collected. But it's a hint, and more importantly something to try.
From a hint to a perma-fail
Forcing a GC right after the hidden browser starts loading is a small change:
function widenForceGC() {
Cu.forceGC();
Cu.forceCC();
Cu.forceGC();
}
...
browser.loadURI(Services.io.newURI("about:blank"), { ... });
Services.tm.dispatchToMainThread(widenForceGC);
The function is defined at the top level of the module on purpose: any function created next to progressListener, arrow function or not, keeps that scope alive, and the listener with it.
The test then timed out every time, at exactly the same point as on CI. From there, I didn't need the profiler anymore: a failure that happens every time can be debugged like any other bug.
The fix
The web progress only holds weak references to its listeners, and nothing else referenced this one, so a GC before the load finished could collect it. The fix keeps a reference to the listener until its load finishes; with it, the test passes even with the forced GC. It landed on November 25th.
This probably only showed up on the standalone jobs because they run the test in a freshly started browser, where major GCs still happen soon after startup. But this wasn't only a test problem: for users, it meant that clicking "Add" to install a search engine could silently do nothing.
Summary
An intermittent failure with nothing in the log no longer means days of try pushes: the profile of a failed run is there, and often actionable. Looking at it shows exactly what happened, which can let us guess what was unusual in the failing run: a hint rather than a proof. Forcing the suspected condition made it fail locally, and from there it was a normal bug to fix.
