Index: content/browser/site_per_process_browsertest.cc |
diff --git a/content/browser/site_per_process_browsertest.cc b/content/browser/site_per_process_browsertest.cc |
index cf491b6c5aac917b30575eea2a105e530d271b1b..8244c249294d05df5976d9795cfea594bcd295a1 100644 |
--- a/content/browser/site_per_process_browsertest.cc |
+++ b/content/browser/site_per_process_browsertest.cc |
@@ -299,6 +299,88 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_CrossSiteIframe) { |
proxy_to_parent->cross_process_frame_connector()->get_view_for_testing()); |
} |
+IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, NavigateRemoteFrame) { |
+ host_resolver()->AddRule("*", "127.0.0.1"); |
+ ASSERT_TRUE(test_server()->Start()); |
+ GURL main_url(test_server()->GetURL("files/site_per_process_main.html")); |
+ NavigateToURL(shell(), main_url); |
+ |
+ // It is safe to obtain the root frame tree node here, as it doesn't change. |
+ FrameTreeNode* root = |
+ static_cast<WebContentsImpl*>(shell()->web_contents())-> |
+ GetFrameTree()->root(); |
+ |
+ SitePerProcessWebContentsObserver observer(shell()->web_contents()); |
+ |
+ // Load same-site page into iframe. |
+ FrameTreeNode* child = root->child_at(0); |
+ GURL http_url(test_server()->GetURL("files/title1.html")); |
+ NavigateFrameToURL(child, http_url); |
+ EXPECT_EQ(http_url, observer.navigation_url()); |
+ EXPECT_TRUE(observer.navigation_succeeded()); |
+ RenderFrameProxyHost* proxy_to_parent = |
Charlie Reis
2014/09/18 20:22:28
We don't need the proxy_to_parent checks in this t
Nate Chapin
2014/09/18 22:39:02
Done.
|
+ child->render_manager()->GetRenderFrameProxyHost( |
+ shell()->web_contents()->GetSiteInstance()); |
+ EXPECT_FALSE(proxy_to_parent); |
+ |
+ // These must stay in scope with replace_host. |
+ GURL::Replacements replace_host; |
+ std::string foo_com("foo.com"); |
+ |
+ // Load cross-site page into iframe. |
+ GURL cross_site_url(test_server()->GetURL("files/title2.html")); |
+ replace_host.SetHostStr(foo_com); |
+ cross_site_url = cross_site_url.ReplaceComponents(replace_host); |
+ NavigateFrameToURL(root->child_at(0), cross_site_url); |
+ EXPECT_EQ(cross_site_url, observer.navigation_url()); |
+ EXPECT_TRUE(observer.navigation_succeeded()); |
+ |
+ // Ensure that we have created a new process for the subframe. |
+ ASSERT_EQ(1U, root->child_count()); |
+ SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance(); |
+ RenderViewHost* rvh = child->current_frame_host()->render_view_host(); |
+ RenderProcessHost* rph = child->current_frame_host()->GetProcess(); |
+ EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), rvh); |
+ EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance); |
Charlie Reis
2014/09/18 20:22:28
Let's keep this site_instance check (as a sanity c
Nate Chapin
2014/09/18 22:39:02
Done.
|
+ EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), rph); |
+ proxy_to_parent = child->render_manager()->GetProxyToParent(); |
+ EXPECT_TRUE(proxy_to_parent); |
+ EXPECT_TRUE(proxy_to_parent->cross_process_frame_connector()); |
+ EXPECT_EQ( |
+ rvh->GetView(), |
+ proxy_to_parent->cross_process_frame_connector()->get_view_for_testing()); |
+ |
+ // Emulate the main frame changing the src of the iframe such that it |
+ // navigates crosssite. |
Charlie Reis
2014/09/18 20:22:28
nit: cross-site
Nate Chapin
2014/09/18 22:39:02
Done.
|
+ cross_site_url = test_server()->GetURL("files/title3.html"); |
+ std::string bar_com("bar.com"); |
+ replace_host.SetHostStr(bar_com); |
+ cross_site_url = cross_site_url.ReplaceComponents(replace_host); |
+ NavigateIframeToURL(shell(), cross_site_url, "test"); |
+ EXPECT_EQ(cross_site_url, observer.navigation_url()); |
+ EXPECT_TRUE(observer.navigation_succeeded()); |
+ |
+ // Check again that a new process is created and is different from the |
+ // top level one and the previous one. |
+ ASSERT_EQ(1U, root->child_count()); |
+ child = root->child_at(0); |
+ EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), |
+ child->current_frame_host()->render_view_host()); |
+ EXPECT_NE(rvh, child->current_frame_host()->render_view_host()); |
+ EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
+ child->current_frame_host()->GetSiteInstance()); |
+ EXPECT_NE(site_instance, |
+ child->current_frame_host()->GetSiteInstance()); |
Charlie Reis
2014/09/18 20:22:28
Again, these two site_instance checks are probably
Nate Chapin
2014/09/18 22:39:02
Done.
|
+ EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), |
+ child->current_frame_host()->GetProcess()); |
+ EXPECT_NE(rph, child->current_frame_host()->GetProcess()); |
+ EXPECT_EQ(proxy_to_parent, child->render_manager()->GetProxyToParent()); |
+ EXPECT_TRUE(proxy_to_parent->cross_process_frame_connector()); |
+ EXPECT_EQ( |
+ child->current_frame_host()->render_view_host()->GetView(), |
+ proxy_to_parent->cross_process_frame_connector()->get_view_for_testing()); |
+} |
Charlie Reis
2014/09/18 20:22:27
Can we add a navigation back to the original site
|
+ |
// Crash a subframe and ensures its children are cleared from the FrameTree. |
// See http://crbug.com/338508. |
// TODO(creis): Disabled for flakiness; see http://crbug.com/405582. |