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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "content/browser/child_process_security_policy_impl.h" 6 #include "content/browser/child_process_security_policy_impl.h"
7 #include "content/browser/web_contents/web_contents_impl.h" 7 #include "content/browser/web_contents/web_contents_impl.h"
8 #include "content/public/browser/render_process_host.h" 8 #include "content/public/browser/render_process_host.h"
9 #include "content/public/common/content_switches.h" 9 #include "content/public/common/content_switches.h"
10 #include "content/public/test/browser_test_utils.h" 10 #include "content/public/test/browser_test_utils.h"
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 346
347 EXPECT_TRUE(ExecuteScript(web_contents(), "document.cookie = 'foo=bar';")); 347 EXPECT_TRUE(ExecuteScript(web_contents(), "document.cookie = 'foo=bar';"));
348 348
349 std::string cookie; 349 std::string cookie;
350 EXPECT_TRUE(ExecuteScriptAndExtractString( 350 EXPECT_TRUE(ExecuteScriptAndExtractString(
351 web_contents(), "window.domAutomationController.send(document.cookie);", 351 web_contents(), "window.domAutomationController.send(document.cookie);",
352 &cookie)); 352 &cookie));
353 EXPECT_EQ("foo=bar", cookie); 353 EXPECT_EQ("foo=bar", cookie);
354 } 354 }
355 355
356 // Check that subdomains on an isolated origin (e.g., bar.isolated.foo.com)
357 // also end up in the isolated origin's SiteInstance.
358 IN_PROC_BROWSER_TEST_F(IsolatedOriginTest, IsolatedOriginWithSubdomain) {
359 // Start on a page with an isolated origin with a same-site iframe.
360 GURL isolated_url(embedded_test_server()->GetURL("isolated.foo.com",
361 "/page_with_iframe.html"));
362 EXPECT_TRUE(NavigateToURL(shell(), isolated_url));
363
364 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
365 FrameTreeNode* child = root->child_at(0);
366 scoped_refptr<SiteInstance> isolated_instance =
367 web_contents()->GetSiteInstance();
368
369 // Navigate iframe to the isolated origin's subdomain.
370 GURL isolated_subdomain_url(
371 embedded_test_server()->GetURL("bar.isolated.foo.com", "/title1.html"));
372 NavigateIframeToURL(web_contents(), "test_iframe", isolated_subdomain_url);
373 EXPECT_EQ(child->current_url(), isolated_subdomain_url);
374
375 EXPECT_EQ(isolated_instance, child->current_frame_host()->GetSiteInstance());
376 EXPECT_FALSE(child->current_frame_host()->IsCrossProcessSubframe());
377 EXPECT_EQ(isolated_url.GetOrigin(),
378 child->current_frame_host()->GetSiteInstance()->GetSiteURL());
379
380 // Now try navigating the main frame (renderer-initiated) to the isolated
381 // origin's subdomain. This should not swap processes.
382 TestNavigationObserver observer(web_contents());
383 EXPECT_TRUE(
384 ExecuteScript(web_contents(),
385 "location.href = '" + isolated_subdomain_url.spec() + "'"));
386 observer.Wait();
387 EXPECT_EQ(isolated_instance, web_contents()->GetSiteInstance());
388 }
389
356 } // namespace content 390 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698