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

Side by Side Diff: content/browser/site_per_process_browsertest.cc

Issue 536143002: Do not create proxy hosts in the subtree of navigating frame. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update CreateCrossProcessSubframeProxies Created 6 years, 3 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 (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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/strings/stringprintf.h" 6 #include "base/strings/stringprintf.h"
7 #include "content/browser/frame_host/cross_process_frame_connector.h" 7 #include "content/browser/frame_host/cross_process_frame_connector.h"
8 #include "content/browser/frame_host/frame_tree.h" 8 #include "content/browser/frame_host/frame_tree.h"
9 #include "content/browser/frame_host/navigator.h"
9 #include "content/browser/frame_host/render_frame_proxy_host.h" 10 #include "content/browser/frame_host/render_frame_proxy_host.h"
10 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" 11 #include "content/browser/frame_host/render_widget_host_view_child_frame.h"
11 #include "content/browser/renderer_host/render_view_host_impl.h" 12 #include "content/browser/renderer_host/render_view_host_impl.h"
12 #include "content/browser/web_contents/web_contents_impl.h" 13 #include "content/browser/web_contents/web_contents_impl.h"
13 #include "content/public/browser/notification_observer.h" 14 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_service.h" 15 #include "content/public/browser/notification_service.h"
15 #include "content/public/browser/notification_types.h" 16 #include "content/public/browser/notification_types.h"
16 #include "content/public/browser/web_contents_observer.h" 17 #include "content/public/browser/web_contents_observer.h"
17 #include "content/public/common/content_switches.h" 18 #include "content/public/common/content_switches.h"
18 #include "content/public/test/browser_test_utils.h" 19 #include "content/public/test/browser_test_utils.h"
19 #include "content/public/test/content_browser_test.h" 20 #include "content/public/test/content_browser_test.h"
20 #include "content/public/test/content_browser_test_utils.h" 21 #include "content/public/test/content_browser_test_utils.h"
21 #include "content/public/test/test_utils.h" 22 #include "content/public/test/test_utils.h"
22 #include "content/shell/browser/shell.h" 23 #include "content/shell/browser/shell.h"
23 #include "content/test/content_browser_test_utils_internal.h" 24 #include "content/test/content_browser_test_utils_internal.h"
25 #include "content/test/test_frame_navigation_observer.h"
24 #include "net/dns/mock_host_resolver.h" 26 #include "net/dns/mock_host_resolver.h"
25 #include "url/gurl.h" 27 #include "url/gurl.h"
26 28
27 namespace content { 29 namespace content {
28 30
29 class SitePerProcessWebContentsObserver: public WebContentsObserver { 31 class SitePerProcessWebContentsObserver: public WebContentsObserver {
30 public: 32 public:
31 explicit SitePerProcessWebContentsObserver(WebContents* web_contents) 33 explicit SitePerProcessWebContentsObserver(WebContents* web_contents)
32 : WebContentsObserver(web_contents), 34 : WebContentsObserver(web_contents),
33 navigation_succeeded_(false) {} 35 navigation_succeeded_(false) {}
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 GURL server_redirect_http_url(test_server()->GetURL( 561 GURL server_redirect_http_url(test_server()->GetURL(
560 "server-redirect?" + client_redirect_http_url.spec())); 562 "server-redirect?" + client_redirect_http_url.spec()));
561 EXPECT_TRUE(NavigateIframeToURL(shell(), server_redirect_http_url, "test")); 563 EXPECT_TRUE(NavigateIframeToURL(shell(), server_redirect_http_url, "test"));
562 564
563 // DidFailProvisionalLoad when navigating to client_redirect_http_url. 565 // DidFailProvisionalLoad when navigating to client_redirect_http_url.
564 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url); 566 EXPECT_EQ(observer.navigation_url(), client_redirect_http_url);
565 EXPECT_FALSE(observer.navigation_succeeded()); 567 EXPECT_FALSE(observer.navigation_succeeded());
566 } 568 }
567 } 569 }
568 570
571 // Ensure that when navigating a frame cross-process RenderFrameProxyHosts are
572 // created in the FrameTree skipping the subtree of the navigating frame.
573 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ProxiesCreationSkipsSubtree) {
Charlie Reis 2014/09/10 07:39:10 nit: ProxyCreationSkipsSubtree
nasko 2014/09/10 19:36:34 Done.
574 host_resolver()->AddRule("*", "127.0.0.1");
575 ASSERT_TRUE(test_server()->Start());
576 GURL main_url(test_server()->GetURL("files/site_per_process_main.html"));
577 NavigateToURL(shell(), main_url);
578
579 // It is safe to obtain the root frame tree node here, as it doesn't change.
580 FrameTreeNode* root =
581 static_cast<WebContentsImpl*>(shell()->web_contents())->
582 GetFrameTree()->root();
583
584 EXPECT_TRUE(root->child_at(1) != NULL);
585 EXPECT_EQ(2U, root->child_at(1)->child_count());
586
587 {
588 // Load same-site page into iframe.
589 SitePerProcessWebContentsObserver observer(shell()->web_contents());
590 GURL http_url(test_server()->GetURL("files/title1.html"));
591 NavigateFrameToURL(root->child_at(0), http_url);
592 EXPECT_EQ(http_url, observer.navigation_url());
593 EXPECT_TRUE(observer.navigation_succeeded());
594 RenderFrameProxyHost* proxy_to_parent =
595 root->child_at(0)->render_manager()->GetRenderFrameProxyHost(
596 shell()->web_contents()->GetSiteInstance());
597 EXPECT_FALSE(proxy_to_parent);
598 }
599
600 // Create the cross-site URL to navigate to.
601 GURL::Replacements replace_host;
602 std::string foo_com("foo.com");
603 GURL cross_site_url(test_server()->GetURL("files/frame_tree/1-1.html"));
604 replace_host.SetHostStr(foo_com);
605 cross_site_url = cross_site_url.ReplaceComponents(replace_host);
606
607 // Load cross-site page into the second iframe without waiting for the
608 // navigation to complete. Once LoadURLWithParams returns, we would expect
609 // proxies to have been created in the frame tree, but children of the
610 // navigating frame to still be present. The reason is that we don't run the
611 // message loop, so no IPCs that alter the frame tree can be processed.
612 FrameTreeNode* child = root->child_at(1);
613 SiteInstance* site;
614 {
615 SitePerProcessWebContentsObserver observer(shell()->web_contents());
616 TestFrameNavigationObserver navigation_observer(child);
617 NavigationController::LoadURLParams params(cross_site_url);
618 params.transition_type = PageTransitionFromInt(PAGE_TRANSITION_LINK);
619 params.frame_tree_node_id = child->frame_tree_node_id();
620 child->navigator()->GetController()->LoadURLWithParams(params);
621 EXPECT_TRUE(child->render_manager()->pending_frame_host());
622
623 site = child->render_manager()->pending_frame_host()->GetSiteInstance();
624 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site);
625
626 EXPECT_TRUE(root->render_manager()->GetRenderFrameProxyHost(site));
627 EXPECT_TRUE(
628 root->child_at(0)->render_manager()->GetRenderFrameProxyHost(site));
629 EXPECT_FALSE(child->render_manager()->GetRenderFrameProxyHost(site));
630 for (size_t i = 0; i < child->child_count(); ++i){
Charlie Reis 2014/09/10 07:39:10 nit: Space after )
nasko 2014/09/10 19:36:34 Done.
631 EXPECT_FALSE(
632 child->child_at(i)->render_manager()->GetRenderFrameProxyHost(site));
633 }
634 // Now that the verification is done, run the message loop and wait for the
635 // navigation to complete.
636 navigation_observer.Wait();
637 EXPECT_FALSE(child->render_manager()->pending_frame_host());
638 EXPECT_EQ(cross_site_url, observer.navigation_url());
639 EXPECT_TRUE(observer.navigation_succeeded());
Charlie Reis 2014/09/10 07:39:10 Are the children FTNs now deleted? Can we verify
nasko 2014/09/10 19:36:34 Not here, since I load a page that has subframes.
640 }
641
642 // Load another cross-site page into the same iframe.
643 cross_site_url = test_server()->GetURL("files/title2.html");
644 std::string bar_com("bar.com");
645 replace_host.SetHostStr(bar_com);
646 cross_site_url = cross_site_url.ReplaceComponents(replace_host);
647
648 {
649 // Perform the same checks as the first cross-site navigation, since
650 // there have been issues in subsequent cross-site navigations. Also ensure
651 // that the SiteInstance has properly changed.
652 // TODO(nasko): Once we have proper cleanup of resources, add code to
653 // verify that the intermediate SiteInstance/RenderFrameHost have been
654 // properly cleaned up.
655 SitePerProcessWebContentsObserver observer(shell()->web_contents());
656 TestFrameNavigationObserver navigation_observer(child);
657 NavigationController::LoadURLParams params(cross_site_url);
658 params.transition_type = PageTransitionFromInt(PAGE_TRANSITION_LINK);
659 params.frame_tree_node_id = child->frame_tree_node_id();
660 child->navigator()->GetController()->LoadURLWithParams(params);
661 EXPECT_TRUE(child->render_manager()->pending_frame_host() != NULL);
662
663 SiteInstance* site2 =
664 child->render_manager()->pending_frame_host()->GetSiteInstance();
665 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site2);
666 EXPECT_NE(site, site2);
667
668 EXPECT_TRUE(root->render_manager()->GetRenderFrameProxyHost(site2));
669 EXPECT_TRUE(
670 root->child_at(0)->render_manager()->GetRenderFrameProxyHost(site2));
671 EXPECT_FALSE(child->render_manager()->GetRenderFrameProxyHost(site2));
672 for (size_t i = 0; i < child->child_count(); ++i) {
673 EXPECT_FALSE(
674 child->child_at(i)->render_manager()->GetRenderFrameProxyHost(site2));
675 }
676
677 navigation_observer.Wait();
678 EXPECT_EQ(cross_site_url, observer.navigation_url());
679 EXPECT_TRUE(observer.navigation_succeeded());
680 }
681 }
682
569 } // namespace content 683 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698