From 601db6b77a787250e5792733eb144d7f8041bda5 Mon Sep 17 00:00:00 2001 From: Cris Barreiro Date: Mon, 16 Dec 2024 11:28:25 +0100 Subject: [PATCH] Address PR comments --- .../app/browser/BrowserWebViewClientTest.kt | 4 +- .../browser/WebViewRequestInterceptorTest.kt | 36 +---------------- .../referencetests/DomainsReferenceTest.kt | 2 +- .../referencetests/SurrogatesReferenceTest.kt | 2 +- .../app/browser/BrowserWebViewClient.kt | 14 +++---- .../app/browser/WebViewRequestInterceptor.kt | 5 +-- .../app/browser/di/BrowserModule.kt | 2 + .../UrlExtractingWebViewClient.kt | 1 - .../MaliciousSiteBlockerWebViewIntegration.kt | 40 ++++++++++--------- ...iciousSiteBlockerWebViewIntegrationTest.kt | 18 +++------ 10 files changed, 41 insertions(+), 83 deletions(-) diff --git a/app/src/androidTest/java/com/duckduckgo/app/browser/BrowserWebViewClientTest.kt b/app/src/androidTest/java/com/duckduckgo/app/browser/BrowserWebViewClientTest.kt index edafca37b598..76d90012132e 100644 --- a/app/src/androidTest/java/com/duckduckgo/app/browser/BrowserWebViewClientTest.kt +++ b/app/src/androidTest/java/com/duckduckgo/app/browser/BrowserWebViewClientTest.kt @@ -199,7 +199,7 @@ class BrowserWebViewClientTest { whenever(currentTimeProvider.elapsedRealtime()).thenReturn(0) whenever(webViewVersionProvider.getMajorVersion()).thenReturn("1") whenever(deviceInfo.appVersion).thenReturn("1") - whenever(mockMaliciousSiteProtection.shouldOverrideUrlLoading(any(), any(), any(), any())).thenReturn(false) + whenever(mockMaliciousSiteProtection.shouldOverrideUrlLoading(any(), any(), any())).thenReturn(false) } @UiThreadTest @@ -338,7 +338,7 @@ class BrowserWebViewClientTest { TestScope().launch { val webResourceRequest = mock() testee.shouldInterceptRequest(webView, webResourceRequest) - verify(requestInterceptor).shouldIntercept(any(), any(), any(), any(), any()) + verify(requestInterceptor).shouldIntercept(any(), any(), any(), any()) } } diff --git a/app/src/androidTest/java/com/duckduckgo/app/browser/WebViewRequestInterceptorTest.kt b/app/src/androidTest/java/com/duckduckgo/app/browser/WebViewRequestInterceptorTest.kt index 0c6a45bfa6ff..c1aca6bcaf18 100644 --- a/app/src/androidTest/java/com/duckduckgo/app/browser/WebViewRequestInterceptorTest.kt +++ b/app/src/androidTest/java/com/duckduckgo/app/browser/WebViewRequestInterceptorTest.kt @@ -119,6 +119,7 @@ class WebViewRequestInterceptorTest { cloakedCnameDetector = mockCloakedCnameDetector, requestFilterer = mockRequestFilterer, duckPlayer = mockDuckPlayer, + maliciousSiteBlockerWebViewIntegration = mockMaliciousSiteProtection, ) } @@ -130,7 +131,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = "foo.com".toUri(), webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = null, ) assertCancelledResponse(response) @@ -143,7 +143,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = null, webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = null, ) @@ -157,7 +156,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = null, webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = null, ) @@ -172,7 +170,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = null, webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = null, ) @@ -187,7 +184,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = null, webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = null, ) verify(mockHttpsUpgrader).upgrade(any()) @@ -203,7 +199,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = null, webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = null, ) @@ -217,7 +212,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = null, webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = null, ) verify(mockDuckPlayer).intercept(any(), any(), any()) @@ -231,7 +225,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = null, webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = null, ) @@ -245,7 +238,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = null, webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = null, ) @@ -259,7 +251,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = null, webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = null, ) assertRequestCanContinueToLoad(response) @@ -272,7 +263,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = "duckduckgo.com/a/b/c?q=123".toUri(), webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = null, ) @@ -286,7 +276,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = "donttrack.us/a/b/c?q=123".toUri(), webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = null, ) @@ -300,7 +289,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = "spreadprivacy.com/a/b/c?q=123".toUri(), webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = null, ) @@ -314,7 +302,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = "duckduckhack.com/a/b/c?q=123".toUri(), webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = null, ) @@ -328,7 +315,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = "privatebrowsingmyths.com/a/b/c?q=123".toUri(), webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = null, ) @@ -342,7 +328,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = "duck.co/a/b/c?q=123".toUri(), webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = null, ) @@ -359,7 +344,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = "foo.com".toUri(), webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = mockListener, ) @@ -377,7 +361,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = "foo.com".toUri(), webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = mockListener, ) @@ -395,7 +378,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = "foo.com".toUri(), webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = null, ) @@ -418,7 +400,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = "foo.com".toUri(), webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = null, ) @@ -442,7 +423,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = "foo.com".toUri(), webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = mockWebViewClientListener, ) @@ -457,7 +437,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = null, webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = mockWebViewClientListener, ) @@ -474,7 +453,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = null, webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = mockWebViewClientListener, ) @@ -492,7 +470,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = null, webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = mockWebViewClientListener, ) @@ -510,7 +487,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = null, webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = mockWebViewClientListener, ) @@ -528,7 +504,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = null, webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = mockWebViewClientListener, ) @@ -546,7 +521,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = null, webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = mockWebViewClientListener, ) @@ -563,7 +537,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = null, webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = mockWebViewClientListener, ) @@ -580,7 +553,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = null, webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = mockWebViewClientListener, ) @@ -597,7 +569,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = null, webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = mockWebViewClientListener, ) @@ -614,7 +585,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = null, webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = mockWebViewClientListener, ) @@ -674,7 +644,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = "foo.com".toUri(), webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = null, ) @@ -713,7 +682,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = "foo.com".toUri(), webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = null, ) @@ -735,7 +703,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = "foo.com".toUri(), webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = null, ) @@ -755,7 +722,6 @@ class WebViewRequestInterceptorTest { request = mockRequest, documentUri = "foo.com".toUri(), webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = null, ) diff --git a/app/src/androidTest/java/com/duckduckgo/app/referencetests/DomainsReferenceTest.kt b/app/src/androidTest/java/com/duckduckgo/app/referencetests/DomainsReferenceTest.kt index baf7d6ce4b7f..f98a8e43cce8 100644 --- a/app/src/androidTest/java/com/duckduckgo/app/referencetests/DomainsReferenceTest.kt +++ b/app/src/androidTest/java/com/duckduckgo/app/referencetests/DomainsReferenceTest.kt @@ -176,6 +176,7 @@ class DomainsReferenceTest(private val testCase: TestCase) { adClickManager = mockAdClickManager, cloakedCnameDetector = CloakedCnameDetectorImpl(tdsCnameEntityDao, mockTrackerAllowlist, mockUserAllowListRepository), requestFilterer = mockRequestFilterer, + maliciousSiteBlockerWebViewIntegration = mockMaliciousSiteProtection, duckPlayer = mockDuckPlayer, ) } @@ -200,7 +201,6 @@ class DomainsReferenceTest(private val testCase: TestCase) { request = mockRequest, documentUri = testCase.siteURL.toUri(), webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = null, ) diff --git a/app/src/androidTest/java/com/duckduckgo/app/referencetests/SurrogatesReferenceTest.kt b/app/src/androidTest/java/com/duckduckgo/app/referencetests/SurrogatesReferenceTest.kt index 92114b7d3152..98673c5f285a 100644 --- a/app/src/androidTest/java/com/duckduckgo/app/referencetests/SurrogatesReferenceTest.kt +++ b/app/src/androidTest/java/com/duckduckgo/app/referencetests/SurrogatesReferenceTest.kt @@ -172,6 +172,7 @@ class SurrogatesReferenceTest(private val testCase: TestCase) { adClickManager = mockAdClickManager, cloakedCnameDetector = mockCloakedCnameDetector, requestFilterer = mockRequestFilterer, + maliciousSiteBlockerWebViewIntegration = mockMaliciousSiteProtection, duckPlayer = mockDuckPlayer, ) } @@ -189,7 +190,6 @@ class SurrogatesReferenceTest(private val testCase: TestCase) { request = mockRequest, documentUri = testCase.siteURL.toUri(), webView = webView, - maliciousSiteProtectionWebViewIntegration = mockMaliciousSiteProtection, webViewClientListener = null, ) diff --git a/app/src/main/java/com/duckduckgo/app/browser/BrowserWebViewClient.kt b/app/src/main/java/com/duckduckgo/app/browser/BrowserWebViewClient.kt index afe946f4ef0d..03196139f267 100644 --- a/app/src/main/java/com/duckduckgo/app/browser/BrowserWebViewClient.kt +++ b/app/src/main/java/com/duckduckgo/app/browser/BrowserWebViewClient.kt @@ -165,14 +165,11 @@ class BrowserWebViewClient @Inject constructor( Timber.v("shouldOverride webViewUrl: ${webView.url} URL: $url") webViewClientListener?.onShouldOverride() - if (runBlocking { - maliciousSiteProtectionWebViewIntegration.shouldOverrideUrlLoading( - url, - webView.url?.toUri(), - isForMainFrame, - confirmationCallback, - ) - } + if (maliciousSiteProtectionWebViewIntegration.shouldOverrideUrlLoading( + url, + isForMainFrame, + confirmationCallback, + ) ) { // TODO (cbarreiro): Handle site blocked synchronously return true @@ -534,7 +531,6 @@ class BrowserWebViewClient @Inject constructor( request, webView, documentUrl?.toUri(), - maliciousSiteProtectionWebViewIntegration, webViewClientListener, ) } diff --git a/app/src/main/java/com/duckduckgo/app/browser/WebViewRequestInterceptor.kt b/app/src/main/java/com/duckduckgo/app/browser/WebViewRequestInterceptor.kt index 4c34e29a671d..1c0aabd3615c 100644 --- a/app/src/main/java/com/duckduckgo/app/browser/WebViewRequestInterceptor.kt +++ b/app/src/main/java/com/duckduckgo/app/browser/WebViewRequestInterceptor.kt @@ -49,7 +49,6 @@ interface RequestInterceptor { request: WebResourceRequest, webView: WebView, documentUri: Uri?, - maliciousSiteProtectionWebViewIntegration: MaliciousSiteBlockerWebViewIntegration, webViewClientListener: WebViewClientListener?, ): WebResourceResponse? @@ -73,6 +72,7 @@ class WebViewRequestInterceptor( private val cloakedCnameDetector: CloakedCnameDetector, private val requestFilterer: RequestFilterer, private val duckPlayer: DuckPlayer, + private val maliciousSiteBlockerWebViewIntegration: MaliciousSiteBlockerWebViewIntegration, private val dispatchers: DispatcherProvider = DefaultDispatcherProvider(), ) : RequestInterceptor { @@ -94,7 +94,6 @@ class WebViewRequestInterceptor( request: WebResourceRequest, webView: WebView, documentUri: Uri?, - maliciousSiteProtectionWebViewIntegration: MaliciousSiteBlockerWebViewIntegration, webViewClientListener: WebViewClientListener?, ): WebResourceResponse? { val url: Uri? = request.url @@ -103,7 +102,7 @@ class WebViewRequestInterceptor( // TODO (cbarreiro): Handle site blocked asynchronously } - maliciousSiteProtectionWebViewIntegration.shouldIntercept(request, documentUri, confirmationCallback)?.let { + maliciousSiteBlockerWebViewIntegration.shouldIntercept(request, documentUri, confirmationCallback)?.let { // TODO (cbarreiro): Handle site blocked synchronously return it } diff --git a/app/src/main/java/com/duckduckgo/app/browser/di/BrowserModule.kt b/app/src/main/java/com/duckduckgo/app/browser/di/BrowserModule.kt index 088ad74173b9..5f31afb4e012 100644 --- a/app/src/main/java/com/duckduckgo/app/browser/di/BrowserModule.kt +++ b/app/src/main/java/com/duckduckgo/app/browser/di/BrowserModule.kt @@ -216,6 +216,7 @@ class BrowserModule { cloakedCnameDetector: CloakedCnameDetector, requestFilterer: RequestFilterer, duckPlayer: DuckPlayer, + maliciousSiteBlockerWebViewIntegration: MaliciousSiteBlockerWebViewIntegration, ): RequestInterceptor = WebViewRequestInterceptor( resourceSurrogates, @@ -228,6 +229,7 @@ class BrowserModule { cloakedCnameDetector, requestFilterer, duckPlayer, + maliciousSiteBlockerWebViewIntegration, ) @Provides diff --git a/app/src/main/java/com/duckduckgo/app/browser/urlextraction/UrlExtractingWebViewClient.kt b/app/src/main/java/com/duckduckgo/app/browser/urlextraction/UrlExtractingWebViewClient.kt index 5a774ea93970..f92cfa71e904 100644 --- a/app/src/main/java/com/duckduckgo/app/browser/urlextraction/UrlExtractingWebViewClient.kt +++ b/app/src/main/java/com/duckduckgo/app/browser/urlextraction/UrlExtractingWebViewClient.kt @@ -84,7 +84,6 @@ class UrlExtractingWebViewClient( request, webView, documentUrl, - maliciousSiteProtection, null, ) } diff --git a/app/src/main/java/com/duckduckgo/app/browser/webview/MaliciousSiteBlockerWebViewIntegration.kt b/app/src/main/java/com/duckduckgo/app/browser/webview/MaliciousSiteBlockerWebViewIntegration.kt index e7b08b4edfab..329dbf449f2f 100644 --- a/app/src/main/java/com/duckduckgo/app/browser/webview/MaliciousSiteBlockerWebViewIntegration.kt +++ b/app/src/main/java/com/duckduckgo/app/browser/webview/MaliciousSiteBlockerWebViewIntegration.kt @@ -31,10 +31,12 @@ import com.duckduckgo.malicioussiteprotection.api.MaliciousSiteProtection.IsMali import com.duckduckgo.privacy.config.api.PrivacyConfigCallbackPlugin import com.squareup.anvil.annotations.ContributesBinding import com.squareup.anvil.annotations.ContributesMultibinding +import dagger.SingleInstanceIn import java.net.URLDecoder import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch +import kotlinx.coroutines.runBlocking import timber.log.Timber interface MaliciousSiteBlockerWebViewIntegration { @@ -45,9 +47,8 @@ interface MaliciousSiteBlockerWebViewIntegration { confirmationCallback: (isMalicious: Boolean) -> Unit, ): WebResourceResponse? - suspend fun shouldOverrideUrlLoading( + fun shouldOverrideUrlLoading( url: Uri, - webViewUrl: Uri?, isForMainFrame: Boolean, confirmationCallback: (isMalicious: Boolean) -> Unit, ): Boolean @@ -55,6 +56,7 @@ interface MaliciousSiteBlockerWebViewIntegration { fun onPageLoadStarted() } +@SingleInstanceIn(AppScope::class) @ContributesMultibinding(AppScope::class, PrivacyConfigCallbackPlugin::class) @ContributesBinding(AppScope::class, MaliciousSiteBlockerWebViewIntegration::class) class RealMaliciousSiteBlockerWebViewIntegration @Inject constructor( @@ -123,30 +125,32 @@ class RealMaliciousSiteBlockerWebViewIntegration @Inject constructor( return null } - override suspend fun shouldOverrideUrlLoading( + override fun shouldOverrideUrlLoading( url: Uri, - webViewUrl: Uri?, isForMainFrame: Boolean, confirmationCallback: (isMalicious: Boolean) -> Unit, ): Boolean { - if (!isFeatureEnabled) { - return false - } - val decodedUrl = URLDecoder.decode(url.toString(), "UTF-8").lowercase() + return runBlocking { + if (!isFeatureEnabled) { + return@runBlocking false + } + val decodedUrl = URLDecoder.decode(url.toString(), "UTF-8").lowercase() - if (processedUrls.contains(decodedUrl)) { - processedUrls.remove(decodedUrl) - Timber.tag("PhishingAndMalwareDetector").d("Already intercepted, skipping $decodedUrl") - return false - } + if (processedUrls.contains(decodedUrl)) { + processedUrls.remove(decodedUrl) + Timber.tag("PhishingAndMalwareDetector").d("Already intercepted, skipping $decodedUrl") + return@runBlocking false + } - if (isForMainFrame && decodedUrl.toUri() == webViewUrl) { - if (maliciousSiteProtection.isMalicious(decodedUrl.toUri(), confirmationCallback) == MALICIOUS) { - return true + // iframes always go through the shouldIntercept method, so we only need to check the main frame here + if (isForMainFrame) { + if (maliciousSiteProtection.isMalicious(decodedUrl.toUri(), confirmationCallback) == MALICIOUS) { + return@runBlocking true + } + processedUrls.add(decodedUrl) } - processedUrls.add(decodedUrl) + false } - return false } private fun isForIframe(request: WebResourceRequest) = request.requestHeaders["Sec-Fetch-Dest"] == "iframe" || diff --git a/app/src/test/java/com/duckduckgo/app/browser/webview/RealMaliciousSiteBlockerWebViewIntegrationTest.kt b/app/src/test/java/com/duckduckgo/app/browser/webview/RealMaliciousSiteBlockerWebViewIntegrationTest.kt index b72120e1941f..b4141551c217 100644 --- a/app/src/test/java/com/duckduckgo/app/browser/webview/RealMaliciousSiteBlockerWebViewIntegrationTest.kt +++ b/app/src/test/java/com/duckduckgo/app/browser/webview/RealMaliciousSiteBlockerWebViewIntegrationTest.kt @@ -49,7 +49,7 @@ class RealMaliciousSiteBlockerWebViewIntegrationTest { fun `shouldOverrideUrlLoading returns false when feature is disabled`() = runTest { updateFeatureEnabled(false) - val result = testee.shouldOverrideUrlLoading(exampleUri, null, true) {} + val result = testee.shouldOverrideUrlLoading(exampleUri, true) {} assertFalse(result) } @@ -67,7 +67,7 @@ class RealMaliciousSiteBlockerWebViewIntegrationTest { fun `shouldOverrideUrlLoading returns false when url is already processed`() = runTest { testee.processedUrls.add(exampleUri.toString()) - val result = testee.shouldOverrideUrlLoading(exampleUri, exampleUri, true) {} + val result = testee.shouldOverrideUrlLoading(exampleUri, true) {} assertFalse(result) } @@ -109,7 +109,7 @@ class RealMaliciousSiteBlockerWebViewIntegrationTest { fun `shouldOverride returns false when feature is enabled, is malicious, and is not mainframe`() = runTest { whenever(maliciousSiteProtection.isMalicious(any(), any())).thenReturn(MALICIOUS) - val result = testee.shouldOverrideUrlLoading(maliciousUri, maliciousUri, false) {} + val result = testee.shouldOverrideUrlLoading(maliciousUri, false) {} assertFalse(result) } @@ -117,7 +117,7 @@ class RealMaliciousSiteBlockerWebViewIntegrationTest { fun `shouldOverride returns true when feature is enabled, is malicious, and is mainframe`() = runTest { whenever(maliciousSiteProtection.isMalicious(any(), any())).thenReturn(MALICIOUS) - val result = testee.shouldOverrideUrlLoading(maliciousUri, maliciousUri, true) {} + val result = testee.shouldOverrideUrlLoading(maliciousUri, true) {} assertTrue(result) } @@ -125,15 +125,7 @@ class RealMaliciousSiteBlockerWebViewIntegrationTest { fun `shouldOverride returns false when feature is enabled, is malicious, and not mainframe nor iframe`() = runTest { whenever(maliciousSiteProtection.isMalicious(any(), any())).thenReturn(MALICIOUS) - val result = testee.shouldOverrideUrlLoading(maliciousUri, maliciousUri, false) {} - assertFalse(result) - } - - @Test - fun `shouldOverride returns true when feature is enabled, is malicious, and is mainframe but webView has different host`() = runTest { - whenever(maliciousSiteProtection.isMalicious(any(), any())).thenReturn(MALICIOUS) - - val result = testee.shouldOverrideUrlLoading(maliciousUri, exampleUri, true) {} + val result = testee.shouldOverrideUrlLoading(maliciousUri, false) {} assertFalse(result) }