Loading components/browser/engine-gecko-nightly/src/main/java/mozilla/components/browser/engine/gecko/GeckoEngine.kt +0 −20 Original line number Diff line number Diff line Loading @@ -72,7 +72,6 @@ class GeckoEngine( ) : Engine, WebExtensionRuntime { private val executor by lazy { executorProvider.invoke() } private val localeUpdater = LocaleSettingUpdater(context, runtime) private val sharedPref = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE) @VisibleForTesting internal val speculativeConnectionFactory = SpeculativeSessionFactory() private var webExtensionDelegate: WebExtensionDelegate? = null private val webExtensionActionHandler = object : ActionHandler { Loading Loading @@ -331,23 +330,11 @@ class GeckoEngine( extension -> GeckoWebExtension(extension, runtime) } ?: emptyList() val privateBrowsingMigrated = sharedPref.getBoolean(MOZAC_HAS_RESET_WEBEXT_PRIVATE_BROWSING_DEFAULT, false) extensions.forEach { extension -> // As a workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=1621385, // we set all installed extensions to be allowed in private browsing mode. // We need to revert back to false which is now the default. if (!extension.isBuiltIn() && extension.isAllowedInPrivateBrowsing() && !privateBrowsingMigrated) { setAllowedInPrivateBrowsing(extension, false) } extension.registerActionHandler(webExtensionActionHandler) extension.registerTabHandler(webExtensionTabHandler) } if (!privateBrowsingMigrated) { sharedPref.edit().putBoolean(MOZAC_HAS_RESET_WEBEXT_PRIVATE_BROWSING_DEFAULT, true).apply() } onSuccess(extensions) GeckoResult<Void>() }, { throwable -> Loading Loading @@ -720,13 +707,6 @@ class GeckoEngine( cookiesHasBeenBlocked = cookiesHasBeenBlocked ) } companion object { private const val PREFERENCE_NAME = "MOZAC_GECKO_ENGINE" private const val MOZAC_HAS_RESET_WEBEXT_PRIVATE_BROWSING_DEFAULT = "MOZAC_HAS_RESET_WEBEXT_PRIVATE_BROWSING_DEFAULT" } } internal fun ContentBlockingController.LogEntry.BlockingData.hasBlockedCookies(): Boolean { Loading components/browser/engine-gecko-nightly/src/test/java/mozilla/components/browser/engine/gecko/GeckoEngineTest.kt +0 −43 Original line number Diff line number Diff line Loading @@ -1352,49 +1352,6 @@ class GeckoEngineTest { assertNotNull(extensions) } @Test fun `migrate private browsing default`() { val bundle = GeckoBundle() bundle.putString("webExtensionId", "id") bundle.putString("locationURI", "uri") val metaDataBundle = GeckoBundle() metaDataBundle.putBoolean("privateBrowsingAllowed", true) metaDataBundle.putStringArray("disabledFlags", emptyArray()) bundle.putBundle("metaData", metaDataBundle) val installedExtension = MockWebExtension(bundle) val installedExtensions = listOf<GeckoWebExtension>(installedExtension) val installedExtensionResult = GeckoResult<List<GeckoWebExtension>>() val runtime = mock<GeckoRuntime>() val extensionController: WebExtensionController = mock() whenever(extensionController.list()).thenReturn(installedExtensionResult) whenever(runtime.webExtensionController).thenReturn(extensionController) val allowedInPrivateBrowsingExtensionResult = GeckoResult<GeckoWebExtension>() whenever(extensionController.setAllowedInPrivateBrowsing(any(), anyBoolean())).thenReturn(allowedInPrivateBrowsingExtensionResult) val engine = spy(GeckoEngine(testContext, runtime = runtime)) var extensions: List<WebExtension>? = null var onErrorCalled = false engine.listInstalledWebExtensions( onSuccess = { extensions = it }, onError = { onErrorCalled = true } ) installedExtensionResult.complete(installedExtensions) assertFalse(onErrorCalled) assertNotNull(extensions) val installedWebExtension = extensions!![0] verify(engine, times(1)).setAllowedInPrivateBrowsing(eq(installedWebExtension), eq(false), any(), any()) engine.listInstalledWebExtensions( onSuccess = { extensions = it }, onError = { onErrorCalled = true } ) verify(engine, times(1)).setAllowedInPrivateBrowsing(eq(installedWebExtension), eq(false), any(), any()) } @Test fun `list web extensions failure`() { val installedExtensionResult = GeckoResult<List<GeckoWebExtension>>() Loading Loading
components/browser/engine-gecko-nightly/src/main/java/mozilla/components/browser/engine/gecko/GeckoEngine.kt +0 −20 Original line number Diff line number Diff line Loading @@ -72,7 +72,6 @@ class GeckoEngine( ) : Engine, WebExtensionRuntime { private val executor by lazy { executorProvider.invoke() } private val localeUpdater = LocaleSettingUpdater(context, runtime) private val sharedPref = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE) @VisibleForTesting internal val speculativeConnectionFactory = SpeculativeSessionFactory() private var webExtensionDelegate: WebExtensionDelegate? = null private val webExtensionActionHandler = object : ActionHandler { Loading Loading @@ -331,23 +330,11 @@ class GeckoEngine( extension -> GeckoWebExtension(extension, runtime) } ?: emptyList() val privateBrowsingMigrated = sharedPref.getBoolean(MOZAC_HAS_RESET_WEBEXT_PRIVATE_BROWSING_DEFAULT, false) extensions.forEach { extension -> // As a workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=1621385, // we set all installed extensions to be allowed in private browsing mode. // We need to revert back to false which is now the default. if (!extension.isBuiltIn() && extension.isAllowedInPrivateBrowsing() && !privateBrowsingMigrated) { setAllowedInPrivateBrowsing(extension, false) } extension.registerActionHandler(webExtensionActionHandler) extension.registerTabHandler(webExtensionTabHandler) } if (!privateBrowsingMigrated) { sharedPref.edit().putBoolean(MOZAC_HAS_RESET_WEBEXT_PRIVATE_BROWSING_DEFAULT, true).apply() } onSuccess(extensions) GeckoResult<Void>() }, { throwable -> Loading Loading @@ -720,13 +707,6 @@ class GeckoEngine( cookiesHasBeenBlocked = cookiesHasBeenBlocked ) } companion object { private const val PREFERENCE_NAME = "MOZAC_GECKO_ENGINE" private const val MOZAC_HAS_RESET_WEBEXT_PRIVATE_BROWSING_DEFAULT = "MOZAC_HAS_RESET_WEBEXT_PRIVATE_BROWSING_DEFAULT" } } internal fun ContentBlockingController.LogEntry.BlockingData.hasBlockedCookies(): Boolean { Loading
components/browser/engine-gecko-nightly/src/test/java/mozilla/components/browser/engine/gecko/GeckoEngineTest.kt +0 −43 Original line number Diff line number Diff line Loading @@ -1352,49 +1352,6 @@ class GeckoEngineTest { assertNotNull(extensions) } @Test fun `migrate private browsing default`() { val bundle = GeckoBundle() bundle.putString("webExtensionId", "id") bundle.putString("locationURI", "uri") val metaDataBundle = GeckoBundle() metaDataBundle.putBoolean("privateBrowsingAllowed", true) metaDataBundle.putStringArray("disabledFlags", emptyArray()) bundle.putBundle("metaData", metaDataBundle) val installedExtension = MockWebExtension(bundle) val installedExtensions = listOf<GeckoWebExtension>(installedExtension) val installedExtensionResult = GeckoResult<List<GeckoWebExtension>>() val runtime = mock<GeckoRuntime>() val extensionController: WebExtensionController = mock() whenever(extensionController.list()).thenReturn(installedExtensionResult) whenever(runtime.webExtensionController).thenReturn(extensionController) val allowedInPrivateBrowsingExtensionResult = GeckoResult<GeckoWebExtension>() whenever(extensionController.setAllowedInPrivateBrowsing(any(), anyBoolean())).thenReturn(allowedInPrivateBrowsingExtensionResult) val engine = spy(GeckoEngine(testContext, runtime = runtime)) var extensions: List<WebExtension>? = null var onErrorCalled = false engine.listInstalledWebExtensions( onSuccess = { extensions = it }, onError = { onErrorCalled = true } ) installedExtensionResult.complete(installedExtensions) assertFalse(onErrorCalled) assertNotNull(extensions) val installedWebExtension = extensions!![0] verify(engine, times(1)).setAllowedInPrivateBrowsing(eq(installedWebExtension), eq(false), any(), any()) engine.listInstalledWebExtensions( onSuccess = { extensions = it }, onError = { onErrorCalled = true } ) verify(engine, times(1)).setAllowedInPrivateBrowsing(eq(installedWebExtension), eq(false), any(), any()) } @Test fun `list web extensions failure`() { val installedExtensionResult = GeckoResult<List<GeckoWebExtension>>() Loading