Skip to content

Commit e34851a

Browse files
committed
Only store the reply proxy for mainframe
1 parent aab0bef commit e34851a

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

app/src/main/java/com/duckduckgo/app/browser/BrowserTabFragment.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3432,6 +3432,7 @@ class BrowserTabFragment :
34323432
webViewCompatTestHelper.handleWebViewCompatMessage(
34333433
message = message,
34343434
replyProxy = replyProxy,
3435+
isMainFrame = isMainFrame,
34353436
)
34363437
}
34373438
}

app/src/main/java/com/duckduckgo/app/browser/WebViewCompatTestHelper.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ interface WebViewCompatTestHelper {
4646
suspend fun handleWebViewCompatMessage(
4747
message: WebMessageCompat,
4848
replyProxy: JavaScriptReplyProxy,
49+
isMainFrame: Boolean,
4950
)
5051

5152
suspend fun useBlobDownloadsMessageListener(): Boolean
@@ -126,7 +127,7 @@ class RealWebViewCompatTestHelper @Inject constructor(
126127
setOf("*"),
127128
) { view, message, sourceOrigin, isMainFrame, replyProxy ->
128129
webView.findViewTreeLifecycleOwner()?.lifecycleScope?.launch {
129-
handleWebViewCompatMessage(message, replyProxy)
130+
handleWebViewCompatMessage(message, replyProxy, isMainFrame)
130131
}
131132
}
132133
}
@@ -144,11 +145,14 @@ class RealWebViewCompatTestHelper @Inject constructor(
144145
override suspend fun handleWebViewCompatMessage(
145146
message: WebMessageCompat,
146147
replyProxy: JavaScriptReplyProxy,
148+
isMainFrame: Boolean,
147149
) {
148150
withContext(dispatchers.io()) {
149151
if (message.data?.startsWith("webViewCompat Ping:") != true) return@withContext
150152
val cfg = getWebViewCompatConfig()
151-
proxy = replyProxy
153+
if (isMainFrame) {
154+
proxy = replyProxy
155+
}
152156
if (cfg.replyToInitialPing) {
153157
cfg.settings?.initialPingDelay?.takeIf { it > 0 }?.let {
154158
delay(it)

0 commit comments

Comments
 (0)