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 477294d4ff3293afaf7946ad66680995578bb6f8..3bec10d1250aecf9b938c0a21bbb6ad36d780c42 100644 |
--- a/content/browser/site_per_process_browsertest.cc |
+++ b/content/browser/site_per_process_browsertest.cc |
@@ -8658,4 +8658,44 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
// calls AssertNoURLRequests() in the shell's URLRequestContext destructor. |
} |
+// Ensure that an iframe that navigates cross-site doesn't use the same process |
+// as its parent. Then when it navigates to its "srcdoc" attribute, it must |
Charlie Reis
2016/11/23 08:02:25
nit: Then when its parent navigates it via the "sr
arthursonzogni
2016/11/23 09:00:48
Done.
|
+// reuse its parent's process. |
+IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
+ IframeSrcdocAfterCrossSiteNavigation) { |
+ GURL parent_url(embedded_test_server()->GetURL( |
+ "a.com", "/cross_site_iframe_factory.html?a(b)")); |
+ GURL child_url(embedded_test_server()->GetURL( |
+ "b.com", "/cross_site_iframe_factory.html?b()")); |
+ GURL blank_url(url::kAboutBlankURL); |
Charlie Reis
2016/11/23 08:02:25
Sanity check: This will change to about:srcdoc aft
arthursonzogni
2016/11/23 09:00:48
Yes that's right. I confirm.
|
+ |
+ // #1 Navigate to a page with a cross-site iframe. |
+ EXPECT_TRUE(NavigateToURL(shell(), parent_url)); |
+ |
+ // Ensure that the iframe uses its own process. |
+ FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
+ ASSERT_EQ(1u, root->child_count()); |
+ FrameTreeNode* child = root->child_at(0); |
+ EXPECT_EQ(parent_url, root->current_url()); |
+ EXPECT_EQ(child_url, child->current_url()); |
+ EXPECT_NE(root->current_frame_host()->GetSiteInstance(), |
+ child->current_frame_host()->GetSiteInstance()); |
+ EXPECT_NE(root->current_frame_host()->GetProcess(), |
+ child->current_frame_host()->GetProcess()); |
+ |
+ // #2 Navigate the iframe to its srcdoc attribute. |
+ TestNavigationObserver load_observer(shell()->web_contents()); |
+ EXPECT_TRUE(ExecuteScript( |
+ root, |
+ R"(document.getElementById("child-0").srcdoc = "srcdoc content";)")); |
Charlie Reis
2016/11/23 08:02:25
Style nit: We don't use R (raw string literals) mu
arthursonzogni
2016/11/23 09:00:48
Done.
|
+ load_observer.Wait(); |
+ |
+ // Ensure that the iframe reuses its parent's process. |
+ EXPECT_EQ(blank_url, child->current_url()); |
+ EXPECT_EQ(root->current_frame_host()->GetSiteInstance(), |
+ child->current_frame_host()->GetSiteInstance()); |
+ EXPECT_EQ(root->current_frame_host()->GetProcess(), |
+ child->current_frame_host()->GetProcess()); |
+} |
+ |
} // namespace content |