Added logic that exits message loop upon test ending even if no browser
window exists.
BUG=None.
TEST=Run in process browser test that doesn't create browser window: it
should quit without timeout error.
Review URL: http://codereview.chromium.org/1508007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43085 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/test/in_process_browser_test.cc b/chrome/test/in_process_browser_test.cc
index 5afcfc2..6070bd4 100644
--- a/chrome/test/in_process_browser_test.cc
+++ b/chrome/test/in_process_browser_test.cc
@@ -276,7 +276,8 @@
// Close all browser windows. This might not happen immediately, since some
// may need to wait for beforeunload and unload handlers to fire in a tab.
- // When all windows are closed, the last window will call Quit().
+ // When all windows are closed, the last window will call Quit(). Call
+ // Quit() explicitly if no windows are open.
#if defined(OS_MACOSX)
// When the browser window closes, Cocoa will generate an inner-loop that
// processes the RenderProcessHost delete task, so allow task nesting.
@@ -284,8 +285,12 @@
MessageLoopForUI::current()->SetNestableTasksAllowed(true);
#endif
BrowserList::const_iterator browser = BrowserList::begin();
- for (; browser != BrowserList::end(); ++browser)
- (*browser)->CloseWindow();
+ if (browser == BrowserList::end()) {
+ MessageLoopForUI::current()->Quit();
+ } else {
+ for (; browser != BrowserList::end(); ++browser)
+ (*browser)->CloseWindow();
+ }
#if defined(OS_MACOSX)
MessageLoopForUI::current()->SetNestableTasksAllowed(old_state);
#endif