Index: content/public/test/test_renderer_host.cc |
diff --git a/content/public/test/test_renderer_host.cc b/content/public/test/test_renderer_host.cc |
index 9a1cc856c58935bdf4b447e44d833e7b112eb315..7de9eb59ab0167ed7fc61c42ac1997f7662553ed 100644 |
--- a/content/public/test/test_renderer_host.cc |
+++ b/content/public/test/test_renderer_host.cc |
@@ -72,7 +72,9 @@ RenderViewHostTestEnabler::~RenderViewHostTestEnabler() { |
// RenderViewHostTestHarness -------------------------------------------------- |
-RenderViewHostTestHarness::RenderViewHostTestHarness() : contents_(NULL) { |
+RenderViewHostTestHarness::RenderViewHostTestHarness() |
+ : contents_(NULL), |
+ real_threads_mask_(TestBrowserThreadBundle::NO_REAL_THREAD) { |
} |
RenderViewHostTestHarness::~RenderViewHostTestHarness() { |
@@ -155,11 +157,14 @@ void RenderViewHostTestHarness::FailedReload() { |
} |
void RenderViewHostTestHarness::SetUp() { |
+ thread_bundle_.reset(new TestBrowserThreadBundle(real_threads_mask_)); |
+ |
#if defined(OS_WIN) |
ole_initializer_.reset(new ui::ScopedOleInitializer()); |
#endif |
#if defined(USE_AURA) |
- aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); |
+ aura_test_helper_.reset( |
+ new aura::test::AuraTestHelper(base::MessageLoopForUI::current())); |
aura_test_helper_->SetUp(); |
#endif |
SetContents(CreateTestWebContents()); |
@@ -174,17 +179,22 @@ void RenderViewHostTestHarness::TearDown() { |
// before we destroy the browser context. |
base::RunLoop().RunUntilIdle(); |
+#if defined(OS_WIN) |
+ ole_initializer_.reset(); |
+#endif |
+ |
// Delete any RenderProcessHosts before the BrowserContext goes away. |
if (rvh_test_enabler_.rph_factory_) |
rvh_test_enabler_.rph_factory_.reset(); |
- // Release the browser context on the UI thread. |
- message_loop_.DeleteSoon(FROM_HERE, browser_context_.release()); |
- base::RunLoop().RunUntilIdle(); |
- |
-#if defined(OS_WIN) |
- ole_initializer_.reset(); |
-#endif |
+ // Release the browser context by posting itself on the end of the task |
+ // queue. This is preferable to immediate deletion because it will behave |
+ // properly if the |rph_factory_| reset above enqueued any tasks which |
+ // depend on |browser_context_|. |
+ BrowserThread::DeleteSoon(content::BrowserThread::UI, |
+ FROM_HERE, |
+ browser_context_.release()); |
+ thread_bundle_.reset(); |
} |
void RenderViewHostTestHarness::SetRenderProcessHostFactory( |