Trying to clarify the problem, if you checkout https://phabricator.services.mozilla.com/D24142 (+ its deps) and run $ ./mach marionette-test browser/components/search/test/marionette/test_engines_on_restart.py --gecko-log - It should fail with: FAIL browser/components/search/test/marionette/test_engines_on_restart.py TestEnginesOnRestart.test_engines - AssertionError: 'google' != u'bing' The test opens Firefox, checks google is the default search engine, restarts firefox and checks that google is still the default search engine. I have annotated the log @ https://gist.github.com/daleharvey/396edddb2d8c8f2146ed0bb26344564c, the reason it fails is if I try to |AddonManager.installBuiltInAddon("resource://search-extensions/google")| when that extension has been previously installed, I get a broken extension object sent to addEnginesFromExtension. rawManifest is null at the point I try to call getLocalisedManifest and it crashes. To explain the problem at a higher level, when the ServiceService starts I have a list of engines "foo, bar", by the time SearchService.init() is complete I need to know the details for those engines, search_url=http://foo.org etc, currently the only way to get that information is being notified via addEnginesFromExtension. Now if I install a fresh extension it will call addEnginesFromExtension for me immediately, however as you can see if I call that on and engine that has been previously installed things break I could use AddonManager.getActiveAddons() to not reinstall previously installed addons, but then for SearchService.init to finish, it still needs to wait for addEnginesFromExtension to be called which as far as I understand requires loading the addons db which I believe there is an effort to be trying to delay that until as late as possible (ie the same issue with calling getAddonByID)
Bug 1534710 Comment 1 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
Trying to clarify the problem, if you checkout https://phabricator.services.mozilla.com/D24142 (+ its deps) and run $ ./mach marionette-test browser/components/search/test/marionette/test_engines_on_restart.py --gecko-log - It should fail with: FAIL browser/components/search/test/marionette/test_engines_on_restart.py TestEnginesOnRestart.test_engines - AssertionError: 'google' != u'bing' The test opens Firefox, checks google is the default search engine, restarts firefox and checks that google is still the default search engine. I have annotated the log @ https://gist.github.com/daleharvey/396edddb2d8c8f2146ed0bb26344564c, the reason it fails is if I try to |AddonManager.installBuiltInAddon("resource://search-extensions/google")| when that extension has been previously installed, I get a broken extension object sent to addEnginesFromExtension. rawManifest is null at the point I try to call getLocalisedManifest and it crashes. To explain the problem at a higher level, when the ServiceService starts I have a list of engines "foo, bar", by the time SearchService.init() is complete I need to know the details for those engines, search_url=http://foo.org etc, currently the only way to get that information is being notified via addEnginesFromExtension. Now if I install a fresh extension it will call addEnginesFromExtension for me immediately, however as you can see if I call that on and engine that has been previously installed things break I could use AddonManager.getActiveAddons() to not reinstall previously installed addons, but then for SearchService.init to finish, it still needs to wait for addEnginesFromExtension to be called which as far as I understand requires loading the addons db which I believe there is an effort to be trying to delay that until as late as possible (ie the same issue with calling getAddonByID) kmag proposed in IRC that it would be possible to ensure that addEnginesFromExtension would be guaranteed to be called for each installed search extension before SearchService.init could possibly be called, this means the data would be available for SearchService to init immediately