Fix FocusHandlerBrowserTest.ResultFile_WrittenForNormalProfile (#35102)

The test intermittently fails on Windows x64 ASAN builds because
Brave's tab_data.cc override unconditionally marks UNLOADED tabs with
should_show_discard_status=true. During browser startup, tabs briefly
have UNLOADED state before loading begins, which triggers the discard
ring IPH code path while BrowserUserEducationInterface is still in
kInitializationPending state.

Refine the check to only mark tabs as showing discard status when they
have a real committed navigation entry (not the initial entry). This
preserves the behavior for session-restored tabs and genuinely
discarded tabs while avoiding the IPH trigger during startup.

Resolves brave/brave-browser#54040
This commit is contained in:
Netzenbot
2026-04-04 09:18:14 -04:00
committed by GitHub
parent b602c4e091
commit a59c2d1fbe
@@ -21,6 +21,8 @@
#include "chrome/browser/ui/tabs/features.h"
#include "chrome/common/webui_url_constants.h"
#include "components/grit/brave_components_scaled_resources.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "extensions/buildflags/buildflags.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/color/color_provider.h"
@@ -101,14 +103,18 @@ TabData TabData::FromTabInterface(tabs::TabInterface* tab) {
}
}
// Show which tabs are unloaded due to being discarded. Only mark tabs that
// were actually discarded (WasDiscarded), not tabs that simply haven't loaded
// yet (e.g. during browser initialization).
if (!data.should_show_discard_status && contents->WasDiscarded()) {
// Show which tabs are unloaded (e.g., session-restored tabs not yet loaded).
// Only apply to tabs that have navigated before — tabs that still have the
// initial NavigationEntry (e.g., during browser startup before any real
// navigation commits) should not show discard status, as the discard ring
// indicator would trigger IPH code before the browser is fully initialized.
if (!data.should_show_discard_status) {
const auto loading_state =
resource_coordinator::TabLoadTracker::Get()->GetLoadingState(contents);
auto* const entry = contents->GetController().GetLastCommittedEntry();
if (loading_state ==
resource_coordinator::TabLoadTracker::LoadingState::UNLOADED) {
resource_coordinator::TabLoadTracker::LoadingState::UNLOADED &&
entry && !entry->IsInitialEntry()) {
data.should_show_discard_status = true;
}
}