Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3672)

Unified Diff: chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc

Issue 305373004: Fix renderer process host backgrounding test on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix comment. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc
diff --git a/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc b/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc
index b2143f955f0ed97186be96aa7e197e33212a2916..e300c4e62d2449620a75884ec3b4d44fb7c18c0c 100644
--- a/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc
+++ b/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc
@@ -21,6 +21,7 @@
#include "content/public/browser/render_widget_host_iterator.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
+#include "content/public/test/browser_test_utils.h"
using content::RenderViewHost;
using content::RenderWidgetHost;
@@ -72,6 +73,7 @@ class ChromeRenderProcessHostTest : public InProcessBrowserTest {
CHECK(wc->GetURL() == page);
WaitForLauncherThread();
+ WaitForMessageProcessing(wc);
return wc->GetRenderProcessHost()->GetHandle();
}
@@ -87,6 +89,7 @@ class ChromeRenderProcessHostTest : public InProcessBrowserTest {
CHECK(wc->GetVisibleURL() == page);
WaitForLauncherThread();
+ WaitForMessageProcessing(wc);
return wc->GetRenderProcessHost()->GetHandle();
}
@@ -98,6 +101,16 @@ class ChromeRenderProcessHostTest : public InProcessBrowserTest {
base::MessageLoop::current()->Run();
}
+ // Implicitly waits for the renderer process associated with the specified
+ // WebContents to process outstanding IPC messages by running some JavaScript
+ // and waiting for the result.
+ void WaitForMessageProcessing(WebContents* wc) {
+ bool result = false;
+ ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
+ wc, "window.domAutomationController.send(true);", &result));
+ ASSERT_TRUE(result);
+ }
+
// When we hit the max number of renderers, verify that the way we do process
// sharing behaves correctly. In particular, this test is verifying that even
// when we hit the max process limit, that renderers of each type will wind up
@@ -252,9 +265,7 @@ IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, ProcessPerTab) {
// We don't change process priorities on Mac or Posix because the user lacks the
// permission to raise a process' priority even after lowering it.
-// TODO(dalecurtis): Reenable this on Windows after figuring out how to reliably
-// wait for the renderer process to process IPC messages.
-#if defined(OS_LINUX)
+#if defined(OS_WIN) || defined(OS_LINUX)
IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, Backgrounding) {
if (!base::Process::CanBackgroundProcesses()) {
LOG(ERROR) << "Can't background processes";
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698