OLD | NEW |
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 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 // isolated origins. | 461 // isolated origins. |
462 EXPECT_TRUE(NavigateToURL(new_shell, foo_url)); | 462 EXPECT_TRUE(NavigateToURL(new_shell, foo_url)); |
463 EXPECT_EQ(foo_process, | 463 EXPECT_EQ(foo_process, |
464 new_shell->web_contents()->GetMainFrame()->GetProcess()); | 464 new_shell->web_contents()->GetMainFrame()->GetProcess()); |
465 EXPECT_NE(isolated_foo_process, | 465 EXPECT_NE(isolated_foo_process, |
466 new_shell->web_contents()->GetMainFrame()->GetProcess()); | 466 new_shell->web_contents()->GetMainFrame()->GetProcess()); |
467 EXPECT_NE(isolated_bar_process, | 467 EXPECT_NE(isolated_bar_process, |
468 new_shell->web_contents()->GetMainFrame()->GetProcess()); | 468 new_shell->web_contents()->GetMainFrame()->GetProcess()); |
469 } | 469 } |
470 | 470 |
| 471 // Check that subdomains on an isolated origin (e.g., bar.isolated.foo.com) |
| 472 // also end up in the isolated origin's SiteInstance. |
| 473 IN_PROC_BROWSER_TEST_F(IsolatedOriginTest, IsolatedOriginWithSubdomain) { |
| 474 // Start on a page with an isolated origin with a same-site iframe. |
| 475 GURL isolated_url(embedded_test_server()->GetURL("isolated.foo.com", |
| 476 "/page_with_iframe.html")); |
| 477 EXPECT_TRUE(NavigateToURL(shell(), isolated_url)); |
| 478 |
| 479 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| 480 FrameTreeNode* child = root->child_at(0); |
| 481 scoped_refptr<SiteInstance> isolated_instance = |
| 482 web_contents()->GetSiteInstance(); |
| 483 |
| 484 // Navigate iframe to the isolated origin's subdomain. |
| 485 GURL isolated_subdomain_url( |
| 486 embedded_test_server()->GetURL("bar.isolated.foo.com", "/title1.html")); |
| 487 NavigateIframeToURL(web_contents(), "test_iframe", isolated_subdomain_url); |
| 488 EXPECT_EQ(child->current_url(), isolated_subdomain_url); |
| 489 |
| 490 EXPECT_EQ(isolated_instance, child->current_frame_host()->GetSiteInstance()); |
| 491 EXPECT_FALSE(child->current_frame_host()->IsCrossProcessSubframe()); |
| 492 EXPECT_EQ(isolated_url.GetOrigin(), |
| 493 child->current_frame_host()->GetSiteInstance()->GetSiteURL()); |
| 494 |
| 495 // Now try navigating the main frame (renderer-initiated) to the isolated |
| 496 // origin's subdomain. This should not swap processes. |
| 497 TestNavigationObserver observer(web_contents()); |
| 498 EXPECT_TRUE( |
| 499 ExecuteScript(web_contents(), |
| 500 "location.href = '" + isolated_subdomain_url.spec() + "'")); |
| 501 observer.Wait(); |
| 502 EXPECT_EQ(isolated_instance, web_contents()->GetSiteInstance()); |
| 503 } |
| 504 |
471 } // namespace content | 505 } // namespace content |
OLD | NEW |