Upstream version 9.37.195.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / renderer_host / render_process_host_chrome_browsertest.cc
index 55cf996..d0e7015 100644 (file)
@@ -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;
@@ -51,7 +52,7 @@ RenderViewHost* FindFirstDevToolsHost() {
     RenderViewHost* host = RenderViewHost::From(widget);
     WebContents* contents = WebContents::FromRenderViewHost(host);
     GURL url = contents->GetURL();
-    if (url.SchemeIs(chrome::kChromeDevToolsScheme))
+    if (url.SchemeIs(content::kChromeDevToolsScheme))
       return host;
   }
   return NULL;
@@ -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,8 +265,9 @@ 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.
+// flaky, disabling on branch
 #if defined(OS_WIN) || defined(OS_LINUX)
-IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, Backgrounding) {
+IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, DISABLED_Backgrounding) {
   if (!base::Process::CanBackgroundProcesses()) {
     LOG(ERROR) << "Can't background processes";
     return;