mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Bug 1919893 - User do not intercept should apply even if scheme is not supported r=android-reviewers,avirvara
Differential Revision: https://phabricator.services.mozilla.com/D224026
This commit is contained in:
parent
6688e8cd5f
commit
e70377eb64
@ -135,7 +135,7 @@ class AppLinksInterceptor(
|
||||
|
||||
val tabId = tabSessionState?.id ?: ""
|
||||
val redirect = useCases.interceptedAppLinkRedirect(uri)
|
||||
val result = handleRedirect(redirect, uri, tabId, engineSupportedSchemes.contains(uriScheme))
|
||||
val result = handleRedirect(redirect, uri, tabId)
|
||||
|
||||
if (redirect.hasExternalApp()) {
|
||||
val packageName = redirect.appIntent?.component?.packageName
|
||||
@ -172,15 +172,18 @@ class AppLinksInterceptor(
|
||||
redirect: AppLinkRedirect,
|
||||
uri: String,
|
||||
tabId: String,
|
||||
schemeSupported: Boolean,
|
||||
): RequestInterceptor.InterceptionResponse? {
|
||||
if (!launchInApp() || inUserDoNotIntercept(uri, redirect.appIntent, tabId)) {
|
||||
if (!launchInApp()) {
|
||||
redirect.fallbackUrl?.let {
|
||||
return RequestInterceptor.InterceptionResponse.Url(it)
|
||||
}
|
||||
}
|
||||
|
||||
if (schemeSupported && inUserDoNotIntercept(uri, redirect.appIntent, tabId)) {
|
||||
if (inUserDoNotIntercept(uri, redirect.appIntent, tabId)) {
|
||||
redirect.fallbackUrl?.let {
|
||||
return RequestInterceptor.InterceptionResponse.Url(it)
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
|
@ -509,7 +509,7 @@ class AppLinksInterceptorTest {
|
||||
)
|
||||
|
||||
val testRedirect = AppLinkRedirect(Intent.parseUri(intentUrl, 0), "", fallbackUrl, null)
|
||||
val response = appLinksInterceptor.handleRedirect(testRedirect, intentUrl, "", true)
|
||||
val response = appLinksInterceptor.handleRedirect(testRedirect, intentUrl, "")
|
||||
assert(response is RequestInterceptor.InterceptionResponse.Url)
|
||||
}
|
||||
|
||||
@ -554,7 +554,7 @@ class AppLinksInterceptorTest {
|
||||
)
|
||||
|
||||
val testRedirect = AppLinkRedirect(Intent.parseUri(intentUrl, 0), "", fallbackUrl, null)
|
||||
val response = appLinksInterceptor.handleRedirect(testRedirect, intentUrl, "", true)
|
||||
val response = appLinksInterceptor.handleRedirect(testRedirect, intentUrl, "")
|
||||
assert(response is RequestInterceptor.InterceptionResponse.AppIntent)
|
||||
}
|
||||
|
||||
@ -569,7 +569,7 @@ class AppLinksInterceptorTest {
|
||||
)
|
||||
|
||||
val testRedirect = AppLinkRedirect(null, "", fallbackUrl, Intent.parseUri(marketplaceUrl, 0))
|
||||
val response = appLinksInterceptor.handleRedirect(testRedirect, webUrl, "", true)
|
||||
val response = appLinksInterceptor.handleRedirect(testRedirect, webUrl, "")
|
||||
assert(response is RequestInterceptor.InterceptionResponse.AppIntent)
|
||||
}
|
||||
|
||||
@ -584,7 +584,7 @@ class AppLinksInterceptorTest {
|
||||
)
|
||||
|
||||
val testRedirect = AppLinkRedirect(null, "", fallbackUrl, null)
|
||||
val response = appLinksInterceptor.handleRedirect(testRedirect, webUrl, "", true)
|
||||
val response = appLinksInterceptor.handleRedirect(testRedirect, webUrl, "")
|
||||
assert(response is RequestInterceptor.InterceptionResponse.Url)
|
||||
}
|
||||
|
||||
@ -634,12 +634,12 @@ class AppLinksInterceptorTest {
|
||||
|
||||
addUserDoNotIntercept(intentUrl, null, "")
|
||||
val testRedirect = AppLinkRedirect(Intent.parseUri(intentUrl, 0), "", fallbackUrl, null)
|
||||
val response = appLinksInterceptor.handleRedirect(testRedirect, intentUrl, "", true)
|
||||
val response = appLinksInterceptor.handleRedirect(testRedirect, intentUrl, "")
|
||||
assert(response is RequestInterceptor.InterceptionResponse.Url)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `WHEN request is in user do not intercept cache but engine doesn't support scheme THEN request is intercepted`() {
|
||||
fun `WHEN request is in user do not intercept cache and scheme is not supported by the engine THEN request is not intercepted`() {
|
||||
val engineSession: EngineSession = mock()
|
||||
val supportedScheme = "supported"
|
||||
val notSupportedScheme = "not_supported"
|
||||
@ -658,7 +658,30 @@ class AppLinksInterceptorTest {
|
||||
val notSupportedRedirect = AppLinkRedirect(Intent.parseUri(notSupportedUrl, 0), "", null, null)
|
||||
whenever(mockGetRedirect.invoke(notSupportedUrl)).thenReturn(notSupportedRedirect)
|
||||
val response = feature.onLoadRequest(engineSession, notSupportedUrl, null, false, false, false, false, false)
|
||||
assert(response is RequestInterceptor.InterceptionResponse.AppIntent)
|
||||
assertNull(response)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `WHEN don't launch in app AND request is in user do not intercept cache AND scheme is not supported by the engine THEN request is not intercepted`() {
|
||||
val engineSession: EngineSession = mock()
|
||||
val supportedScheme = "supported"
|
||||
val notSupportedScheme = "not_supported"
|
||||
val blocklistedScheme = "blocklisted"
|
||||
val feature = AppLinksInterceptor(
|
||||
context = mockContext,
|
||||
interceptLinkClicks = false,
|
||||
engineSupportedSchemes = setOf(supportedScheme),
|
||||
alwaysDeniedSchemes = setOf(blocklistedScheme),
|
||||
launchInApp = { false },
|
||||
useCases = mockUseCases,
|
||||
)
|
||||
|
||||
val notSupportedUrl = "$notSupportedScheme://example.com"
|
||||
addUserDoNotIntercept(notSupportedUrl, null, "")
|
||||
val notSupportedRedirect = AppLinkRedirect(Intent.parseUri(notSupportedUrl, 0), "", null, null)
|
||||
whenever(mockGetRedirect.invoke(notSupportedUrl)).thenReturn(notSupportedRedirect)
|
||||
val response = feature.onLoadRequest(engineSession, notSupportedUrl, null, false, false, false, false, false)
|
||||
assertNull(response)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user