| 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 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 GetFrameDeviceScaleFactor(web_contents())); | 630 GetFrameDeviceScaleFactor(web_contents())); |
| 631 | 631 |
| 632 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); | 632 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| 633 FrameTreeNode* child = root->child_at(0); | 633 FrameTreeNode* child = root->child_at(0); |
| 634 EXPECT_EQ(SitePerProcessHighDPIBrowserTest::kDeviceScaleFactor, | 634 EXPECT_EQ(SitePerProcessHighDPIBrowserTest::kDeviceScaleFactor, |
| 635 GetFrameDeviceScaleFactor(child)); | 635 GetFrameDeviceScaleFactor(child)); |
| 636 } | 636 } |
| 637 | 637 |
| 638 // Ensure that navigating subframes in --site-per-process mode works and the | 638 // Ensure that navigating subframes in --site-per-process mode works and the |
| 639 // correct documents are committed. | 639 // correct documents are committed. |
| 640 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) { | 640 #if defined(OS_WIN) |
| 641 // This test is flaky on Windows, see https://crbug.com/629419. |
| 642 #define MAYBE_CrossSiteIframe DISABLED_CrossSiteIframe |
| 643 #else |
| 644 #define MAYBE_CrossSiteIframe CrossSiteIframe |
| 645 #endif |
| 646 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_CrossSiteIframe) { |
| 641 GURL main_url(embedded_test_server()->GetURL( | 647 GURL main_url(embedded_test_server()->GetURL( |
| 642 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))")); | 648 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))")); |
| 643 NavigateToURL(shell(), main_url); | 649 NavigateToURL(shell(), main_url); |
| 644 | 650 |
| 645 // It is safe to obtain the root frame tree node here, as it doesn't change. | 651 // It is safe to obtain the root frame tree node here, as it doesn't change. |
| 646 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); | 652 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| 647 | 653 |
| 648 TestNavigationObserver observer(shell()->web_contents()); | 654 TestNavigationObserver observer(shell()->web_contents()); |
| 649 | 655 |
| 650 // Load same-site page into iframe. | 656 // Load same-site page into iframe. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 " +--Site A ------- proxies for B\n" | 716 " +--Site A ------- proxies for B\n" |
| 711 " |--Site A -- proxies for B\n" | 717 " |--Site A -- proxies for B\n" |
| 712 " +--Site A -- proxies for B\n" | 718 " +--Site A -- proxies for B\n" |
| 713 " +--Site A -- proxies for B\n" | 719 " +--Site A -- proxies for B\n" |
| 714 "Where A = http://a.com/\n" | 720 "Where A = http://a.com/\n" |
| 715 " B = http://foo.com/", | 721 " B = http://foo.com/", |
| 716 DepictFrameTree(root)); | 722 DepictFrameTree(root)); |
| 717 | 723 |
| 718 // Load another cross-site page into the same iframe. | 724 // Load another cross-site page into the same iframe. |
| 719 url = embedded_test_server()->GetURL("bar.com", "/title3.html"); | 725 url = embedded_test_server()->GetURL("bar.com", "/title3.html"); |
| 720 RenderFrameDeletedObserver deleted_observer(child->current_frame_host()); | |
| 721 NavigateFrameToURL(root->child_at(0), url); | 726 NavigateFrameToURL(root->child_at(0), url); |
| 722 deleted_observer.WaitUntilDeleted(); | |
| 723 EXPECT_TRUE(observer.last_navigation_succeeded()); | 727 EXPECT_TRUE(observer.last_navigation_succeeded()); |
| 724 EXPECT_EQ(url, observer.last_navigation_url()); | 728 EXPECT_EQ(url, observer.last_navigation_url()); |
| 725 | 729 |
| 726 // Check again that a new process is created and is different from the | 730 // Check again that a new process is created and is different from the |
| 727 // top level one and the previous one. | 731 // top level one and the previous one. |
| 728 ASSERT_EQ(2U, root->child_count()); | 732 ASSERT_EQ(2U, root->child_count()); |
| 729 child = root->child_at(0); | 733 child = root->child_at(0); |
| 730 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), | 734 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), |
| 731 child->current_frame_host()->render_view_host()); | 735 child->current_frame_host()->render_view_host()); |
| 732 EXPECT_NE(rvh, child->current_frame_host()->render_view_host()); | 736 EXPECT_NE(rvh, child->current_frame_host()->render_view_host()); |
| (...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1706 EXPECT_EQ( | 1710 EXPECT_EQ( |
| 1707 " Site A ------------ proxies for B C\n" | 1711 " Site A ------------ proxies for B C\n" |
| 1708 " |--Site B ------- proxies for A C\n" | 1712 " |--Site B ------- proxies for A C\n" |
| 1709 " +--Site C ------- proxies for A B\n" | 1713 " +--Site C ------- proxies for A B\n" |
| 1710 "Where A = http://a.com/\n" | 1714 "Where A = http://a.com/\n" |
| 1711 " B = http://foo.com/ (no process)\n" | 1715 " B = http://foo.com/ (no process)\n" |
| 1712 " C = http://bar.com/", | 1716 " C = http://bar.com/", |
| 1713 DepictFrameTree(root)); | 1717 DepictFrameTree(root)); |
| 1714 } | 1718 } |
| 1715 | 1719 |
| 1716 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, NavigateRemoteFrame) { | 1720 #if defined(OS_WIN) |
| 1721 // This test is flaky on Windows, see https://crbug.com/629419. |
| 1722 #define MAYBE_NavigateRemoteFrame DISABLED_NavigateRemoteFrame |
| 1723 #else |
| 1724 #define MAYBE_NavigateRemoteFrame NavigateRemoteFrame |
| 1725 #endif |
| 1726 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_NavigateRemoteFrame) { |
| 1717 GURL main_url(embedded_test_server()->GetURL( | 1727 GURL main_url(embedded_test_server()->GetURL( |
| 1718 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))")); | 1728 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))")); |
| 1719 NavigateToURL(shell(), main_url); | 1729 NavigateToURL(shell(), main_url); |
| 1720 | 1730 |
| 1721 // It is safe to obtain the root frame tree node here, as it doesn't change. | 1731 // It is safe to obtain the root frame tree node here, as it doesn't change. |
| 1722 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); | 1732 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| 1723 | 1733 |
| 1724 TestNavigationObserver observer(shell()->web_contents()); | 1734 TestNavigationObserver observer(shell()->web_contents()); |
| 1725 | 1735 |
| 1726 // Load same-site page into iframe. | 1736 // Load same-site page into iframe. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1746 " +--Site A -- proxies for B\n" | 1756 " +--Site A -- proxies for B\n" |
| 1747 "Where A = http://a.com/\n" | 1757 "Where A = http://a.com/\n" |
| 1748 " B = http://foo.com/", | 1758 " B = http://foo.com/", |
| 1749 DepictFrameTree(root)); | 1759 DepictFrameTree(root)); |
| 1750 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance(); | 1760 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance(); |
| 1751 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance); | 1761 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance); |
| 1752 | 1762 |
| 1753 // Emulate the main frame changing the src of the iframe such that it | 1763 // Emulate the main frame changing the src of the iframe such that it |
| 1754 // navigates cross-site. | 1764 // navigates cross-site. |
| 1755 url = embedded_test_server()->GetURL("bar.com", "/title3.html"); | 1765 url = embedded_test_server()->GetURL("bar.com", "/title3.html"); |
| 1756 RenderFrameDeletedObserver deleted_observer(child->current_frame_host()); | |
| 1757 NavigateIframeToURL(shell()->web_contents(), "child-0", url); | 1766 NavigateIframeToURL(shell()->web_contents(), "child-0", url); |
| 1758 deleted_observer.WaitUntilDeleted(); | |
| 1759 EXPECT_TRUE(observer.last_navigation_succeeded()); | 1767 EXPECT_TRUE(observer.last_navigation_succeeded()); |
| 1760 EXPECT_EQ(url, observer.last_navigation_url()); | 1768 EXPECT_EQ(url, observer.last_navigation_url()); |
| 1761 | 1769 |
| 1762 // Check again that a new process is created and is different from the | 1770 // Check again that a new process is created and is different from the |
| 1763 // top level one and the previous one. | 1771 // top level one and the previous one. |
| 1764 EXPECT_EQ( | 1772 EXPECT_EQ( |
| 1765 " Site A ------------ proxies for C\n" | 1773 " Site A ------------ proxies for C\n" |
| 1766 " |--Site C ------- proxies for A\n" | 1774 " |--Site C ------- proxies for A\n" |
| 1767 " +--Site A ------- proxies for C\n" | 1775 " +--Site A ------- proxies for C\n" |
| 1768 " |--Site A -- proxies for C\n" | 1776 " |--Site A -- proxies for C\n" |
| (...skipping 2464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4233 // wait for reply. | 4241 // wait for reply. |
| 4234 PostMessageAndWaitForReply(child1, "postToSibling('subframe-msg', 2)", | 4242 PostMessageAndWaitForReply(child1, "postToSibling('subframe-msg', 2)", |
| 4235 "\"done-1-2-name\""); | 4243 "\"done-1-2-name\""); |
| 4236 | 4244 |
| 4237 // Verify the total number of received messages for each subframe. | 4245 // Verify the total number of received messages for each subframe. |
| 4238 EXPECT_EQ(1, GetReceivedMessages(child0)); | 4246 EXPECT_EQ(1, GetReceivedMessages(child0)); |
| 4239 EXPECT_EQ(2, GetReceivedMessages(child1)); | 4247 EXPECT_EQ(2, GetReceivedMessages(child1)); |
| 4240 EXPECT_EQ(1, GetReceivedMessages(child2)); | 4248 EXPECT_EQ(1, GetReceivedMessages(child2)); |
| 4241 } | 4249 } |
| 4242 | 4250 |
| 4243 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, RFPHDestruction) { | 4251 #if defined(OS_WIN) |
| 4252 // This test is flaky on Windows, see https://crbug.com/629419. |
| 4253 #define MAYBE_RFPHDestruction DISABLED_RFPHDestruction |
| 4254 #else |
| 4255 #define MAYBE_RFPHDestruction RFPHDestruction |
| 4256 #endif |
| 4257 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_RFPHDestruction) { |
| 4244 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); | 4258 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
| 4245 NavigateToURL(shell(), main_url); | 4259 NavigateToURL(shell(), main_url); |
| 4246 | 4260 |
| 4247 // It is safe to obtain the root frame tree node here, as it doesn't change. | 4261 // It is safe to obtain the root frame tree node here, as it doesn't change. |
| 4248 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); | 4262 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| 4249 | 4263 |
| 4250 TestNavigationObserver observer(shell()->web_contents()); | 4264 TestNavigationObserver observer(shell()->web_contents()); |
| 4251 | 4265 |
| 4252 // Load cross-site page into iframe. | 4266 // Load cross-site page into iframe. |
| 4253 FrameTreeNode* child = root->child_at(0); | 4267 FrameTreeNode* child = root->child_at(0); |
| 4254 GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html"); | 4268 GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html"); |
| 4255 NavigateFrameToURL(root->child_at(0), url); | 4269 NavigateFrameToURL(root->child_at(0), url); |
| 4256 EXPECT_TRUE(observer.last_navigation_succeeded()); | 4270 EXPECT_TRUE(observer.last_navigation_succeeded()); |
| 4257 EXPECT_EQ(url, observer.last_navigation_url()); | 4271 EXPECT_EQ(url, observer.last_navigation_url()); |
| 4258 EXPECT_EQ( | 4272 EXPECT_EQ( |
| 4259 " Site A ------------ proxies for B\n" | 4273 " Site A ------------ proxies for B\n" |
| 4260 " |--Site B ------- proxies for A\n" | 4274 " |--Site B ------- proxies for A\n" |
| 4261 " +--Site A ------- proxies for B\n" | 4275 " +--Site A ------- proxies for B\n" |
| 4262 " |--Site A -- proxies for B\n" | 4276 " |--Site A -- proxies for B\n" |
| 4263 " +--Site A -- proxies for B\n" | 4277 " +--Site A -- proxies for B\n" |
| 4264 " +--Site A -- proxies for B\n" | 4278 " +--Site A -- proxies for B\n" |
| 4265 "Where A = http://127.0.0.1/\n" | 4279 "Where A = http://127.0.0.1/\n" |
| 4266 " B = http://foo.com/", | 4280 " B = http://foo.com/", |
| 4267 DepictFrameTree(root)); | 4281 DepictFrameTree(root)); |
| 4268 | 4282 |
| 4269 // Load another cross-site page. | 4283 // Load another cross-site page. |
| 4270 url = embedded_test_server()->GetURL("bar.com", "/title3.html"); | 4284 url = embedded_test_server()->GetURL("bar.com", "/title3.html"); |
| 4271 RenderFrameDeletedObserver deleted_observer_b(child->current_frame_host()); | |
| 4272 NavigateIframeToURL(shell()->web_contents(), "test", url); | 4285 NavigateIframeToURL(shell()->web_contents(), "test", url); |
| 4273 deleted_observer_b.WaitUntilDeleted(); | |
| 4274 EXPECT_TRUE(observer.last_navigation_succeeded()); | 4286 EXPECT_TRUE(observer.last_navigation_succeeded()); |
| 4275 EXPECT_EQ(url, observer.last_navigation_url()); | 4287 EXPECT_EQ(url, observer.last_navigation_url()); |
| 4276 EXPECT_EQ( | 4288 EXPECT_EQ( |
| 4277 " Site A ------------ proxies for C\n" | 4289 " Site A ------------ proxies for C\n" |
| 4278 " |--Site C ------- proxies for A\n" | 4290 " |--Site C ------- proxies for A\n" |
| 4279 " +--Site A ------- proxies for C\n" | 4291 " +--Site A ------- proxies for C\n" |
| 4280 " |--Site A -- proxies for C\n" | 4292 " |--Site A -- proxies for C\n" |
| 4281 " +--Site A -- proxies for C\n" | 4293 " +--Site A -- proxies for C\n" |
| 4282 " +--Site A -- proxies for C\n" | 4294 " +--Site A -- proxies for C\n" |
| 4283 "Where A = http://127.0.0.1/\n" | 4295 "Where A = http://127.0.0.1/\n" |
| 4284 " C = http://bar.com/", | 4296 " C = http://bar.com/", |
| 4285 DepictFrameTree(root)); | 4297 DepictFrameTree(root)); |
| 4286 | 4298 |
| 4287 // Navigate back to the parent's origin. | 4299 // Navigate back to the parent's origin. |
| 4288 RenderFrameDeletedObserver deleted_observer_c(child->current_frame_host()); | 4300 RenderFrameDeletedObserver deleted_observer(child->current_frame_host()); |
| 4289 url = embedded_test_server()->GetURL("/title1.html"); | 4301 url = embedded_test_server()->GetURL("/title1.html"); |
| 4290 NavigateFrameToURL(child, url); | 4302 NavigateFrameToURL(child, url); |
| 4291 EXPECT_EQ(url, observer.last_navigation_url()); | 4303 EXPECT_EQ(url, observer.last_navigation_url()); |
| 4292 EXPECT_TRUE(observer.last_navigation_succeeded()); | 4304 EXPECT_TRUE(observer.last_navigation_succeeded()); |
| 4293 | 4305 |
| 4294 // Wait for the old process to exit, to verify that the proxies go away. | 4306 // Wait for the old process to exit, to verify that the proxies go away. |
| 4295 deleted_observer_c.WaitUntilDeleted(); | 4307 deleted_observer.WaitUntilDeleted(); |
| 4296 EXPECT_EQ( | 4308 EXPECT_EQ( |
| 4297 " Site A\n" | 4309 " Site A\n" |
| 4298 " |--Site A\n" | 4310 " |--Site A\n" |
| 4299 " +--Site A\n" | 4311 " +--Site A\n" |
| 4300 " |--Site A\n" | 4312 " |--Site A\n" |
| 4301 " +--Site A\n" | 4313 " +--Site A\n" |
| 4302 " +--Site A\n" | 4314 " +--Site A\n" |
| 4303 "Where A = http://127.0.0.1/", | 4315 "Where A = http://127.0.0.1/", |
| 4304 DepictFrameTree(root)); | 4316 DepictFrameTree(root)); |
| 4305 } | 4317 } |
| (...skipping 4208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8514 EXPECT_TRUE(NavigateToURL(shell(), b_url)); | 8526 EXPECT_TRUE(NavigateToURL(shell(), b_url)); |
| 8515 | 8527 |
| 8516 base::string16 expected_title(base::UTF8ToUTF16("foo")); | 8528 base::string16 expected_title(base::UTF8ToUTF16("foo")); |
| 8517 TitleWatcher title_watcher(popup2->web_contents(), expected_title); | 8529 TitleWatcher title_watcher(popup2->web_contents(), expected_title); |
| 8518 EXPECT_TRUE(ExecuteScript( | 8530 EXPECT_TRUE(ExecuteScript( |
| 8519 shell(), "window.open('','popup2').postMessage('foo', '*');")); | 8531 shell(), "window.open('','popup2').postMessage('foo', '*');")); |
| 8520 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | 8532 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
| 8521 } | 8533 } |
| 8522 | 8534 |
| 8523 } // namespace content | 8535 } // namespace content |
| OLD | NEW |