Chromium Code Reviews| 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 9a47b4b12f7173c4df1a8e334e3ee7b731c1d09f..98327384a086f0c58edb4ae17aecb7e7617270f7 100644 |
| --- a/content/browser/site_per_process_browsertest.cc |
| +++ b/content/browser/site_per_process_browsertest.cc |
| @@ -17,6 +17,7 @@ |
| #include "content/public/test/content_browser_test_utils.h" |
| #include "content/public/test/test_utils.h" |
| #include "content/shell/browser/shell.h" |
| +#include "content/test/content_browser_test_utils_internal.h" |
| #include "net/dns/mock_host_resolver.h" |
| #include "url/gurl.h" |
| @@ -203,13 +204,16 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) { |
| GURL main_url(test_server()->GetURL("files/site_per_process_main.html")); |
| NavigateToURL(shell(), main_url); |
| - StartFrameAtDataURL(); |
| + // 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. |
| GURL http_url(test_server()->GetURL("files/title1.html")); |
| - EXPECT_TRUE(NavigateIframeToURL(shell(), http_url, "test")); |
| + NavigateFrameToURL(root->child_at(0), http_url); |
| EXPECT_EQ(http_url, observer.navigation_url()); |
| EXPECT_TRUE(observer.navigation_succeeded()); |
| @@ -221,22 +225,44 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) { |
| GURL cross_site_url(test_server()->GetURL("files/title2.html")); |
| replace_host.SetHostStr(foo_com); |
| cross_site_url = cross_site_url.ReplaceComponents(replace_host); |
| - EXPECT_TRUE(NavigateIframeToURL(shell(), cross_site_url, "test")); |
| + 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. |
| - FrameTreeNode* root = |
| - static_cast<WebContentsImpl*>(shell()->web_contents())-> |
| - GetFrameTree()->root(); |
| ASSERT_EQ(1U, root->child_count()); |
| FrameTreeNode* child = root->child_at(0); |
| + 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); |
| + EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), rph); |
| + |
| + // Load another cross-site page into the same iframe. |
| + 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); |
| + NavigateFrameToURL(root->child_at(0), cross_site_url); |
| + 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()->render_view_host()->GetSiteInstance()); |
| + child->current_frame_host()->GetSiteInstance()); |
| + EXPECT_NE(site_instance, |
| + child->current_frame_host()->GetSiteInstance()); |
| EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), |
| child->current_frame_host()->GetProcess()); |
| + EXPECT_NE(rph, child->current_frame_host()->GetProcess()); |
| + |
|
Charlie Reis
2014/04/25 17:16:13
nit: No blank line here.
nasko
2014/04/25 17:20:13
Done.
|
| } |
| // Crash a subframe and ensures its children are cleared from the FrameTree. |