tor-browser

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

commit 4af16768a4e9203739691a9b1768247dabb5e5f5
parent 65f795c3bcb08b74decb88651da4e45a1c2af94c
Author: Emma Zuehlcke <emz@mozilla.com>
Date:   Tue, 28 Oct 2025 16:13:28 +0000

Bug 1995259 - Extend do_get_profile to also dispatch profiler-after-change via category manager mechanism. r=manuel

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

Diffstat:
Mtesting/xpcshell/head.js | 25+++++++++++++++++++++++++
1 file changed, 25 insertions(+), 0 deletions(-)

diff --git a/testing/xpcshell/head.js b/testing/xpcshell/head.js @@ -1427,6 +1427,31 @@ function do_get_profile(notifyProfileAfterChange = false) { "profile-after-change", "xpcshell-do-get-profile" ); + + // The "profile-after-change" dispatch above does not reach services that + // listen for the message via nsICategoryManager. These services register + // their observer via `components.conf`. The message for these services + // gets dispatched separately. So we have to do the same in testing. + + // TODO: Bug 1995259: Not all tests / services expect this behavior yet, + // use an allow-list to determine which services to initialize on + // synthetic PAC. + let filterServices = new Set([ + "@mozilla.org/profile-after-change-gate;1", + ]); + + for (let entry of Services.catMan.enumerateCategory( + "profile-after-change" + )) { + if (!filterServices.has(entry.value)) { + continue; + } + try { + Cc[entry.value] + ?.getService(Ci.nsIObserver) + ?.observe(null, "profile-after-change", ""); + } catch (e) {} + } } }