Uncrash BrowserFocusTest.*

It didn't wait for things to finish, which was clearly broken.

TBR=xji

TEST=interactive_ui_tests:BrowserFocusTest.* on Linux, no crashes
BUG=50696

Review URL: http://codereview.chromium.org/3005038

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54251 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/browser_focus_uitest.cc b/chrome/browser/browser_focus_uitest.cc
index aa79385..46a335bf 100644
--- a/chrome/browser/browser_focus_uitest.cc
+++ b/chrome/browser/browser_focus_uitest.cc
@@ -745,19 +745,20 @@
 // types of tabs.
 IN_PROC_BROWSER_TEST_F(BrowserFocusTest, TabInitialFocus) {
   BringBrowserWindowToFront();
+
   // Open the history tab, focus should be on the tab contents.
   browser()->ShowHistoryTab();
-
   ui_test_utils::RunAllPendingInMessageLoop();
-
   ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
 
   // Open the new tab, focus should be on the location bar.
   browser()->NewTab();
+  ui_test_utils::RunAllPendingInMessageLoop();
   ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
 
   // Open the download tab, focus should be on the tab contents.
   browser()->ShowDownloadsTab();
+  ui_test_utils::RunAllPendingInMessageLoop();
   ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
 
   // Open about:blank, focus should be on the location bar.
@@ -775,7 +776,6 @@
 
   // Open the new tab, reload.
   browser()->NewTab();
-
   ui_test_utils::RunAllPendingInMessageLoop();
 
   browser()->Reload(CURRENT_TAB);
@@ -789,8 +789,10 @@
   ASSERT_TRUE(IsViewFocused(VIEW_ID_LOCATION_BAR));
   browser()->Reload(CURRENT_TAB);
   ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser()));
+
   // Focus should now be on the tab contents.
   browser()->ShowDownloadsTab();
+  ui_test_utils::RunAllPendingInMessageLoop();
   ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
 }
 
@@ -813,8 +815,10 @@
   ui_test_utils::CrashTab(browser()->GetSelectedTabContents());
   browser()->Reload(CURRENT_TAB);
   ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser()));
+
   // Focus should now be on the tab contents.
   browser()->ShowDownloadsTab();
+  ui_test_utils::RunAllPendingInMessageLoop();
   ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW));
 }