Skip to content

Commit

Permalink
Fixed reentrancy check
Browse files Browse the repository at this point in the history
  • Loading branch information
spylogsster committed Jul 19, 2022
1 parent 56a675e commit 2757464
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion browser/ui/brave_browser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ void BraveBrowser::TabStripEmpty() {
return;
}

chrome::AddTabAt(this, GetNewTabURL(), -1, true);
base::SequencedTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(&chrome::AddTabAt, this, GetNewTabURL(), -1,
true, absl::nullopt));
}

bool BraveBrowser::ShouldDisplayFavicon(
Expand Down
8 changes: 7 additions & 1 deletion browser/ui/brave_browser_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,19 @@ IN_PROC_BROWSER_TEST_F(BraveBrowserBrowserTest, OpenNewTabWhenTabStripIsEmpty) {
// Expecting a new tab is opened.
EXPECT_EQ(new_browser->GetNewTabURL(),
tab_strip->GetWebContentsAt(0)->GetURL().possibly_invalid_spec());
// No reentrancy for Ctrl+W
tab_strip->CloseSelectedTabs();
base::RunLoop().RunUntilIdle();
// Expecting a new tab is opened.
EXPECT_EQ(new_browser->GetNewTabURL(),
tab_strip->GetWebContentsAt(0)->GetURL().possibly_invalid_spec());

// Add a couple of more tabs.
chrome::AddTabAt(new_browser, new_browser->GetNewTabURL(), -1, true);
chrome::AddTabAt(new_browser, new_browser->GetNewTabURL(), -1, true);
ASSERT_EQ(3, tab_strip->count());
EXPECT_EQ(chrome::GetTotalBrowserCount(), 2u);
// Close the browser window.
LOG(ERROR) << "WINDOW";
new_browser->window()->Close();
base::RunLoop().RunUntilIdle();
EXPECT_EQ(chrome::GetTotalBrowserCount(), 1u);
Expand Down

0 comments on commit 2757464

Please sign in to comment.