Index: chrome/browser/ui/views/constrained_window_views_browsertest.cc |
diff --git a/chrome/browser/ui/views/constrained_window_views_browsertest.cc b/chrome/browser/ui/views/constrained_window_views_browsertest.cc |
index 5db441f1a9143d94846528364e2cb8fe89a793ac..a78c73c2d421e1ba480c521a3f8d582a26a2b78f 100644 |
--- a/chrome/browser/ui/views/constrained_window_views_browsertest.cc |
+++ b/chrome/browser/ui/views/constrained_window_views_browsertest.cc |
@@ -211,6 +211,12 @@ IN_PROC_BROWSER_TEST_F(ConstrainedWindowViewTest, NavigationOnBackspace) { |
content::RunAllPendingInMessageLoop(); |
content::WaitForLoadStop(web_contents); |
+ // When Widget::Close is called, a task is posted that will destroy the |
+ // widget. Here the widget is closed when the navigation commits. Load stop |
+ // may occur right after the commit, before the widget is destroyed. |
+ // Execute pending tasks to account for this. |
+ base::RunLoop().RunUntilIdle(); |
+ |
EXPECT_EQ(nullptr, dialog->GetWidget()); |
EXPECT_EQ(original_url, web_contents->GetURL()); |
} |