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

Bug 1837599 - Allow history visits containing mobile subdomains to be displayed in the awesome bar

This commit is contained in:
Alexandru2909 2023-06-14 16:51:51 +03:00 committed by mergify[bot]
parent f3b956c929
commit 02fb6cc8da
2 changed files with 13 additions and 11 deletions

View File

@ -339,7 +339,7 @@ class AwesomeBarView(
internal fun getHistoryProvidersForSearchEngine(
searchEngineSource: SearchEngineSource,
): AwesomeBar.SuggestionProvider? {
val searchEngineHostFilter = searchEngineSource.searchEngine?.resultsUrl?.host ?: return null
val searchEngineUriFilter = searchEngineSource.searchEngine?.resultsUrl ?: return null
return if (activity.settings().historyMetadataUIFeature) {
CombinedHistorySuggestionProvider(
@ -351,7 +351,7 @@ class AwesomeBarView(
maxNumberOfSuggestions = METADATA_SUGGESTION_LIMIT,
showEditSuggestion = false,
suggestionsHeader = activity.getString(R.string.firefox_suggest_header),
resultsHostFilter = searchEngineHostFilter,
resultsUriFilter = searchEngineUriFilter,
)
} else {
HistoryStorageSuggestionProvider(
@ -362,7 +362,7 @@ class AwesomeBarView(
maxNumberOfSuggestions = METADATA_SUGGESTION_LIMIT,
showEditSuggestion = false,
suggestionsHeader = activity.getString(R.string.firefox_suggest_header),
resultsHostFilter = searchEngineHostFilter,
resultsUriFilter = searchEngineUriFilter,
)
}
}

View File

@ -171,12 +171,13 @@ class AwesomeBarViewTest {
val settings: Settings = mockk(relaxed = true) {
every { historyMetadataUIFeature } returns true
}
val url = Uri.parse("test.com")
every { activity.settings() } returns settings
val state = getSearchProviderState(
showAllHistorySuggestions = false,
searchEngineSource = SearchEngineSource.Shortcut(
mockk(relaxed = true) {
every { resultsUrl.host } returns "test"
every { resultsUrl } returns url
},
),
)
@ -185,7 +186,7 @@ class AwesomeBarViewTest {
val historyProvider = result.firstOrNull { it is CombinedHistorySuggestionProvider }
assertNotNull(historyProvider)
assertEquals("test", (historyProvider as CombinedHistorySuggestionProvider).resultsHostFilter)
assertEquals(url, (historyProvider as CombinedHistorySuggestionProvider).resultsUriFilter)
assertEquals(AwesomeBarView.METADATA_SUGGESTION_LIMIT, historyProvider.getMaxNumberOfSuggestions())
}
@ -546,12 +547,13 @@ class AwesomeBarViewTest {
val settings: Settings = mockk(relaxed = true) {
every { historyMetadataUIFeature } returns false
}
val url = Uri.parse("test.com")
every { activity.settings() } returns settings
val state = getSearchProviderState(
showAllHistorySuggestions = false,
searchEngineSource = SearchEngineSource.Shortcut(
mockk(relaxed = true) {
every { resultsUrl.host } returns "test"
every { resultsUrl } returns url
},
),
)
@ -560,7 +562,7 @@ class AwesomeBarViewTest {
val historyProvider = result.firstOrNull { it is HistoryStorageSuggestionProvider }
assertNotNull(historyProvider)
assertEquals("test", (historyProvider as HistoryStorageSuggestionProvider).resultsHostFilter)
assertEquals(url, (historyProvider as HistoryStorageSuggestionProvider).resultsUriFilter)
assertEquals(AwesomeBarView.METADATA_SUGGESTION_LIMIT, historyProvider.getMaxNumberOfSuggestions())
}
@ -811,8 +813,8 @@ class AwesomeBarViewTest {
val historyProviders: List<HistoryStorageSuggestionProvider> = result.filterIsInstance<HistoryStorageSuggestionProvider>()
assertEquals(2, historyProviders.size)
assertNull(historyProviders[0].resultsHostFilter) // the general history provider
assertNotNull(historyProviders[1].resultsHostFilter) // the filtered history provider
assertNull(historyProviders[0].resultsUriFilter) // the general history provider
assertNotNull(historyProviders[1].resultsUriFilter) // the filtered history provider
val bookmarksProviders: List<BookmarksStorageSuggestionProvider> = result.filterIsInstance<BookmarksStorageSuggestionProvider>()
assertEquals(2, bookmarksProviders.size)
assertNull(bookmarksProviders[0].resultsUriFilter) // the general bookmarks provider
@ -883,7 +885,7 @@ class AwesomeBarViewTest {
assertNotNull(result)
assertTrue(result is CombinedHistorySuggestionProvider)
assertNotNull((result as CombinedHistorySuggestionProvider).resultsHostFilter)
assertNotNull((result as CombinedHistorySuggestionProvider).resultsUriFilter)
assertEquals(AwesomeBarView.METADATA_SUGGESTION_LIMIT, result.getMaxNumberOfSuggestions())
}
@ -899,7 +901,7 @@ class AwesomeBarViewTest {
assertNotNull(result)
assertTrue(result is HistoryStorageSuggestionProvider)
assertNotNull((result as HistoryStorageSuggestionProvider).resultsHostFilter)
assertNotNull((result as HistoryStorageSuggestionProvider).resultsUriFilter)
assertEquals(AwesomeBarView.METADATA_SUGGESTION_LIMIT, result.getMaxNumberOfSuggestions())
}