2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-19 09:25:34 +00:00

Bug 1839358 - Allow open tabs containing mobile subdomains to be displayed as suggestions in the awesome bar

This commit is contained in:
Alexandru2909 2023-06-20 15:04:08 +03:00 committed by mergify[bot]
parent 59ffbe62ba
commit 2ad016ba24
2 changed files with 9 additions and 8 deletions

View File

@ -493,8 +493,8 @@ class AwesomeBarView(
searchEngineSource: SearchEngineSource, searchEngineSource: SearchEngineSource,
filterByCurrentEngine: Boolean = false, filterByCurrentEngine: Boolean = false,
): SessionSuggestionProvider { ): SessionSuggestionProvider {
val searchEngineHostFilter = when (filterByCurrentEngine) { val searchEngineUriFilter = when (filterByCurrentEngine) {
true -> searchEngineSource.searchEngine?.resultsUrl?.host true -> searchEngineSource.searchEngine?.resultsUrl
false -> null false -> null
} }
@ -506,7 +506,7 @@ class AwesomeBarView(
getDrawable(activity, R.drawable.ic_search_results_tab), getDrawable(activity, R.drawable.ic_search_results_tab),
excludeSelectedSession = !fromHomeFragment, excludeSelectedSession = !fromHomeFragment,
suggestionsHeader = activity.getString(R.string.firefox_suggest_header), suggestionsHeader = activity.getString(R.string.firefox_suggest_header),
resultsHostFilter = searchEngineHostFilter, resultsUriFilter = searchEngineUriFilter,
) )
} }

View File

@ -640,19 +640,20 @@ class AwesomeBarViewTest {
val localSessionsProviders = result.filterIsInstance<SessionSuggestionProvider>() val localSessionsProviders = result.filterIsInstance<SessionSuggestionProvider>()
assertEquals(1, localSessionsProviders.size) assertEquals(1, localSessionsProviders.size)
assertNull(localSessionsProviders[0].resultsHostFilter) assertNull(localSessionsProviders[0].resultsUriFilter)
} }
@Test @Test
fun `GIVEN normal browsing mode and needing to show filtered local tabs suggestions WHEN configuring providers THEN add the tabs provider with an engine filter`() { fun `GIVEN normal browsing mode and needing to show filtered local tabs suggestions WHEN configuring providers THEN add the tabs provider with an engine filter`() {
val settings: Settings = mockk(relaxed = true) val settings: Settings = mockk(relaxed = true)
val url = Uri.parse("https://www.test.com")
every { activity.settings() } returns settings every { activity.settings() } returns settings
every { activity.browsingModeManager.mode } returns BrowsingMode.Normal every { activity.browsingModeManager.mode } returns BrowsingMode.Normal
val state = getSearchProviderState( val state = getSearchProviderState(
showAllSessionSuggestions = false, showAllSessionSuggestions = false,
searchEngineSource = SearchEngineSource.Shortcut( searchEngineSource = SearchEngineSource.Shortcut(
mockk(relaxed = true) { mockk(relaxed = true) {
every { resultsUrl.host } returns "test" every { resultsUrl } returns url
}, },
), ),
) )
@ -661,7 +662,7 @@ class AwesomeBarViewTest {
val localSessionsProviders = result.filterIsInstance<SessionSuggestionProvider>() val localSessionsProviders = result.filterIsInstance<SessionSuggestionProvider>()
assertEquals(1, localSessionsProviders.size) assertEquals(1, localSessionsProviders.size)
assertEquals("test", localSessionsProviders[0].resultsHostFilter) assertEquals(url, localSessionsProviders[0].resultsUriFilter)
} }
@Test @Test
@ -827,8 +828,8 @@ class AwesomeBarViewTest {
assertEquals("www.test.com", syncedTabsProviders[1].resultsHostFilter) // the filtered synced tabs provider assertEquals("www.test.com", syncedTabsProviders[1].resultsHostFilter) // the filtered synced tabs provider
val localTabsProviders: List<SessionSuggestionProvider> = result.filterIsInstance<SessionSuggestionProvider>() val localTabsProviders: List<SessionSuggestionProvider> = result.filterIsInstance<SessionSuggestionProvider>()
assertEquals(2, localTabsProviders.size) assertEquals(2, localTabsProviders.size)
assertNull(localTabsProviders[0].resultsHostFilter) // the general tabs provider assertNull(localTabsProviders[0].resultsUriFilter) // the general tabs provider
assertEquals("www.test.com", localTabsProviders[1].resultsHostFilter) // the filtered tabs provider assertEquals(url, localTabsProviders[1].resultsUriFilter) // the filtered tabs provider
assertEquals(1, result.filterIsInstance<SearchEngineSuggestionProvider>().size) assertEquals(1, result.filterIsInstance<SearchEngineSuggestionProvider>().size)
} }