tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit f2418eea10c58ab930b62e43b0525032d08e804d
parent 052c2c5cf1e7ff928c936576959c3648cfa9ba54
Author: AndiAJ <andiaj@users.noreply.github.com>
Date:   Mon,  5 Jan 2026 15:49:12 +0000

Bug 1923147 - Fix dismissOpenLinksInAppCFRTest UI test r=dpop,jajohnson

The UI test was flaky/failing because sometimes the website wasn't fully loaded when trying to refresh it.

To fix this, I've switched from verifying the page content to waiting for the page to be loaded, and also added a wait for the main menu "stop" button to not exist (if it exists the page isn't loaded yet)  before clicking the refresh button.

The UI test successfully passed 50x on Firebase ✅

Differential Revision: https://phabricator.services.mozilla.com/D277875

Diffstat:
Mmobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsAdvancedTest.kt | 3++-
Mmobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt | 2+-
Mmobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/robots/ThreeDotMenuMainRobot.kt | 13+++++++++++--
3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsAdvancedTest.kt b/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsAdvancedTest.kt @@ -18,6 +18,7 @@ import org.mozilla.fenix.helpers.MatcherHelper.itemWithResIdAndText import org.mozilla.fenix.helpers.OpenLinksInApp import org.mozilla.fenix.helpers.TestAssetHelper import org.mozilla.fenix.helpers.TestAssetHelper.externalLinksAsset +import org.mozilla.fenix.helpers.TestAssetHelper.waitingTimeLong import org.mozilla.fenix.helpers.TestHelper import org.mozilla.fenix.helpers.TestHelper.exitMenu import org.mozilla.fenix.helpers.TestHelper.mDevice @@ -228,7 +229,7 @@ class SettingsAdvancedTest : TestSetup() { navigationToolbar(composeTestRule) { }.enterURLAndEnterToBrowser("https://m.youtube.com/".toUri()) { - verifyPageContent("youtube") + waitForPageToLoad(pageLoadWaitingTime = waitingTimeLong) verifyOpenLinksInAppsCFRExists(true) clickOpenLinksInAppsDismissCFRButton() verifyOpenLinksInAppsCFRExists(false) diff --git a/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt b/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/robots/BrowserRobot.kt @@ -1021,7 +1021,7 @@ class BrowserRobot(private val composeTestRule: ComposeTestRule) { if (i == RETRY_COUNT) { throw e } else { - browserScreen(this@BrowserRobot.composeTestRule) { + browserScreen(composeTestRule) { }.openThreeDotMenu { }.clickRefreshButton { waitForPageToLoad(pageLoadWaitingTime = waitingTimeLong) diff --git a/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/robots/ThreeDotMenuMainRobot.kt b/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/ui/robots/ThreeDotMenuMainRobot.kt @@ -15,6 +15,7 @@ import androidx.compose.ui.test.assertIsNotDisplayed import androidx.compose.ui.test.assertIsNotEnabled import androidx.compose.ui.test.hasContentDescription import androidx.compose.ui.test.hasTestTag +import androidx.compose.ui.test.hasText import androidx.compose.ui.test.junit4.ComposeTestRule import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onNodeWithTag @@ -46,6 +47,7 @@ import org.mozilla.fenix.helpers.MatcherHelper.itemContainingText import org.mozilla.fenix.helpers.MatcherHelper.itemWithDescription import org.mozilla.fenix.helpers.MatcherHelper.itemWithResId import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime +import org.mozilla.fenix.helpers.TestAssetHelper.waitingTimeLong import org.mozilla.fenix.helpers.TestAssetHelper.waitingTimeShort import org.mozilla.fenix.helpers.TestHelper.appName import org.mozilla.fenix.helpers.TestHelper.mDevice @@ -540,7 +542,14 @@ class ThreeDotMenuMainRobot(private val composeTestRule: ComposeTestRule) { return BrowserRobot.Transition(composeTestRule) } + @OptIn(ExperimentalTestApi::class) fun clickRefreshButton(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition { + Log.i(TAG, "clickRefreshButton: Waiting for $waitingTimeLong until the \"Stop\" button does not exist") + composeTestRule.waitUntilDoesNotExist(hasText("Stop"), waitingTimeLong) + Log.i(TAG, "clickRefreshButton: Waited for $waitingTimeLong until the \"Stop\" button does not exist") + Log.i(TAG, "clickRefreshButton: Waiting for $waitingTime until the \"Refresh\" button exists") + composeTestRule.waitUntilAtLeastOneExists(hasText("Refresh"), waitingTime) + Log.i(TAG, "clickRefreshButton: Waited for $waitingTime until the \"Refresh\" button exists") Log.i(TAG, "clickRefreshButton: Trying to click the \"Refresh\" button") composeTestRule.refreshButton().performClick() Log.i(TAG, "clickRefreshButton: Clicked the \"Refresh\" button") @@ -722,8 +731,6 @@ private fun threeDotMenuRecyclerView() = private fun editBookmarkButton() = onView(withText("Edit")) -private fun stopLoadingButton() = itemWithDescription("Stop") - private fun closeAllTabsButton() = onView(allOf(withText("Close all tabs"))).inRoot(RootMatchers.isPlatformPopup()) private fun shareTabButton() = onView(allOf(withText("Share all tabs"))).inRoot(RootMatchers.isPlatformPopup()) @@ -764,6 +771,8 @@ private fun ComposeTestRule.forwardButton() = onNodeWithText("Forward") private fun ComposeTestRule.refreshButton() = onNodeWithText("Refresh") +private fun ComposeTestRule.stopButton() = onNodeWithText("Stop") + private fun ComposeTestRule.shareButton() = onNodeWithText("Share") private fun ComposeTestRule.signInButton() = onNodeWithContentDescription("Sign in Sync passwords, bookmarks, and more")