Bug 1855939 - Fix crash when tapping the shopping CFR action after rotation

fenix/120.0
Alexandru2909 8 months ago committed by mergify[bot]
parent c623101f19
commit ef4ceb4404

@ -99,7 +99,7 @@ class BrowserToolbarCFRPresenter(
.transformWhile { progress ->
emit(progress)
progress != 100
}.filter { it == 100 }.collect {
}.filter { popup == null && it == 100 }.collect {
scope?.cancel()
showTcpCfr()
}
@ -112,7 +112,7 @@ class BrowserToolbarCFRPresenter(
.filter { it.isProductUrl && it.content.progress == 100 && !it.content.loading }
.distinctUntilChanged()
.map { toolbar.findViewById<View>(R.id.mozac_browser_toolbar_page_actions).isVisible }
.filter { it }
.filter { popup == null && it }
.firstOrNull()
if (shouldShowCfr == true) {
@ -134,7 +134,7 @@ class BrowserToolbarCFRPresenter(
emit(progress)
progress != 100
}
.filter { it == 100 }
.filter { popup == null && it == 100 }
.collect {
scope?.cancel()
showEraseCfr()

@ -255,6 +255,36 @@ class BrowserToolbarCFRPresenterTest {
verify { presenter.showShoppingCFR(eq(false)) }
}
@Test
fun `GIVEN the current tab is showing a product page WHEN the tab is not loading AND another CFR is shown THEN the shopping CFR is not shown`() {
val tab = createTab(url = "")
val browserStore = createBrowserStore(
tab = tab,
selectedTabId = tab.id,
)
val presenter = createPresenter(
browserStore = browserStore,
settings = mockk {
every { shouldShowTotalCookieProtectionCFR } returns false
every { shouldShowReviewQualityCheckCFR } returns true
every { reviewQualityCheckOptInTimeInMillis } returns System.currentTimeMillis()
every { shouldShowEraseActionCFR } returns false
},
)
every { presenter.popup } returns mockk()
every { presenter.showShoppingCFR(any()) } just Runs
presenter.start()
assertNotNull(presenter.scope)
browserStore.dispatch(ShoppingProductAction.UpdateProductUrlStatusAction(tab.id, true)).joinBlocking()
verify(exactly = 0) { presenter.showShoppingCFR(eq(false)) }
browserStore.dispatch(ContentAction.UpdateProgressAction(tab.id, 100)).joinBlocking()
verify(exactly = 0) { presenter.showShoppingCFR(eq(false)) }
}
@Test
fun `GIVEN the user opted in the shopping feature AND the opted in shopping CFR should be shown WHEN the tab finishes loading THEN the CFR is shown`() {
val tab = createTab(url = "")

Loading…
Cancel
Save