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

Unified Diff: content/browser/isolated_origin_browsertest.cc

Issue 2891443002: Keep subdomains of an isolated origin in the isolated origin's SiteInstance. (Closed)
Patch Set: More cleanup Created 3 years, 6 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
Index: content/browser/isolated_origin_browsertest.cc
diff --git a/content/browser/isolated_origin_browsertest.cc b/content/browser/isolated_origin_browsertest.cc
index d44a1ba3ee54e0235c566966fa6e90aced6e6740..2c254926836c18fbd76525b54e9c2eaa760f2ed8 100644
--- a/content/browser/isolated_origin_browsertest.cc
+++ b/content/browser/isolated_origin_browsertest.cc
@@ -353,4 +353,38 @@ IN_PROC_BROWSER_TEST_F(IsolatedOriginTest, Cookies) {
EXPECT_EQ("foo=bar", cookie);
}
+// Check that subdomains on an isolated origin (e.g., bar.isolated.foo.com)
+// also end up in the isolated origin's SiteInstance.
+IN_PROC_BROWSER_TEST_F(IsolatedOriginTest, IsolatedOriginWithSubdomain) {
+ // Start on a page with an isolated origin with a same-site iframe.
+ GURL isolated_url(embedded_test_server()->GetURL("isolated.foo.com",
+ "/page_with_iframe.html"));
+ EXPECT_TRUE(NavigateToURL(shell(), isolated_url));
+
+ FrameTreeNode* root = web_contents()->GetFrameTree()->root();
+ FrameTreeNode* child = root->child_at(0);
+ scoped_refptr<SiteInstance> isolated_instance =
+ web_contents()->GetSiteInstance();
+
+ // Navigate iframe to the isolated origin's subdomain.
+ GURL isolated_subdomain_url(
+ embedded_test_server()->GetURL("bar.isolated.foo.com", "/title1.html"));
+ NavigateIframeToURL(web_contents(), "test_iframe", isolated_subdomain_url);
+ EXPECT_EQ(child->current_url(), isolated_subdomain_url);
+
+ EXPECT_EQ(isolated_instance, child->current_frame_host()->GetSiteInstance());
+ EXPECT_FALSE(child->current_frame_host()->IsCrossProcessSubframe());
+ EXPECT_EQ(isolated_url.GetOrigin(),
+ child->current_frame_host()->GetSiteInstance()->GetSiteURL());
+
+ // Now try navigating the main frame (renderer-initiated) to the isolated
+ // origin's subdomain. This should not swap processes.
+ TestNavigationObserver observer(web_contents());
+ EXPECT_TRUE(
+ ExecuteScript(web_contents(),
+ "location.href = '" + isolated_subdomain_url.spec() + "'"));
+ observer.Wait();
+ EXPECT_EQ(isolated_instance, web_contents()->GetSiteInstance());
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698