| Index: chrome/browser/prerender/prerender_browsertest.cc
|
| diff --git a/chrome/browser/prerender/prerender_browsertest.cc b/chrome/browser/prerender/prerender_browsertest.cc
|
| index 57a3f49571d4a83287aed88eeb1f9d977b64c021..6514b789a8d7e23cd2b58f9b42e637e71cfaaf94 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.
|
| + MessageLoop* loop = MessageLoopForUI::current();
|
| + if (loop->is_running())
|
| + loop->Quit();
|
| + }
|
| }
|
|
|
| virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE {
|
| @@ -787,17 +792,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);
|
|
|