File tree Expand file tree Collapse file tree 4 files changed +25
-21
lines changed
app/src/androidTest/java/com/duckduckgo/app/browser
content-scope-scripts/content-scope-scripts-impl/src/test/java/com/duckduckgo/contentscopescripts/impl/messaging
js-messaging/js-messaging-impl/src
main/java/com/duckduckgo/js/messaging/impl
test/java/com/duckduckgo/js/messaging/impl Expand file tree Collapse file tree 4 files changed +25
-21
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ import com.duckduckgo.autoconsent.api.Autoconsent
68
68
import com.duckduckgo.autofill.api.BrowserAutofill
69
69
import com.duckduckgo.autofill.api.InternalTestUserChecker
70
70
import com.duckduckgo.browser.api.JsInjectorPlugin
71
+ import com.duckduckgo.browser.api.WebMessagingBrowserPlugin
71
72
import com.duckduckgo.browser.api.WebViewVersionProvider
72
73
import com.duckduckgo.common.test.CoroutineTestRule
73
74
import com.duckduckgo.common.utils.CurrentTimeProvider
Original file line number Diff line number Diff line change @@ -60,8 +60,8 @@ class ContentScopeScriptsPostMessageWrapperPluginTest {
60
60
61
61
testee.postMessage(subscriptionEventData, mockWebView)
62
62
63
- verify(mockWebMessaging).postMessage(mockWebView, subscriptionEventData)
64
- }
63
+ verify(mockWebMessaging).postMessage(mockWebView, subscriptionEventData)
64
+ }
65
65
66
66
@Test
67
67
fun whenWebViewCompatContentScopeScriptsIsNotEnabledThenPostMessageToContentScopeScriptsJsMessaging () =
Original file line number Diff line number Diff line change @@ -38,13 +38,13 @@ import com.duckduckgo.js.messaging.api.WebMessagingStrategy
38
38
import com.duckduckgo.js.messaging.api.WebViewCompatMessageCallback
39
39
import com.squareup.anvil.annotations.ContributesBinding
40
40
import com.squareup.moshi.Moshi
41
- import javax.inject.Inject
42
41
import kotlinx.coroutines.CoroutineScope
43
42
import kotlinx.coroutines.launch
44
43
import logcat.LogPriority.ERROR
45
44
import logcat.asLog
46
45
import logcat.logcat
47
46
import org.json.JSONObject
47
+ import javax.inject.Inject
48
48
49
49
@ContributesBinding(AppScope ::class )
50
50
class RealWebMessagingDelegate @Inject constructor(
@@ -162,8 +162,8 @@ class RealWebMessagingDelegate @Inject constructor(
162
162
webView : WebView ,
163
163
) {
164
164
if (! strategy.canHandleMessaging()) {
165
- return
166
- }
165
+ return
166
+ }
167
167
168
168
runCatching {
169
169
return @runCatching webViewCompatWrapper.addWebMessageListener(
@@ -181,7 +181,6 @@ class RealWebMessagingDelegate @Inject constructor(
181
181
}.getOrElse { exception ->
182
182
logcat(ERROR ) { " Error adding WebMessageListener for ${strategy.objectName} : ${exception.asLog()} " }
183
183
}
184
-
185
184
}
186
185
187
186
override suspend fun unregister (
Original file line number Diff line number Diff line change @@ -240,24 +240,28 @@ class RealWebMessagingDelegateTest {
240
240
override suspend fun canHandleMessaging (): Boolean = canHandleMessaging
241
241
242
242
override fun getMessageHandlers (): List <WebViewCompatMessageHandler > {
243
- return listOf (object : WebViewCompatMessageHandler {
244
- override fun process (jsMessage : JsMessage ): ProcessResult {
245
- return SendToConsumer
246
- }
247
-
248
- override val featureName: String = " testFeature"
249
- override val methods: List <String > = listOf (" testMethod" )
250
- },)
243
+ return listOf (
244
+ object : WebViewCompatMessageHandler {
245
+ override fun process (jsMessage : JsMessage ): ProcessResult {
246
+ return SendToConsumer
247
+ }
248
+
249
+ override val featureName: String = " testFeature"
250
+ override val methods: List <String > = listOf (" testMethod" )
251
+ },
252
+ )
251
253
}
252
254
253
255
override fun getGlobalMessageHandler (): List <GlobalJsMessageHandler > {
254
- return listOf (object : GlobalJsMessageHandler {
255
- override fun process (jsMessage : JsMessage ): ProcessResult {
256
- return SendToConsumer
257
- }
258
-
259
- override val method: String = " globalMethod"
260
- },)
256
+ return listOf (
257
+ object : GlobalJsMessageHandler {
258
+ override fun process (jsMessage : JsMessage ): ProcessResult {
259
+ return SendToConsumer
260
+ }
261
+
262
+ override val method: String = " globalMethod"
263
+ },
264
+ )
261
265
}
262
266
}
263
267
}
You can’t perform that action at this time.
0 commit comments