| 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 8785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8796 | 8796 |
| 8797 // Ensure that an iframe that navigates cross-site doesn't use the same process | 8797 // Ensure that an iframe that navigates cross-site doesn't use the same process |
| 8798 // as its parent. Then when its parent navigates it via the "srcdoc" attribute, | 8798 // as its parent. Then when its parent navigates it via the "srcdoc" attribute, |
| 8799 // it must reuse its parent's process. | 8799 // it must reuse its parent's process. |
| 8800 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 8800 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| 8801 IframeSrcdocAfterCrossSiteNavigation) { | 8801 IframeSrcdocAfterCrossSiteNavigation) { |
| 8802 GURL parent_url(embedded_test_server()->GetURL( | 8802 GURL parent_url(embedded_test_server()->GetURL( |
| 8803 "a.com", "/cross_site_iframe_factory.html?a(b)")); | 8803 "a.com", "/cross_site_iframe_factory.html?a(b)")); |
| 8804 GURL child_url(embedded_test_server()->GetURL( | 8804 GURL child_url(embedded_test_server()->GetURL( |
| 8805 "b.com", "/cross_site_iframe_factory.html?b()")); | 8805 "b.com", "/cross_site_iframe_factory.html?b()")); |
| 8806 GURL blank_url(url::kAboutBlankURL); | 8806 GURL srcdoc_url(kAboutSrcDocURL); |
| 8807 | 8807 |
| 8808 // #1 Navigate to a page with a cross-site iframe. | 8808 // #1 Navigate to a page with a cross-site iframe. |
| 8809 EXPECT_TRUE(NavigateToURL(shell(), parent_url)); | 8809 EXPECT_TRUE(NavigateToURL(shell(), parent_url)); |
| 8810 | 8810 |
| 8811 // Ensure that the iframe uses its own process. | 8811 // Ensure that the iframe uses its own process. |
| 8812 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); | 8812 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| 8813 ASSERT_EQ(1u, root->child_count()); | 8813 ASSERT_EQ(1u, root->child_count()); |
| 8814 FrameTreeNode* child = root->child_at(0); | 8814 FrameTreeNode* child = root->child_at(0); |
| 8815 EXPECT_EQ(parent_url, root->current_url()); | 8815 EXPECT_EQ(parent_url, root->current_url()); |
| 8816 EXPECT_EQ(child_url, child->current_url()); | 8816 EXPECT_EQ(child_url, child->current_url()); |
| 8817 EXPECT_NE(root->current_frame_host()->GetSiteInstance(), | 8817 EXPECT_NE(root->current_frame_host()->GetSiteInstance(), |
| 8818 child->current_frame_host()->GetSiteInstance()); | 8818 child->current_frame_host()->GetSiteInstance()); |
| 8819 EXPECT_NE(root->current_frame_host()->GetProcess(), | 8819 EXPECT_NE(root->current_frame_host()->GetProcess(), |
| 8820 child->current_frame_host()->GetProcess()); | 8820 child->current_frame_host()->GetProcess()); |
| 8821 | 8821 |
| 8822 // #2 Navigate the iframe to its srcdoc attribute. | 8822 // #2 Navigate the iframe to its srcdoc attribute. |
| 8823 TestNavigationObserver load_observer(shell()->web_contents()); | 8823 TestNavigationObserver load_observer(shell()->web_contents()); |
| 8824 EXPECT_TRUE(ExecuteScript( | 8824 EXPECT_TRUE(ExecuteScript( |
| 8825 root, "document.getElementById('child-0').srcdoc = 'srcdoc content';")); | 8825 root, "document.getElementById('child-0').srcdoc = 'srcdoc content';")); |
| 8826 load_observer.Wait(); | 8826 load_observer.Wait(); |
| 8827 | 8827 |
| 8828 // Ensure that the iframe reuses its parent's process. | 8828 // Ensure that the iframe reuses its parent's process. |
| 8829 EXPECT_EQ(blank_url, child->current_url()); | 8829 EXPECT_EQ(srcdoc_url, child->current_url()); |
| 8830 EXPECT_EQ(root->current_frame_host()->GetSiteInstance(), | 8830 EXPECT_EQ(root->current_frame_host()->GetSiteInstance(), |
| 8831 child->current_frame_host()->GetSiteInstance()); | 8831 child->current_frame_host()->GetSiteInstance()); |
| 8832 EXPECT_EQ(root->current_frame_host()->GetProcess(), | 8832 EXPECT_EQ(root->current_frame_host()->GetProcess(), |
| 8833 child->current_frame_host()->GetProcess()); | 8833 child->current_frame_host()->GetProcess()); |
| 8834 } | 8834 } |
| 8835 | 8835 |
| 8836 } // namespace content | 8836 } // namespace content |
| OLD | NEW |