OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/site_per_process_browsertest.h" | 5 #include "content/browser/site_per_process_browsertest.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 8746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8757 NavigateFrameToURL(root->child_at(0), second_nav_url); | 8757 NavigateFrameToURL(root->child_at(0), second_nav_url); |
8758 EXPECT_EQ( | 8758 EXPECT_EQ( |
8759 "", root->child_at(0)->current_replication_state().feature_policy_header); | 8759 "", root->child_at(0)->current_replication_state().feature_policy_header); |
8760 | 8760 |
8761 // Navigate the iframe back to a page with a policy | 8761 // Navigate the iframe back to a page with a policy |
8762 NavigateFrameToURL(root->child_at(0), first_nav_url); | 8762 NavigateFrameToURL(root->child_at(0), first_nav_url); |
8763 EXPECT_EQ( | 8763 EXPECT_EQ( |
8764 "{\"vibrate\":[\"*\"]}", | 8764 "{\"vibrate\":[\"*\"]}", |
8765 root->child_at(0)->current_replication_state().feature_policy_header); | 8765 root->child_at(0)->current_replication_state().feature_policy_header); |
8766 } | 8766 } |
| 8767 |
| 8768 // Ensure that an iframe that navigates cross-site doesn't use the same process |
| 8769 // as its parent. Then when its parent navigates it via the "srcdoc" attribute, |
| 8770 // it must reuse its parent's process. |
| 8771 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| 8772 IframeSrcdocAfterCrossSiteNavigation) { |
| 8773 GURL parent_url(embedded_test_server()->GetURL( |
| 8774 "a.com", "/cross_site_iframe_factory.html?a(b)")); |
| 8775 GURL child_url(embedded_test_server()->GetURL( |
| 8776 "b.com", "/cross_site_iframe_factory.html?b()")); |
| 8777 GURL blank_url(url::kAboutBlankURL); |
| 8778 |
| 8779 // #1 Navigate to a page with a cross-site iframe. |
| 8780 EXPECT_TRUE(NavigateToURL(shell(), parent_url)); |
| 8781 |
| 8782 // Ensure that the iframe uses its own process. |
| 8783 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| 8784 ASSERT_EQ(1u, root->child_count()); |
| 8785 FrameTreeNode* child = root->child_at(0); |
| 8786 EXPECT_EQ(parent_url, root->current_url()); |
| 8787 EXPECT_EQ(child_url, child->current_url()); |
| 8788 EXPECT_NE(root->current_frame_host()->GetSiteInstance(), |
| 8789 child->current_frame_host()->GetSiteInstance()); |
| 8790 EXPECT_NE(root->current_frame_host()->GetProcess(), |
| 8791 child->current_frame_host()->GetProcess()); |
| 8792 |
| 8793 // #2 Navigate the iframe to its srcdoc attribute. |
| 8794 TestNavigationObserver load_observer(shell()->web_contents()); |
| 8795 EXPECT_TRUE(ExecuteScript( |
| 8796 root, "document.getElementById('child-0').srcdoc = 'srcdoc content';")); |
| 8797 load_observer.Wait(); |
| 8798 |
| 8799 // Ensure that the iframe reuses its parent's process. |
| 8800 EXPECT_EQ(blank_url, child->current_url()); |
| 8801 EXPECT_EQ(root->current_frame_host()->GetSiteInstance(), |
| 8802 child->current_frame_host()->GetSiteInstance()); |
| 8803 EXPECT_EQ(root->current_frame_host()->GetProcess(), |
| 8804 child->current_frame_host()->GetProcess()); |
| 8805 } |
| 8806 |
8767 } // namespace content | 8807 } // namespace content |
OLD | NEW |