Open Bug 1968071 Opened 1 year ago Updated 1 year ago

Cannot import ProfilesDatastoreService in xpcshell tests without initializing the nsIToolkitProfileService

Categories

(Toolkit :: Startup and Profile System, defect)

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.

Severity: -- → S3

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?

Flags: needinfo?(brennie)
You need to log in before you can comment on or make changes to this bug.