From e38f0fc98cfd49bdbafc9014d4c7fe5005863cb7 Mon Sep 17 00:00:00 2001 From: Netzenbot Date: Wed, 25 Mar 2026 08:45:30 -0400 Subject: [PATCH] Fix intermittent ContainersBrowserTest.MixedTabsPersistence (#34921) Fix intermittent ContainersBrowserTest.MixedTabsPersistence failure After session restore, background tabs use deferred loading and may not have loaded their pages yet. The test was calling EvalJs to read document.cookie on restored tabs without ensuring they were loaded, causing a SecurityError on unloaded tabs with opaque origins. Fix: Activate each tab and wait for load stop before accessing content, following the standard Chromium session restore test pattern. Resolves brave/brave-browser#53772 --- browser/containers/containers_browsertest.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/browser/containers/containers_browsertest.cc b/browser/containers/containers_browsertest.cc index b6c137158af..2aa68747d36 100644 --- a/browser/containers/containers_browsertest.cc +++ b/browser/containers/containers_browsertest.cc @@ -1416,6 +1416,11 @@ IN_PROC_BROWSER_TEST_F(ContainersBrowserTest, MixedTabsPersistence) { browser()->tab_strip_model()->GetWebContentsAt(i); ASSERT_TRUE(tab); + // Restored background tabs may not have loaded yet. Activate each tab to + // trigger session restore's deferred loading, then wait for it to finish. + browser()->tab_strip_model()->ActivateTabAt(i); + ASSERT_TRUE(content::WaitForLoadStop(tab)); + content::StoragePartition* partition = tab->GetPrimaryMainFrame()->GetStoragePartition(); ASSERT_TRUE(partition);