Verified Commit e299491f authored by ma1's avatar ma1
Browse files

TB 44591: Force extensions initialization on startup.

parent 9d27d854
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import mozilla.appservices.autofill.AutofillApiException
import mozilla.components.ExperimentalAndroidComponentsApi
import mozilla.components.browser.engine.gecko.GeckoEngine
import mozilla.components.browser.state.action.SearchAction.SearchConfigurationAvailabilityChanged
import mozilla.components.browser.state.action.SystemAction
import mozilla.components.browser.state.selector.selectedTab
@@ -893,6 +894,7 @@ open class FenixApplication : Application(), Provider, ThemeProvider {
                    components.useCases.tabsUseCases.selectTab(sessionId)
                },
                onExtensionsLoaded = { extensions ->

                    // enable noscript if it is disabled
                    extensions.find { extension : WebExtension ->
                        extension.id == NOSCRIPT_ID
@@ -902,6 +904,19 @@ open class FenixApplication : Application(), Provider, ThemeProvider {
                        }
                    }

                    // 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() {