Verified Commit 9dc8507f authored by ma1's avatar ma1
Browse files

TB 44591: Force extensions initialization on startup.

parent 22db4d45
Loading
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.async
import kotlinx.coroutines.launch
import mozilla.appservices.autofill.AutofillApiException
import mozilla.components.browser.engine.gecko.GeckoEngine
import mozilla.components.browser.state.action.SystemAction
import mozilla.components.browser.state.selector.selectedTab
import mozilla.components.browser.state.store.BrowserStore
@@ -702,6 +703,20 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
                    components.useCases.tabsUseCases.selectTab(sessionId)
                },
                onExtensionsLoaded = { extensions ->

                    // temp fix for tb#44591 "fails to initialize WebExtensions"
                    // disable and enable each extension to properly initialize them
                    extensions.forEach { extension ->
                        if (extension.isEnabled()) {
                          (components.core.engine as GeckoEngine).disableWebExtension(
                              extension,
                              onSuccess = {
                                  (components.core.engine as GeckoEngine).enableWebExtension(extension)
                              },
                          )
                        }
                    }

                    // Delay until bootstrap is finished so that it will actually update tor-browser#44303
                    components.torController.registerRunOnceBootstrapped(object : RunOnceBootstrapped {
                        override fun onBootstrapped() {