Cannot import ProfilesDatastoreService in xpcshell tests without initializing the nsIToolkitProfileService
Categories
(Toolkit :: Startup and Profile System, defect)
Tracking
()
People
(Reporter: beth, Unassigned)
References
Details
If you haven't done the necessary incantations in an xpcshell test to instantiate all the profile machinery, these lines in ProfilesDatastoreService will cause a crash (searchfox) trying to instantiate a nsIToolkitProfileService:
Hit MOZ_CRASH([Parent 11505, Main Thread] ###!!! ASSERTION: No dirserviceprovider!: 'gDirServiceProvider', file /builds/worker/checkouts/gecko/toolkit/profile/nsToolkitProfileService.cpp:972) at /builds/worker/checkouts/gecko/xpcom/base/nsDebugImpl.cpp:528
Which means you cant do something like if (lazy.ProfilesDatastoreService.initialized) in code that may or may not run in an xpcshell environment to try to work around the availability of the service.
The datastore service does need the toolkit service, for example, to decide whether the database is located inside the profile object or in the cross-profile location.
There is ProfilesDatastoreService.resetProfileService(aMockService) which is used to mock out the toolkit service object.
What specifically are you needing to solve here? Just a simpler setup process for getting a ProfilesDatastoreService in xpcshell tests?
| Reporter | ||
Comment 2•1 year ago
|
||
I want to remove these checks https://searchfox.org/mozilla-central/rev/60f924edfedc19cd16a30251053513c08bba149c/toolkit/components/nimbus/lib/ExperimentStore.sys.mjs#481-494
Fixing bug 1968069 also fixes this issue
Description
•