Chromium Code Reviews| Index: chrome/browser/prerender/prerender_browsertest.cc |
| diff --git a/chrome/browser/prerender/prerender_browsertest.cc b/chrome/browser/prerender/prerender_browsertest.cc |
| index c98d0bfe929fbb4f0ed7695350b44021af56d8a2..f1ab3949a7ecb7fa49de0a608db7eacb7d5dba03 100644 |
| --- a/chrome/browser/prerender/prerender_browsertest.cc |
| +++ b/chrome/browser/prerender/prerender_browsertest.cc |
| @@ -170,8 +170,13 @@ class TestPrerenderContents : public PrerenderContents { |
| // When the PrerenderContents is destroyed, quit the UI message loop. |
| // This happens on navigation to used prerendered pages, and soon |
| // after cancellation of unused prerendered pages. |
| - if (quit_message_loop_on_destruction_) |
| - MessageLoopForUI::current()->Quit(); |
| + if (quit_message_loop_on_destruction_) { |
| + // The message loop may not be running if this is swapped in |
| + // synchronously on a Navigation. |
|
dominich
2012/02/28 16:21:00
Is it worth splitting the tests into browser- and
|
| + MessageLoop* loop = MessageLoopForUI::current(); |
| + if (loop->is_running()) |
| + loop->Quit(); |
| + } |
| } |
| virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE { |
| @@ -786,17 +791,11 @@ class PrerenderBrowserTest : public InProcessBrowserTest { |
| } |
| } |
| - // ui_test_utils::NavigateToURL waits until DidStopLoading is called on |
| - // the current tab. As that tab is going to end up deleted, and may never |
| - // finish loading before that happens, exit the message loop on the deletion |
| - // of the used prerender contents instead. |
| - // |
| - // As PrerenderTestURL waits until the prerendered page has completely |
| - // loaded, there is no race between loading |dest_url| and swapping the |
| - // prerendered TabContents into the tab. |
| + // Navigate to the prerendered URL, but don't run the message loop. Browser |
| + // issued navigations to prerendered pages will synchronously swap in the |
| + // prerendered page. |
| ui_test_utils::NavigateToURLWithDisposition( |
| browser(), dest_url, disposition, ui_test_utils::BROWSER_TEST_NONE); |
| - ui_test_utils::RunMessageLoop(); |
| // Make sure the PrerenderContents found earlier was used or removed. |
| EXPECT_TRUE(GetPrerenderContents() == NULL); |