File tree Expand file tree Collapse file tree 3 files changed +10
-21
lines changed
app/src/main/java/com/duckduckgo/app/browser
duckchat/duckchat-impl/src
main/java/com/duckduckgo/duckchat/impl/ui
test/kotlin/com/duckduckgo/duckchat/impl/ui Expand file tree Collapse file tree 3 files changed +10
-21
lines changed Original file line number Diff line number Diff line change @@ -482,14 +482,14 @@ class BrowserWebViewClient @Inject constructor(
482
482
483
483
// See https://app.asana.com/0/0/1206159443951489/f (WebView limitations)
484
484
if (webView.progress == 100 ) {
485
+ jsPlugins.getPlugins().forEach {
486
+ it.onPageFinished(
487
+ webView,
488
+ url,
489
+ webViewClientListener?.getSite(),
490
+ )
491
+ }
485
492
appCoroutineScope.launch {
486
- jsPlugins.getPlugins().forEach {
487
- it.onPageFinished(
488
- webView,
489
- url,
490
- webViewClientListener?.getSite(),
491
- )
492
- }
493
493
(webView as ? DuckDuckGoWebView )?.let { duckDuckGoWebView ->
494
494
val activeExperiments = webViewClientListener?.getSite()?.activeContentScopeExperiments ? : listOf ()
495
495
addDocumentStartJavascriptPlugins.getPlugins().forEach {
Original file line number Diff line number Diff line change @@ -20,16 +20,12 @@ import android.graphics.Bitmap
20
20
import android.webkit.WebView
21
21
import android.webkit.WebViewClient
22
22
import androidx.annotation.UiThread
23
- import com.duckduckgo.app.di.AppCoroutineScope
24
23
import com.duckduckgo.browser.api.JsInjectorPlugin
25
24
import com.duckduckgo.common.utils.plugins.PluginPoint
26
25
import javax.inject.Inject
27
- import kotlinx.coroutines.CoroutineScope
28
- import kotlinx.coroutines.launch
29
26
30
27
class DuckChatWebViewClient @Inject constructor(
31
28
private val jsPlugins : PluginPoint <JsInjectorPlugin >,
32
- @AppCoroutineScope private val appCoroutineScope : CoroutineScope ,
33
29
) : WebViewClient() {
34
30
35
31
@UiThread
@@ -38,10 +34,8 @@ class DuckChatWebViewClient @Inject constructor(
38
34
url : String? ,
39
35
favicon : Bitmap ? ,
40
36
) {
41
- appCoroutineScope.launch {
42
- jsPlugins.getPlugins().forEach {
43
- it.onPageStarted(webView, url, null )
44
- }
37
+ jsPlugins.getPlugins().forEach {
38
+ it.onPageStarted(webView, url, null )
45
39
}
46
40
}
47
41
}
Original file line number Diff line number Diff line change @@ -18,27 +18,22 @@ package com.duckduckgo.duckchat.impl.ui
18
18
19
19
import android.webkit.WebView
20
20
import com.duckduckgo.browser.api.JsInjectorPlugin
21
- import com.duckduckgo.common.test.CoroutineTestRule
22
21
import com.duckduckgo.common.utils.plugins.PluginPoint
23
22
import kotlinx.coroutines.test.runTest
24
- import org.junit.Rule
25
23
import org.junit.Test
26
24
import org.mockito.kotlin.mock
27
25
import org.mockito.kotlin.verify
28
26
import org.mockito.kotlin.whenever
29
27
30
28
class DuckChatWebViewClientTest {
31
29
32
- @get:Rule
33
- var coroutineRule = CoroutineTestRule ()
34
-
35
30
@Test
36
31
fun whenOnPageStartedCalledThenJsPluginOnPageStartedInvoked () = runTest {
37
32
val mockPlugin: JsInjectorPlugin = mock()
38
33
val pluginPoint: PluginPoint <JsInjectorPlugin > = mock()
39
34
whenever(pluginPoint.getPlugins()).thenReturn(listOf (mockPlugin))
40
35
41
- val duckChatWebViewClient = DuckChatWebViewClient (pluginPoint, coroutineRule.testScope )
36
+ val duckChatWebViewClient = DuckChatWebViewClient (pluginPoint)
42
37
val webView: WebView = mock()
43
38
val url = " https://example.com"
44
39
You can’t perform that action at this time.
0 commit comments