@@ -2358,6 +2358,14 @@ IN_PROC_BROWSER_TEST_F(DaoBackToOpenerBrowserTest,
23582358
23592359 EXPECT_FALSE (dest_contents->GetController ().CanGoBack ());
23602360 EXPECT_FALSE (chrome::CanGoBack (browser ()));
2361+
2362+ // Defense in depth: even if GoBack is invoked anyway, the child must not
2363+ // be closed and must remain the active tab.
2364+ const int tab_count_before = tab_strip->count ();
2365+ chrome::GoBack (browser (), WindowOpenDisposition::CURRENT_TAB );
2366+ base::RunLoop ().RunUntilIdle ();
2367+ EXPECT_EQ (tab_count_before, tab_strip->count ());
2368+ EXPECT_EQ (dest_contents, tab_strip->GetActiveWebContents ());
23612369}
23622370
23632371// 3. Closing the opener tab should also disable back-to-opener for the
@@ -2385,6 +2393,14 @@ IN_PROC_BROWSER_TEST_F(DaoBackToOpenerBrowserTest,
23852393 // With the opener gone and no in-tab history, back must be disabled.
23862394 EXPECT_FALSE (dest_contents->GetController ().CanGoBack ());
23872395 EXPECT_FALSE (chrome::CanGoBack (browser ()));
2396+
2397+ // Defense in depth: even if GoBack is invoked anyway, the orphaned child
2398+ // must not be closed and must remain the active tab.
2399+ const int tab_count_before = tab_strip->count ();
2400+ chrome::GoBack (browser (), WindowOpenDisposition::CURRENT_TAB );
2401+ base::RunLoop ().RunUntilIdle ();
2402+ EXPECT_EQ (tab_count_before, tab_strip->count ());
2403+ EXPECT_EQ (dest_contents, tab_strip->GetActiveWebContents ());
23882404}
23892405
23902406// 4. When a child tab has its own in-tab navigation history, the regular
@@ -2422,6 +2438,8 @@ IN_PROC_BROWSER_TEST_F(DaoBackToOpenerBrowserTest,
24222438 EXPECT_EQ (2 , tab_strip->count ());
24232439 EXPECT_EQ (dest_index, tab_strip->GetIndexOfWebContents (dest_contents));
24242440 EXPECT_EQ (dest_contents, tab_strip->GetActiveWebContents ());
2441+ EXPECT_EQ (embedded_test_server ()->GetURL (" /title1.html" ),
2442+ dest_contents->GetLastCommittedURL ());
24252443}
24262444
24272445// 5. Pinned tabs should not participate in back-to-opener: a pinned child
0 commit comments