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

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

Issue 1652483002: Browser Side Text Input State Tracking for OOPIF. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed a Compile Error Created 4 years, 9 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 "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 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 base::CommandLine* command_line) { 556 base::CommandLine* command_line) {
557 IsolateAllSitesForTesting(command_line); 557 IsolateAllSitesForTesting(command_line);
558 }; 558 };
559 559
560 void SitePerProcessBrowserTest::SetUpOnMainThread() { 560 void SitePerProcessBrowserTest::SetUpOnMainThread() {
561 host_resolver()->AddRule("*", "127.0.0.1"); 561 host_resolver()->AddRule("*", "127.0.0.1");
562 ASSERT_TRUE(embedded_test_server()->Start()); 562 ASSERT_TRUE(embedded_test_server()->Start());
563 SetupCrossSiteRedirector(embedded_test_server()); 563 SetupCrossSiteRedirector(embedded_test_server());
564 } 564 }
565 565
566 WebContentsImpl* SitePerProcessBrowserTest::GetWebContents() {
567 return static_cast<WebContentsImpl*>(shell()->web_contents());
568 }
566 // 569 //
567 // SitePerProcessHighDPIBrowserTest 570 // SitePerProcessHighDPIBrowserTest
568 // 571 //
569 572
570 573
571 class SitePerProcessHighDPIBrowserTest : public SitePerProcessBrowserTest { 574 class SitePerProcessHighDPIBrowserTest : public SitePerProcessBrowserTest {
572 public: 575 public:
573 SitePerProcessHighDPIBrowserTest() {} 576 SitePerProcessHighDPIBrowserTest() {}
574 577
575 protected: 578 protected:
(...skipping 19 matching lines...) Expand all
595 }; 598 };
596 599
597 // Ensure that navigating subframes in --site-per-process mode works and the 600 // Ensure that navigating subframes in --site-per-process mode works and the
598 // correct documents are committed. 601 // correct documents are committed.
599 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) { 602 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) {
600 GURL main_url(embedded_test_server()->GetURL( 603 GURL main_url(embedded_test_server()->GetURL(
601 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))")); 604 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))"));
602 NavigateToURL(shell(), main_url); 605 NavigateToURL(shell(), main_url);
603 606
604 // It is safe to obtain the root frame tree node here, as it doesn't change. 607 // It is safe to obtain the root frame tree node here, as it doesn't change.
605 FrameTreeNode* root = 608 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
606 static_cast<WebContentsImpl*>(shell()->web_contents())->
607 GetFrameTree()->root();
608 609
609 TestNavigationObserver observer(shell()->web_contents()); 610 TestNavigationObserver observer(shell()->web_contents());
610 611
611 // Load same-site page into iframe. 612 // Load same-site page into iframe.
612 FrameTreeNode* child = root->child_at(0); 613 FrameTreeNode* child = root->child_at(0);
613 GURL http_url(embedded_test_server()->GetURL("a.com", "/title1.html")); 614 GURL http_url(embedded_test_server()->GetURL("a.com", "/title1.html"));
614 NavigateFrameToURL(child, http_url); 615 NavigateFrameToURL(child, http_url);
615 EXPECT_EQ(http_url, observer.last_navigation_url()); 616 EXPECT_EQ(http_url, observer.last_navigation_url());
616 EXPECT_TRUE(observer.last_navigation_succeeded()); 617 EXPECT_TRUE(observer.last_navigation_succeeded());
617 { 618 {
618 // There should be only one RenderWidgetHost when there are no 619 // There should be only one RenderWidgetHost when there are no
619 // cross-process iframes. 620 // cross-process iframes.
620 std::set<RenderWidgetHostView*> views_set = 621 std::set<RenderWidgetHostView*> views_set =
621 static_cast<WebContentsImpl*>(shell()->web_contents()) 622 GetWebContents()->GetRenderWidgetHostViewsInTree();
622 ->GetRenderWidgetHostViewsInTree();
623 EXPECT_EQ(1U, views_set.size()); 623 EXPECT_EQ(1U, views_set.size());
624 } 624 }
625 625
626 EXPECT_EQ( 626 EXPECT_EQ(
627 " Site A\n" 627 " Site A\n"
628 " |--Site A\n" 628 " |--Site A\n"
629 " +--Site A\n" 629 " +--Site A\n"
630 " |--Site A\n" 630 " |--Site A\n"
631 " +--Site A\n" 631 " +--Site A\n"
632 " +--Site A\n" 632 " +--Site A\n"
(...skipping 12 matching lines...) Expand all
645 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance(); 645 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance();
646 RenderViewHost* rvh = child->current_frame_host()->render_view_host(); 646 RenderViewHost* rvh = child->current_frame_host()->render_view_host();
647 RenderProcessHost* rph = child->current_frame_host()->GetProcess(); 647 RenderProcessHost* rph = child->current_frame_host()->GetProcess();
648 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), rvh); 648 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), rvh);
649 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance); 649 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance);
650 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), rph); 650 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), rph);
651 { 651 {
652 // There should be now two RenderWidgetHosts, one for each process 652 // There should be now two RenderWidgetHosts, one for each process
653 // rendering a frame. 653 // rendering a frame.
654 std::set<RenderWidgetHostView*> views_set = 654 std::set<RenderWidgetHostView*> views_set =
655 static_cast<WebContentsImpl*>(shell()->web_contents()) 655 GetWebContents()->GetRenderWidgetHostViewsInTree();
656 ->GetRenderWidgetHostViewsInTree();
657 EXPECT_EQ(2U, views_set.size()); 656 EXPECT_EQ(2U, views_set.size());
658 } 657 }
659 RenderFrameProxyHost* proxy_to_parent = 658 RenderFrameProxyHost* proxy_to_parent =
660 child->render_manager()->GetProxyToParent(); 659 child->render_manager()->GetProxyToParent();
661 EXPECT_TRUE(proxy_to_parent); 660 EXPECT_TRUE(proxy_to_parent);
662 EXPECT_TRUE(proxy_to_parent->cross_process_frame_connector()); 661 EXPECT_TRUE(proxy_to_parent->cross_process_frame_connector());
663 // The out-of-process iframe should have its own RenderWidgetHost, 662 // The out-of-process iframe should have its own RenderWidgetHost,
664 // independent of any RenderViewHost. 663 // independent of any RenderViewHost.
665 EXPECT_NE( 664 EXPECT_NE(
666 rvh->GetWidget()->GetView(), 665 rvh->GetWidget()->GetView(),
(...skipping 26 matching lines...) Expand all
693 EXPECT_NE(rvh, child->current_frame_host()->render_view_host()); 692 EXPECT_NE(rvh, child->current_frame_host()->render_view_host());
694 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), 693 EXPECT_NE(shell()->web_contents()->GetSiteInstance(),
695 child->current_frame_host()->GetSiteInstance()); 694 child->current_frame_host()->GetSiteInstance());
696 EXPECT_NE(site_instance, 695 EXPECT_NE(site_instance,
697 child->current_frame_host()->GetSiteInstance()); 696 child->current_frame_host()->GetSiteInstance());
698 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), 697 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(),
699 child->current_frame_host()->GetProcess()); 698 child->current_frame_host()->GetProcess());
700 EXPECT_NE(rph, child->current_frame_host()->GetProcess()); 699 EXPECT_NE(rph, child->current_frame_host()->GetProcess());
701 { 700 {
702 std::set<RenderWidgetHostView*> views_set = 701 std::set<RenderWidgetHostView*> views_set =
703 static_cast<WebContentsImpl*>(shell()->web_contents()) 702 GetWebContents()->GetRenderWidgetHostViewsInTree();
704 ->GetRenderWidgetHostViewsInTree();
705 EXPECT_EQ(2U, views_set.size()); 703 EXPECT_EQ(2U, views_set.size());
706 } 704 }
707 EXPECT_EQ(proxy_to_parent, child->render_manager()->GetProxyToParent()); 705 EXPECT_EQ(proxy_to_parent, child->render_manager()->GetProxyToParent());
708 EXPECT_TRUE(proxy_to_parent->cross_process_frame_connector()); 706 EXPECT_TRUE(proxy_to_parent->cross_process_frame_connector());
709 EXPECT_NE( 707 EXPECT_NE(
710 child->current_frame_host()->render_view_host()->GetWidget()->GetView(), 708 child->current_frame_host()->render_view_host()->GetWidget()->GetView(),
711 proxy_to_parent->cross_process_frame_connector()->get_view_for_testing()); 709 proxy_to_parent->cross_process_frame_connector()->get_view_for_testing());
712 EXPECT_TRUE(child->current_frame_host()->GetRenderWidgetHost()); 710 EXPECT_TRUE(child->current_frame_host()->GetRenderWidgetHost());
713 711
714 EXPECT_EQ( 712 EXPECT_EQ(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 #else 759 #else
762 #define MAYBE_NestedSurfaceHitTestTest NestedSurfaceHitTestTest 760 #define MAYBE_NestedSurfaceHitTestTest NestedSurfaceHitTestTest
763 #endif 761 #endif
764 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 762 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
765 MAYBE_NestedSurfaceHitTestTest) { 763 MAYBE_NestedSurfaceHitTestTest) {
766 GURL main_url(embedded_test_server()->GetURL( 764 GURL main_url(embedded_test_server()->GetURL(
767 "/frame_tree/page_with_positioned_nested_frames.html")); 765 "/frame_tree/page_with_positioned_nested_frames.html"));
768 NavigateToURL(shell(), main_url); 766 NavigateToURL(shell(), main_url);
769 767
770 // It is safe to obtain the root frame tree node here, as it doesn't change. 768 // It is safe to obtain the root frame tree node here, as it doesn't change.
771 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 769 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
772 ->GetFrameTree()
773 ->root();
774 ASSERT_EQ(1U, root->child_count()); 770 ASSERT_EQ(1U, root->child_count());
775 771
776 FrameTreeNode* parent_iframe_node = root->child_at(0); 772 FrameTreeNode* parent_iframe_node = root->child_at(0);
777 GURL site_url(embedded_test_server()->GetURL( 773 GURL site_url(embedded_test_server()->GetURL(
778 "a.com", "/frame_tree/page_with_positioned_frame.html")); 774 "a.com", "/frame_tree/page_with_positioned_frame.html"));
779 EXPECT_EQ(site_url, parent_iframe_node->current_url()); 775 EXPECT_EQ(site_url, parent_iframe_node->current_url());
780 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), 776 EXPECT_NE(shell()->web_contents()->GetSiteInstance(),
781 parent_iframe_node->current_frame_host()->GetSiteInstance()); 777 parent_iframe_node->current_frame_host()->GetSiteInstance());
782 778
783 FrameTreeNode* nested_iframe_node = parent_iframe_node->child_at(0); 779 FrameTreeNode* nested_iframe_node = parent_iframe_node->child_at(0);
784 GURL nested_site_url( 780 GURL nested_site_url(
785 embedded_test_server()->GetURL("baz.com", "/title1.html")); 781 embedded_test_server()->GetURL("baz.com", "/title1.html"));
786 EXPECT_EQ(nested_site_url, nested_iframe_node->current_url()); 782 EXPECT_EQ(nested_site_url, nested_iframe_node->current_url());
787 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), 783 EXPECT_NE(shell()->web_contents()->GetSiteInstance(),
788 nested_iframe_node->current_frame_host()->GetSiteInstance()); 784 nested_iframe_node->current_frame_host()->GetSiteInstance());
789 EXPECT_NE(parent_iframe_node->current_frame_host()->GetSiteInstance(), 785 EXPECT_NE(parent_iframe_node->current_frame_host()->GetSiteInstance(),
790 nested_iframe_node->current_frame_host()->GetSiteInstance()); 786 nested_iframe_node->current_frame_host()->GetSiteInstance());
791 787
792 // Create listeners for mouse events. 788 // Create listeners for mouse events.
793 RenderWidgetHostMouseEventMonitor main_frame_monitor( 789 RenderWidgetHostMouseEventMonitor main_frame_monitor(
794 root->current_frame_host()->GetRenderWidgetHost()); 790 root->current_frame_host()->GetRenderWidgetHost());
795 RenderWidgetHostMouseEventMonitor nested_frame_monitor( 791 RenderWidgetHostMouseEventMonitor nested_frame_monitor(
796 nested_iframe_node->current_frame_host()->GetRenderWidgetHost()); 792 nested_iframe_node->current_frame_host()->GetRenderWidgetHost());
797 793
798 RenderWidgetHostInputEventRouter* router = 794 RenderWidgetHostInputEventRouter* router =
799 static_cast<WebContentsImpl*>(shell()->web_contents()) 795 GetWebContents()->GetInputEventRouter();
800 ->GetInputEventRouter();
801 796
802 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( 797 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>(
803 root->current_frame_host()->GetRenderWidgetHost()->GetView()); 798 root->current_frame_host()->GetRenderWidgetHost()->GetView());
804 RenderWidgetHostViewBase* rwhv_nested = 799 RenderWidgetHostViewBase* rwhv_nested =
805 static_cast<RenderWidgetHostViewBase*>( 800 static_cast<RenderWidgetHostViewBase*>(
806 nested_iframe_node->current_frame_host() 801 nested_iframe_node->current_frame_host()
807 ->GetRenderWidgetHost() 802 ->GetRenderWidgetHost()
808 ->GetView()); 803 ->GetView());
809 804
810 SurfaceHitTestReadyNotifier notifier( 805 SurfaceHitTestReadyNotifier notifier(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 #else 837 #else
843 #define MAYBE_SurfaceHitTestPointerEventsNone SurfaceHitTestPointerEventsNone 838 #define MAYBE_SurfaceHitTestPointerEventsNone SurfaceHitTestPointerEventsNone
844 #endif 839 #endif
845 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 840 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
846 MAYBE_SurfaceHitTestPointerEventsNone) { 841 MAYBE_SurfaceHitTestPointerEventsNone) {
847 GURL main_url(embedded_test_server()->GetURL( 842 GURL main_url(embedded_test_server()->GetURL(
848 "/frame_tree/page_with_positioned_frame_pointer-events_none.html")); 843 "/frame_tree/page_with_positioned_frame_pointer-events_none.html"));
849 NavigateToURL(shell(), main_url); 844 NavigateToURL(shell(), main_url);
850 845
851 // It is safe to obtain the root frame tree node here, as it doesn't change. 846 // It is safe to obtain the root frame tree node here, as it doesn't change.
852 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 847 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
853 ->GetFrameTree()
854 ->root();
855 ASSERT_EQ(1U, root->child_count()); 848 ASSERT_EQ(1U, root->child_count());
856 849
857 FrameTreeNode* child_node = root->child_at(0); 850 FrameTreeNode* child_node = root->child_at(0);
858 GURL site_url(embedded_test_server()->GetURL("baz.com", "/title1.html")); 851 GURL site_url(embedded_test_server()->GetURL("baz.com", "/title1.html"));
859 EXPECT_EQ(site_url, child_node->current_url()); 852 EXPECT_EQ(site_url, child_node->current_url());
860 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), 853 EXPECT_NE(shell()->web_contents()->GetSiteInstance(),
861 child_node->current_frame_host()->GetSiteInstance()); 854 child_node->current_frame_host()->GetSiteInstance());
862 855
863 // Create listeners for mouse events. 856 // Create listeners for mouse events.
864 RenderWidgetHostMouseEventMonitor main_frame_monitor( 857 RenderWidgetHostMouseEventMonitor main_frame_monitor(
865 root->current_frame_host()->GetRenderWidgetHost()); 858 root->current_frame_host()->GetRenderWidgetHost());
866 RenderWidgetHostMouseEventMonitor child_frame_monitor( 859 RenderWidgetHostMouseEventMonitor child_frame_monitor(
867 child_node->current_frame_host()->GetRenderWidgetHost()); 860 child_node->current_frame_host()->GetRenderWidgetHost());
868 861
869 RenderWidgetHostInputEventRouter* router = 862 RenderWidgetHostInputEventRouter* router =
870 static_cast<WebContentsImpl*>(shell()->web_contents()) 863 GetWebContents()->GetInputEventRouter();
871 ->GetInputEventRouter();
872 864
873 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( 865 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>(
874 root->current_frame_host()->GetRenderWidgetHost()->GetView()); 866 root->current_frame_host()->GetRenderWidgetHost()->GetView());
875 RenderWidgetHostViewBase* rwhv_child = static_cast<RenderWidgetHostViewBase*>( 867 RenderWidgetHostViewBase* rwhv_child = static_cast<RenderWidgetHostViewBase*>(
876 child_node->current_frame_host()->GetRenderWidgetHost()->GetView()); 868 child_node->current_frame_host()->GetRenderWidgetHost()->GetView());
877 869
878 SurfaceHitTestReadyNotifier notifier( 870 SurfaceHitTestReadyNotifier notifier(
879 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_child)); 871 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_child));
880 notifier.WaitForSurfaceReady(); 872 notifier.WaitForSurfaceReady();
881 873
(...skipping 22 matching lines...) Expand all
904 #else 896 #else
905 #define MAYBE_CompositorFrameSwapped CompositorFrameSwapped 897 #define MAYBE_CompositorFrameSwapped CompositorFrameSwapped
906 #endif 898 #endif
907 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 899 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
908 MAYBE_CompositorFrameSwapped) { 900 MAYBE_CompositorFrameSwapped) {
909 GURL main_url(embedded_test_server()->GetURL( 901 GURL main_url(embedded_test_server()->GetURL(
910 "a.com", "/cross_site_iframe_factory.html?a(baz)")); 902 "a.com", "/cross_site_iframe_factory.html?a(baz)"));
911 NavigateToURL(shell(), main_url); 903 NavigateToURL(shell(), main_url);
912 904
913 // It is safe to obtain the root frame tree node here, as it doesn't change. 905 // It is safe to obtain the root frame tree node here, as it doesn't change.
914 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 906 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
915 ->GetFrameTree()
916 ->root();
917 ASSERT_EQ(1U, root->child_count()); 907 ASSERT_EQ(1U, root->child_count());
918 908
919 FrameTreeNode* child_node = root->child_at(0); 909 FrameTreeNode* child_node = root->child_at(0);
920 GURL site_url(embedded_test_server()->GetURL( 910 GURL site_url(embedded_test_server()->GetURL(
921 "baz.com", "/cross_site_iframe_factory.html?baz()")); 911 "baz.com", "/cross_site_iframe_factory.html?baz()"));
922 EXPECT_EQ(site_url, child_node->current_url()); 912 EXPECT_EQ(site_url, child_node->current_url());
923 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), 913 EXPECT_NE(shell()->web_contents()->GetSiteInstance(),
924 child_node->current_frame_host()->GetSiteInstance()); 914 child_node->current_frame_host()->GetSiteInstance());
925 RenderWidgetHostViewBase* rwhv_base = static_cast<RenderWidgetHostViewBase*>( 915 RenderWidgetHostViewBase* rwhv_base = static_cast<RenderWidgetHostViewBase*>(
926 child_node->current_frame_host()->GetRenderWidgetHost()->GetView()); 916 child_node->current_frame_host()->GetRenderWidgetHost()->GetView());
(...skipping 10 matching lines...) Expand all
937 } 927 }
938 } 928 }
939 929
940 // Ensure that OOPIFs are deleted after navigating to a new main frame. 930 // Ensure that OOPIFs are deleted after navigating to a new main frame.
941 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CleanupCrossSiteIframe) { 931 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CleanupCrossSiteIframe) {
942 GURL main_url(embedded_test_server()->GetURL( 932 GURL main_url(embedded_test_server()->GetURL(
943 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))")); 933 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))"));
944 NavigateToURL(shell(), main_url); 934 NavigateToURL(shell(), main_url);
945 935
946 // It is safe to obtain the root frame tree node here, as it doesn't change. 936 // It is safe to obtain the root frame tree node here, as it doesn't change.
947 FrameTreeNode* root = 937 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
948 static_cast<WebContentsImpl*>(shell()->web_contents())->
949 GetFrameTree()->root();
950 938
951 TestNavigationObserver observer(shell()->web_contents()); 939 TestNavigationObserver observer(shell()->web_contents());
952 940
953 // Load a cross-site page into both iframes. 941 // Load a cross-site page into both iframes.
954 GURL foo_url = embedded_test_server()->GetURL("foo.com", "/title2.html"); 942 GURL foo_url = embedded_test_server()->GetURL("foo.com", "/title2.html");
955 NavigateFrameToURL(root->child_at(0), foo_url); 943 NavigateFrameToURL(root->child_at(0), foo_url);
956 EXPECT_TRUE(observer.last_navigation_succeeded()); 944 EXPECT_TRUE(observer.last_navigation_succeeded());
957 EXPECT_EQ(foo_url, observer.last_navigation_url()); 945 EXPECT_EQ(foo_url, observer.last_navigation_url());
958 NavigateFrameToURL(root->child_at(1), foo_url); 946 NavigateFrameToURL(root->child_at(1), foo_url);
959 EXPECT_TRUE(observer.last_navigation_succeeded()); 947 EXPECT_TRUE(observer.last_navigation_succeeded());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
996 EXPECT_FALSE(RenderViewHost::FromID(subframe_process_id, subframe_rvh_id)); 984 EXPECT_FALSE(RenderViewHost::FromID(subframe_process_id, subframe_rvh_id));
997 } 985 }
998 986
999 // Ensure that root frames cannot be detached. 987 // Ensure that root frames cannot be detached.
1000 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, RestrictFrameDetach) { 988 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, RestrictFrameDetach) {
1001 GURL main_url(embedded_test_server()->GetURL( 989 GURL main_url(embedded_test_server()->GetURL(
1002 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))")); 990 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))"));
1003 NavigateToURL(shell(), main_url); 991 NavigateToURL(shell(), main_url);
1004 992
1005 // It is safe to obtain the root frame tree node here, as it doesn't change. 993 // It is safe to obtain the root frame tree node here, as it doesn't change.
1006 FrameTreeNode* root = 994 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
1007 static_cast<WebContentsImpl*>(shell()->web_contents())->
1008 GetFrameTree()->root();
1009 995
1010 TestNavigationObserver observer(shell()->web_contents()); 996 TestNavigationObserver observer(shell()->web_contents());
1011 997
1012 // Load cross-site pages into both iframes. 998 // Load cross-site pages into both iframes.
1013 GURL foo_url = embedded_test_server()->GetURL("foo.com", "/title2.html"); 999 GURL foo_url = embedded_test_server()->GetURL("foo.com", "/title2.html");
1014 NavigateFrameToURL(root->child_at(0), foo_url); 1000 NavigateFrameToURL(root->child_at(0), foo_url);
1015 EXPECT_TRUE(observer.last_navigation_succeeded()); 1001 EXPECT_TRUE(observer.last_navigation_succeeded());
1016 EXPECT_EQ(foo_url, observer.last_navigation_url()); 1002 EXPECT_EQ(foo_url, observer.last_navigation_url());
1017 GURL bar_url = embedded_test_server()->GetURL("bar.com", "/title2.html"); 1003 GURL bar_url = embedded_test_server()->GetURL("bar.com", "/title2.html");
1018 NavigateFrameToURL(root->child_at(1), bar_url); 1004 NavigateFrameToURL(root->child_at(1), bar_url);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 " C = http://bar.com/", 1046 " C = http://bar.com/",
1061 DepictFrameTree(root)); 1047 DepictFrameTree(root));
1062 } 1048 }
1063 1049
1064 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, NavigateRemoteFrame) { 1050 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, NavigateRemoteFrame) {
1065 GURL main_url(embedded_test_server()->GetURL( 1051 GURL main_url(embedded_test_server()->GetURL(
1066 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))")); 1052 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))"));
1067 NavigateToURL(shell(), main_url); 1053 NavigateToURL(shell(), main_url);
1068 1054
1069 // It is safe to obtain the root frame tree node here, as it doesn't change. 1055 // It is safe to obtain the root frame tree node here, as it doesn't change.
1070 FrameTreeNode* root = 1056 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
1071 static_cast<WebContentsImpl*>(shell()->web_contents())->
1072 GetFrameTree()->root();
1073 1057
1074 TestNavigationObserver observer(shell()->web_contents()); 1058 TestNavigationObserver observer(shell()->web_contents());
1075 1059
1076 // Load same-site page into iframe. 1060 // Load same-site page into iframe.
1077 FrameTreeNode* child = root->child_at(0); 1061 FrameTreeNode* child = root->child_at(0);
1078 GURL http_url(embedded_test_server()->GetURL("a.com", "/title1.html")); 1062 GURL http_url(embedded_test_server()->GetURL("a.com", "/title1.html"));
1079 NavigateFrameToURL(child, http_url); 1063 NavigateFrameToURL(child, http_url);
1080 EXPECT_EQ(http_url, observer.last_navigation_url()); 1064 EXPECT_EQ(http_url, observer.last_navigation_url());
1081 EXPECT_TRUE(observer.last_navigation_succeeded()); 1065 EXPECT_TRUE(observer.last_navigation_succeeded());
1082 1066
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 child->current_frame_host()->GetSiteInstance()); 1113 child->current_frame_host()->GetSiteInstance());
1130 } 1114 }
1131 1115
1132 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 1116 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
1133 NavigateRemoteFrameToBlankAndDataURLs) { 1117 NavigateRemoteFrameToBlankAndDataURLs) {
1134 GURL main_url(embedded_test_server()->GetURL( 1118 GURL main_url(embedded_test_server()->GetURL(
1135 "a.com", "/cross_site_iframe_factory.html?a(a,a(a))")); 1119 "a.com", "/cross_site_iframe_factory.html?a(a,a(a))"));
1136 NavigateToURL(shell(), main_url); 1120 NavigateToURL(shell(), main_url);
1137 1121
1138 // It is safe to obtain the root frame tree node here, as it doesn't change. 1122 // It is safe to obtain the root frame tree node here, as it doesn't change.
1139 FrameTreeNode* root = 1123 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
1140 static_cast<WebContentsImpl*>(shell()->web_contents())->
1141 GetFrameTree()->root();
1142 1124
1143 TestNavigationObserver observer(shell()->web_contents()); 1125 TestNavigationObserver observer(shell()->web_contents());
1144 1126
1145 // Load same-site page into iframe. 1127 // Load same-site page into iframe.
1146 FrameTreeNode* child = root->child_at(0); 1128 FrameTreeNode* child = root->child_at(0);
1147 GURL http_url(embedded_test_server()->GetURL("a.com", "/title1.html")); 1129 GURL http_url(embedded_test_server()->GetURL("a.com", "/title1.html"));
1148 NavigateFrameToURL(child, http_url); 1130 NavigateFrameToURL(child, http_url);
1149 EXPECT_EQ(http_url, observer.last_navigation_url()); 1131 EXPECT_EQ(http_url, observer.last_navigation_url());
1150 EXPECT_TRUE(observer.last_navigation_succeeded()); 1132 EXPECT_TRUE(observer.last_navigation_succeeded());
1151 EXPECT_EQ( 1133 EXPECT_EQ(
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 // 1219 //
1238 // Note that due to http://crbug.com/450681, node2 cannot be re-navigated to 1220 // Note that due to http://crbug.com/450681, node2 cannot be re-navigated to
1239 // site B and stays in not rendered state. 1221 // site B and stays in not rendered state.
1240 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 1222 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
1241 NavigateRemoteFrameToKilledProcess) { 1223 NavigateRemoteFrameToKilledProcess) {
1242 GURL main_url(embedded_test_server()->GetURL( 1224 GURL main_url(embedded_test_server()->GetURL(
1243 "foo.com", "/cross_site_iframe_factory.html?foo.com(bar.com, foo.com)")); 1225 "foo.com", "/cross_site_iframe_factory.html?foo.com(bar.com, foo.com)"));
1244 NavigateToURL(shell(), main_url); 1226 NavigateToURL(shell(), main_url);
1245 1227
1246 // It is safe to obtain the root frame tree node here, as it doesn't change. 1228 // It is safe to obtain the root frame tree node here, as it doesn't change.
1247 FrameTreeNode* root = 1229 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
1248 static_cast<WebContentsImpl*>(shell()->web_contents())->
1249 GetFrameTree()->root();
1250 1230
1251 TestNavigationObserver observer(shell()->web_contents()); 1231 TestNavigationObserver observer(shell()->web_contents());
1252 ASSERT_EQ(2U, root->child_count()); 1232 ASSERT_EQ(2U, root->child_count());
1253 1233
1254 // Make sure node2 points to the correct cross-site page. 1234 // Make sure node2 points to the correct cross-site page.
1255 GURL site_b_url = embedded_test_server()->GetURL( 1235 GURL site_b_url = embedded_test_server()->GetURL(
1256 "bar.com", "/cross_site_iframe_factory.html?bar.com()"); 1236 "bar.com", "/cross_site_iframe_factory.html?bar.com()");
1257 FrameTreeNode* node2 = root->child_at(0); 1237 FrameTreeNode* node2 = root->child_at(0);
1258 EXPECT_EQ(site_b_url, node2->current_url()); 1238 EXPECT_EQ(site_b_url, node2->current_url());
1259 1239
(...skipping 28 matching lines...) Expand all
1288 // 1268 //
1289 // Note that due to http://crbug.com/450681, node2 cannot be re-navigated to 1269 // Note that due to http://crbug.com/450681, node2 cannot be re-navigated to
1290 // site B and stays in not rendered state. 1270 // site B and stays in not rendered state.
1291 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 1271 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
1292 NavigateRemoteFrameToKilledProcessWithSubtree) { 1272 NavigateRemoteFrameToKilledProcessWithSubtree) {
1293 GURL main_url(embedded_test_server()->GetURL( 1273 GURL main_url(embedded_test_server()->GetURL(
1294 "a.com", "/cross_site_iframe_factory.html?a(bar(baz), a)")); 1274 "a.com", "/cross_site_iframe_factory.html?a(bar(baz), a)"));
1295 NavigateToURL(shell(), main_url); 1275 NavigateToURL(shell(), main_url);
1296 1276
1297 // It is safe to obtain the root frame tree node here, as it doesn't change. 1277 // It is safe to obtain the root frame tree node here, as it doesn't change.
1298 FrameTreeNode* root = 1278 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
1299 static_cast<WebContentsImpl*>(shell()->web_contents())->
1300 GetFrameTree()->root();
1301 TestNavigationObserver observer(shell()->web_contents()); 1279 TestNavigationObserver observer(shell()->web_contents());
1302 1280
1303 ASSERT_EQ(2U, root->child_count()); 1281 ASSERT_EQ(2U, root->child_count());
1304 1282
1305 GURL site_b_url(embedded_test_server()->GetURL( 1283 GURL site_b_url(embedded_test_server()->GetURL(
1306 "bar.com", "/cross_site_iframe_factory.html?bar(baz())")); 1284 "bar.com", "/cross_site_iframe_factory.html?bar(baz())"));
1307 // We can't use a TestNavigationObserver to verify the URL here, 1285 // We can't use a TestNavigationObserver to verify the URL here,
1308 // since the frame has children that may have clobbered it in the observer. 1286 // since the frame has children that may have clobbered it in the observer.
1309 EXPECT_EQ(site_b_url, root->child_at(0)->current_url()); 1287 EXPECT_EQ(site_b_url, root->child_at(0)->current_url());
1310 1288
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 1353
1376 // Ensure that the renderer process doesn't crash when the main frame navigates 1354 // Ensure that the renderer process doesn't crash when the main frame navigates
1377 // a remote child to a page that results in a network error. 1355 // a remote child to a page that results in a network error.
1378 // See https://crbug.com/558016. 1356 // See https://crbug.com/558016.
1379 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, NavigateRemoteAfterError) { 1357 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, NavigateRemoteAfterError) {
1380 GURL main_url(embedded_test_server()->GetURL( 1358 GURL main_url(embedded_test_server()->GetURL(
1381 "a.com", "/cross_site_iframe_factory.html?a(a)")); 1359 "a.com", "/cross_site_iframe_factory.html?a(a)"));
1382 NavigateToURL(shell(), main_url); 1360 NavigateToURL(shell(), main_url);
1383 1361
1384 // It is safe to obtain the root frame tree node here, as it doesn't change. 1362 // It is safe to obtain the root frame tree node here, as it doesn't change.
1385 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 1363 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
1386 ->GetFrameTree()
1387 ->root();
1388 1364
1389 // Load same-site page into iframe. 1365 // Load same-site page into iframe.
1390 { 1366 {
1391 TestNavigationObserver observer(shell()->web_contents()); 1367 TestNavigationObserver observer(shell()->web_contents());
1392 FrameTreeNode* child = root->child_at(0); 1368 FrameTreeNode* child = root->child_at(0);
1393 GURL http_url(embedded_test_server()->GetURL("a.com", "/title1.html")); 1369 GURL http_url(embedded_test_server()->GetURL("a.com", "/title1.html"));
1394 NavigateFrameToURL(child, http_url); 1370 NavigateFrameToURL(child, http_url);
1395 EXPECT_EQ(http_url, observer.last_navigation_url()); 1371 EXPECT_EQ(http_url, observer.last_navigation_url());
1396 EXPECT_TRUE(observer.last_navigation_succeeded()); 1372 EXPECT_TRUE(observer.last_navigation_succeeded());
1397 observer.Wait(); 1373 observer.Wait();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1431 // successfully loads after earlier encountering a network error for it. 1407 // successfully loads after earlier encountering a network error for it.
1432 // See https://crbug.com/560511. 1408 // See https://crbug.com/560511.
1433 // TODO(creis): Make the net error page show in the correct process as well, 1409 // TODO(creis): Make the net error page show in the correct process as well,
1434 // per https://crbug.com/588314. 1410 // per https://crbug.com/588314.
1435 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ProcessTransferAfterError) { 1411 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ProcessTransferAfterError) {
1436 GURL main_url(embedded_test_server()->GetURL( 1412 GURL main_url(embedded_test_server()->GetURL(
1437 "a.com", "/cross_site_iframe_factory.html?a(a)")); 1413 "a.com", "/cross_site_iframe_factory.html?a(a)"));
1438 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 1414 EXPECT_TRUE(NavigateToURL(shell(), main_url));
1439 1415
1440 // It is safe to obtain the root frame tree node here, as it doesn't change. 1416 // It is safe to obtain the root frame tree node here, as it doesn't change.
1441 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 1417 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
1442 ->GetFrameTree()
1443 ->root();
1444 FrameTreeNode* child = root->child_at(0); 1418 FrameTreeNode* child = root->child_at(0);
1445 GURL url_a = child->current_url(); 1419 GURL url_a = child->current_url();
1446 1420
1447 // Disable host resolution in the test server and try to navigate the subframe 1421 // Disable host resolution in the test server and try to navigate the subframe
1448 // cross-site, which will lead to a committed net error (which looks like 1422 // cross-site, which will lead to a committed net error (which looks like
1449 // success to the TestNavigationObserver). 1423 // success to the TestNavigationObserver).
1450 GURL url_b = embedded_test_server()->GetURL("b.com", "/title3.html"); 1424 GURL url_b = embedded_test_server()->GetURL("b.com", "/title3.html");
1451 host_resolver()->ClearRules(); 1425 host_resolver()->ClearRules();
1452 TestNavigationObserver observer(shell()->web_contents()); 1426 TestNavigationObserver observer(shell()->web_contents());
1453 NavigateIframeToURL(shell()->web_contents(), "child-0", url_b); 1427 NavigateIframeToURL(shell()->web_contents(), "child-0", url_b);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 // verifying that a proxy for node 4 has been recreated in process B. This 1509 // verifying that a proxy for node 4 has been recreated in process B. This
1536 // verifies the fix for https://crbug.com/478892. 1510 // verifies the fix for https://crbug.com/478892.
1537 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 1511 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
1538 NavigatingToKilledProcessRestoresAllProxies) { 1512 NavigatingToKilledProcessRestoresAllProxies) {
1539 // Navigate to a page with three frames: one cross-site and two same-site. 1513 // Navigate to a page with three frames: one cross-site and two same-site.
1540 GURL main_url(embedded_test_server()->GetURL( 1514 GURL main_url(embedded_test_server()->GetURL(
1541 "a.com", "/frame_tree/page_with_three_frames.html")); 1515 "a.com", "/frame_tree/page_with_three_frames.html"));
1542 NavigateToURL(shell(), main_url); 1516 NavigateToURL(shell(), main_url);
1543 1517
1544 // It is safe to obtain the root frame tree node here, as it doesn't change. 1518 // It is safe to obtain the root frame tree node here, as it doesn't change.
1545 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 1519 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
1546 ->GetFrameTree()
1547 ->root();
1548 TestNavigationObserver observer(shell()->web_contents()); 1520 TestNavigationObserver observer(shell()->web_contents());
1549 1521
1550 EXPECT_EQ( 1522 EXPECT_EQ(
1551 " Site A ------------ proxies for B\n" 1523 " Site A ------------ proxies for B\n"
1552 " |--Site B ------- proxies for A\n" 1524 " |--Site B ------- proxies for A\n"
1553 " |--Site A ------- proxies for B\n" 1525 " |--Site A ------- proxies for B\n"
1554 " +--Site A ------- proxies for B\n" 1526 " +--Site A ------- proxies for B\n"
1555 "Where A = http://a.com/\n" 1527 "Where A = http://a.com/\n"
1556 " B = http://b.com/", 1528 " B = http://b.com/",
1557 DepictFrameTree(root)); 1529 DepictFrameTree(root));
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1604 // process A, and then checks that process B isn't resurrected to create a 1576 // process A, and then checks that process B isn't resurrected to create a
1605 // proxy for the new child frame. See https://crbug.com/476846. 1577 // proxy for the new child frame. See https://crbug.com/476846.
1606 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 1578 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
1607 CreateChildFrameAfterKillingProcess) { 1579 CreateChildFrameAfterKillingProcess) {
1608 // Navigate to a page with three frames: one cross-site and two same-site. 1580 // Navigate to a page with three frames: one cross-site and two same-site.
1609 GURL main_url(embedded_test_server()->GetURL( 1581 GURL main_url(embedded_test_server()->GetURL(
1610 "a.com", "/frame_tree/page_with_three_frames.html")); 1582 "a.com", "/frame_tree/page_with_three_frames.html"));
1611 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 1583 EXPECT_TRUE(NavigateToURL(shell(), main_url));
1612 1584
1613 // It is safe to obtain the root frame tree node here, as it doesn't change. 1585 // It is safe to obtain the root frame tree node here, as it doesn't change.
1614 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 1586 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
1615 ->GetFrameTree()
1616 ->root();
1617 1587
1618 EXPECT_EQ( 1588 EXPECT_EQ(
1619 " Site A ------------ proxies for B\n" 1589 " Site A ------------ proxies for B\n"
1620 " |--Site B ------- proxies for A\n" 1590 " |--Site B ------- proxies for A\n"
1621 " |--Site A ------- proxies for B\n" 1591 " |--Site A ------- proxies for B\n"
1622 " +--Site A ------- proxies for B\n" 1592 " +--Site A ------- proxies for B\n"
1623 "Where A = http://a.com/\n" 1593 "Where A = http://a.com/\n"
1624 " B = http://b.com/", 1594 " B = http://b.com/",
1625 DepictFrameTree(root)); 1595 DepictFrameTree(root));
1626 SiteInstance* b_site_instance = 1596 SiteInstance* b_site_instance =
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 // for which its parent has proxies. This includes A. However, even though 1651 // for which its parent has proxies. This includes A. However, even though
1682 // process A is live (step 4), the parent proxy in A is not live (which was 1652 // process A is live (step 4), the parent proxy in A is not live (which was
1683 // incorrectly assumed previously). This is because step 4 does not resurrect 1653 // incorrectly assumed previously). This is because step 4 does not resurrect
1684 // proxies for popups opened before the crash. 1654 // proxies for popups opened before the crash.
1685 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 1655 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
1686 CreateChildFrameAfterKillingOpener) { 1656 CreateChildFrameAfterKillingOpener) {
1687 GURL main_url(embedded_test_server()->GetURL("a.com", "/title1.html")); 1657 GURL main_url(embedded_test_server()->GetURL("a.com", "/title1.html"));
1688 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 1658 EXPECT_TRUE(NavigateToURL(shell(), main_url));
1689 1659
1690 // It is safe to obtain the root frame tree node here, as it doesn't change. 1660 // It is safe to obtain the root frame tree node here, as it doesn't change.
1691 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 1661 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
1692 ->GetFrameTree()
1693 ->root();
1694 SiteInstance* site_instance_a = root->current_frame_host()->GetSiteInstance(); 1662 SiteInstance* site_instance_a = root->current_frame_host()->GetSiteInstance();
1695 1663
1696 // Open a popup and navigate it cross-process to b.com. 1664 // Open a popup and navigate it cross-process to b.com.
1697 ShellAddedObserver new_shell_observer; 1665 ShellAddedObserver new_shell_observer;
1698 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), 1666 EXPECT_TRUE(ExecuteScript(root->current_frame_host(),
1699 "popup = window.open('about:blank');")); 1667 "popup = window.open('about:blank');"));
1700 Shell* popup = new_shell_observer.GetShell(); 1668 Shell* popup = new_shell_observer.GetShell();
1701 GURL popup_url(embedded_test_server()->GetURL("b.com", "/title2.html")); 1669 GURL popup_url(embedded_test_server()->GetURL("b.com", "/title2.html"));
1702 EXPECT_TRUE(NavigateToURL(popup, popup_url)); 1670 EXPECT_TRUE(NavigateToURL(popup, popup_url));
1703 1671
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1769 // node1 is the root. 1737 // node1 is the root.
1770 // Initially, both node1.proxy_hosts_ and node3.proxy_hosts_ contain C. 1738 // Initially, both node1.proxy_hosts_ and node3.proxy_hosts_ contain C.
1771 // After we kill B, make sure proxies for C are cleared. 1739 // After we kill B, make sure proxies for C are cleared.
1772 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 1740 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
1773 KillingRendererClearsDescendantProxies) { 1741 KillingRendererClearsDescendantProxies) {
1774 GURL main_url(embedded_test_server()->GetURL( 1742 GURL main_url(embedded_test_server()->GetURL(
1775 "a.com", "/frame_tree/page_with_two_frames_nested.html")); 1743 "a.com", "/frame_tree/page_with_two_frames_nested.html"));
1776 NavigateToURL(shell(), main_url); 1744 NavigateToURL(shell(), main_url);
1777 1745
1778 // It is safe to obtain the root frame tree node here, as it doesn't change. 1746 // It is safe to obtain the root frame tree node here, as it doesn't change.
1779 FrameTreeNode* root = 1747 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
1780 static_cast<WebContentsImpl*>(shell()->web_contents())->
1781 GetFrameTree()->root();
1782 ASSERT_EQ(2U, root->child_count()); 1748 ASSERT_EQ(2U, root->child_count());
1783 1749
1784 GURL site_b_url( 1750 GURL site_b_url(
1785 embedded_test_server()->GetURL( 1751 embedded_test_server()->GetURL(
1786 "bar.com", "/frame_tree/page_with_one_frame.html")); 1752 "bar.com", "/frame_tree/page_with_one_frame.html"));
1787 // We can't use a TestNavigationObserver to verify the URL here, 1753 // We can't use a TestNavigationObserver to verify the URL here,
1788 // since the frame has children that may have clobbered it in the observer. 1754 // since the frame has children that may have clobbered it in the observer.
1789 EXPECT_EQ(site_b_url, root->child_at(0)->current_url()); 1755 EXPECT_EQ(site_b_url, root->child_at(0)->current_url());
1790 1756
1791 // Ensure that a new process is created for node2. 1757 // Ensure that a new process is created for node2.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1843 } 1809 }
1844 1810
1845 // Crash a subframe and ensures its children are cleared from the FrameTree. 1811 // Crash a subframe and ensures its children are cleared from the FrameTree.
1846 // See http://crbug.com/338508. 1812 // See http://crbug.com/338508.
1847 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrashSubframe) { 1813 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrashSubframe) {
1848 GURL main_url(embedded_test_server()->GetURL( 1814 GURL main_url(embedded_test_server()->GetURL(
1849 "a.com", "/cross_site_iframe_factory.html?a(b)")); 1815 "a.com", "/cross_site_iframe_factory.html?a(b)"));
1850 NavigateToURL(shell(), main_url); 1816 NavigateToURL(shell(), main_url);
1851 1817
1852 // Check the subframe process. 1818 // Check the subframe process.
1853 FrameTreeNode* root = 1819 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
1854 static_cast<WebContentsImpl*>(shell()->web_contents())->
1855 GetFrameTree()->root();
1856 EXPECT_EQ( 1820 EXPECT_EQ(
1857 " Site A ------------ proxies for B\n" 1821 " Site A ------------ proxies for B\n"
1858 " +--Site B ------- proxies for A\n" 1822 " +--Site B ------- proxies for A\n"
1859 "Where A = http://a.com/\n" 1823 "Where A = http://a.com/\n"
1860 " B = http://b.com/", 1824 " B = http://b.com/",
1861 DepictFrameTree(root)); 1825 DepictFrameTree(root));
1862 FrameTreeNode* child = root->child_at(0); 1826 FrameTreeNode* child = root->child_at(0);
1863 EXPECT_TRUE( 1827 EXPECT_TRUE(
1864 child->current_frame_host()->render_view_host()->IsRenderViewLive()); 1828 child->current_frame_host()->render_view_host()->IsRenderViewLive());
1865 EXPECT_TRUE(child->current_frame_host()->IsRenderFrameLive()); 1829 EXPECT_TRUE(child->current_frame_host()->IsRenderFrameLive());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1906 // When a new subframe is added, related SiteInstances that can reach the 1870 // When a new subframe is added, related SiteInstances that can reach the
1907 // subframe should create proxies for it (https://crbug.com/423587). This test 1871 // subframe should create proxies for it (https://crbug.com/423587). This test
1908 // checks that if A embeds B and later adds a new subframe A2, A2 gets a proxy 1872 // checks that if A embeds B and later adds a new subframe A2, A2 gets a proxy
1909 // in B's process. 1873 // in B's process.
1910 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CreateProxiesForNewFrames) { 1874 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CreateProxiesForNewFrames) {
1911 GURL main_url(embedded_test_server()->GetURL( 1875 GURL main_url(embedded_test_server()->GetURL(
1912 "b.com", "/frame_tree/page_with_one_frame.html")); 1876 "b.com", "/frame_tree/page_with_one_frame.html"));
1913 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 1877 EXPECT_TRUE(NavigateToURL(shell(), main_url));
1914 1878
1915 // It is safe to obtain the root frame tree node here, as it doesn't change. 1879 // It is safe to obtain the root frame tree node here, as it doesn't change.
1916 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 1880 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
1917 ->GetFrameTree()
1918 ->root();
1919 ASSERT_EQ(1U, root->child_count()); 1881 ASSERT_EQ(1U, root->child_count());
1920 1882
1921 // Make sure the frame starts out at the correct cross-site URL. 1883 // Make sure the frame starts out at the correct cross-site URL.
1922 EXPECT_EQ(embedded_test_server()->GetURL("baz.com", "/title1.html"), 1884 EXPECT_EQ(embedded_test_server()->GetURL("baz.com", "/title1.html"),
1923 root->child_at(0)->current_url()); 1885 root->child_at(0)->current_url());
1924 1886
1925 EXPECT_EQ( 1887 EXPECT_EQ(
1926 " Site A ------------ proxies for B\n" 1888 " Site A ------------ proxies for B\n"
1927 " +--Site B ------- proxies for A\n" 1889 " +--Site B ------- proxies for A\n"
1928 "Where A = http://b.com/\n" 1890 "Where A = http://b.com/\n"
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
2151 2113
2152 // Ensure that when navigating a frame cross-process RenderFrameProxyHosts are 2114 // Ensure that when navigating a frame cross-process RenderFrameProxyHosts are
2153 // created in the FrameTree skipping the subtree of the navigating frame. 2115 // created in the FrameTree skipping the subtree of the navigating frame.
2154 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 2116 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
2155 ProxyCreationSkipsSubtree) { 2117 ProxyCreationSkipsSubtree) {
2156 GURL main_url(embedded_test_server()->GetURL( 2118 GURL main_url(embedded_test_server()->GetURL(
2157 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))")); 2119 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))"));
2158 NavigateToURL(shell(), main_url); 2120 NavigateToURL(shell(), main_url);
2159 2121
2160 // It is safe to obtain the root frame tree node here, as it doesn't change. 2122 // It is safe to obtain the root frame tree node here, as it doesn't change.
2161 FrameTreeNode* root = 2123 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
2162 static_cast<WebContentsImpl*>(shell()->web_contents())->
2163 GetFrameTree()->root();
2164 2124
2165 EXPECT_TRUE(root->child_at(1) != NULL); 2125 EXPECT_TRUE(root->child_at(1) != NULL);
2166 EXPECT_EQ(2U, root->child_at(1)->child_count()); 2126 EXPECT_EQ(2U, root->child_at(1)->child_count());
2167 2127
2168 { 2128 {
2169 // Load same-site page into iframe. 2129 // Load same-site page into iframe.
2170 TestNavigationObserver observer(shell()->web_contents()); 2130 TestNavigationObserver observer(shell()->web_contents());
2171 GURL http_url(embedded_test_server()->GetURL("a.com", "/title1.html")); 2131 GURL http_url(embedded_test_server()->GetURL("a.com", "/title1.html"));
2172 NavigateFrameToURL(root->child_at(0), http_url); 2132 NavigateFrameToURL(root->child_at(0), http_url);
2173 EXPECT_EQ(http_url, observer.last_navigation_url()); 2133 EXPECT_EQ(http_url, observer.last_navigation_url());
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
2299 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 2259 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
2300 MAYBE_FrameOwnerPropertiesPropagationScrolling) { 2260 MAYBE_FrameOwnerPropertiesPropagationScrolling) {
2301 #if defined(OS_MACOSX) 2261 #if defined(OS_MACOSX)
2302 ui::test::ScopedPreferredScrollerStyle scroller_style_override(false); 2262 ui::test::ScopedPreferredScrollerStyle scroller_style_override(false);
2303 #endif 2263 #endif
2304 GURL main_url(embedded_test_server()->GetURL( 2264 GURL main_url(embedded_test_server()->GetURL(
2305 "a.com", "/frame_owner_properties_scrolling.html")); 2265 "a.com", "/frame_owner_properties_scrolling.html"));
2306 NavigateToURL(shell(), main_url); 2266 NavigateToURL(shell(), main_url);
2307 2267
2308 // It is safe to obtain the root frame tree node here, as it doesn't change. 2268 // It is safe to obtain the root frame tree node here, as it doesn't change.
2309 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 2269 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
2310 ->GetFrameTree()
2311 ->root();
2312 ASSERT_EQ(1u, root->child_count()); 2270 ASSERT_EQ(1u, root->child_count());
2313 2271
2314 EXPECT_EQ( 2272 EXPECT_EQ(
2315 " Site A ------------ proxies for B\n" 2273 " Site A ------------ proxies for B\n"
2316 " +--Site B ------- proxies for A\n" 2274 " +--Site B ------- proxies for A\n"
2317 "Where A = http://a.com/\n" 2275 "Where A = http://a.com/\n"
2318 " B = http://b.com/", 2276 " B = http://b.com/",
2319 DepictFrameTree(root)); 2277 DepictFrameTree(root));
2320 2278
2321 FrameTreeNode* child = root->child_at(0); 2279 FrameTreeNode* child = root->child_at(0);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2372 2330
2373 // Verify that "marginwidth" and "marginheight" properties on frame elements 2331 // Verify that "marginwidth" and "marginheight" properties on frame elements
2374 // propagate to child frames correctly. 2332 // propagate to child frames correctly.
2375 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 2333 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
2376 FrameOwnerPropertiesPropagationMargin) { 2334 FrameOwnerPropertiesPropagationMargin) {
2377 GURL main_url(embedded_test_server()->GetURL( 2335 GURL main_url(embedded_test_server()->GetURL(
2378 "a.com", "/frame_owner_properties_margin.html")); 2336 "a.com", "/frame_owner_properties_margin.html"));
2379 NavigateToURL(shell(), main_url); 2337 NavigateToURL(shell(), main_url);
2380 2338
2381 // It is safe to obtain the root frame tree node here, as it doesn't change. 2339 // It is safe to obtain the root frame tree node here, as it doesn't change.
2382 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 2340 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
2383 ->GetFrameTree()
2384 ->root();
2385 ASSERT_EQ(1u, root->child_count()); 2341 ASSERT_EQ(1u, root->child_count());
2386 2342
2387 EXPECT_EQ( 2343 EXPECT_EQ(
2388 " Site A ------------ proxies for B\n" 2344 " Site A ------------ proxies for B\n"
2389 " +--Site B ------- proxies for A\n" 2345 " +--Site B ------- proxies for A\n"
2390 "Where A = http://a.com/\n" 2346 "Where A = http://a.com/\n"
2391 " B = http://b.com/", 2347 " B = http://b.com/",
2392 DepictFrameTree(root)); 2348 DepictFrameTree(root));
2393 2349
2394 FrameTreeNode* child = root->child_at(0); 2350 FrameTreeNode* child = root->child_at(0);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
2464 } 2420 }
2465 } 2421 }
2466 2422
2467 // Verify origin replication with an A-embed-B-embed-C-embed-A hierarchy. 2423 // Verify origin replication with an A-embed-B-embed-C-embed-A hierarchy.
2468 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OriginReplication) { 2424 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OriginReplication) {
2469 GURL main_url(embedded_test_server()->GetURL( 2425 GURL main_url(embedded_test_server()->GetURL(
2470 "a.com", "/cross_site_iframe_factory.html?a(b(c(a),b), a)")); 2426 "a.com", "/cross_site_iframe_factory.html?a(b(c(a),b), a)"));
2471 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 2427 EXPECT_TRUE(NavigateToURL(shell(), main_url));
2472 2428
2473 // It is safe to obtain the root frame tree node here, as it doesn't change. 2429 // It is safe to obtain the root frame tree node here, as it doesn't change.
2474 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 2430 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
2475 ->GetFrameTree()
2476 ->root();
2477 2431
2478 EXPECT_EQ( 2432 EXPECT_EQ(
2479 " Site A ------------ proxies for B C\n" 2433 " Site A ------------ proxies for B C\n"
2480 " |--Site B ------- proxies for A C\n" // tiptop_child 2434 " |--Site B ------- proxies for A C\n" // tiptop_child
2481 " | |--Site C -- proxies for A B\n" // middle_child 2435 " | |--Site C -- proxies for A B\n" // middle_child
2482 " | | +--Site A -- proxies for B C\n" // lowest_child 2436 " | | +--Site A -- proxies for B C\n" // lowest_child
2483 " | +--Site B -- proxies for A C\n" 2437 " | +--Site B -- proxies for A C\n"
2484 " +--Site A ------- proxies for B C\n" 2438 " +--Site A ------- proxies for B C\n"
2485 "Where A = http://a.com/\n" 2439 "Where A = http://a.com/\n"
2486 " B = http://b.com/\n" 2440 " B = http://b.com/\n"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
2555 &result)); 2509 &result));
2556 EXPECT_EQ(a_origin, result + "/"); 2510 EXPECT_EQ(a_origin, result + "/");
2557 } 2511 }
2558 2512
2559 // Check that iframe sandbox flags are replicated correctly. 2513 // Check that iframe sandbox flags are replicated correctly.
2560 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, SandboxFlagsReplication) { 2514 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, SandboxFlagsReplication) {
2561 GURL main_url(embedded_test_server()->GetURL("/sandboxed_frames.html")); 2515 GURL main_url(embedded_test_server()->GetURL("/sandboxed_frames.html"));
2562 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 2516 EXPECT_TRUE(NavigateToURL(shell(), main_url));
2563 2517
2564 // It is safe to obtain the root frame tree node here, as it doesn't change. 2518 // It is safe to obtain the root frame tree node here, as it doesn't change.
2565 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 2519 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
2566 ->GetFrameTree()
2567 ->root();
2568 2520
2569 TestNavigationObserver observer(shell()->web_contents()); 2521 TestNavigationObserver observer(shell()->web_contents());
2570 2522
2571 // Navigate the second (sandboxed) subframe to a cross-site page with a 2523 // Navigate the second (sandboxed) subframe to a cross-site page with a
2572 // subframe. 2524 // subframe.
2573 GURL foo_url( 2525 GURL foo_url(
2574 embedded_test_server()->GetURL("foo.com", "/frame_tree/1-1.html")); 2526 embedded_test_server()->GetURL("foo.com", "/frame_tree/1-1.html"));
2575 NavigateFrameToURL(root->child_at(1), foo_url); 2527 NavigateFrameToURL(root->child_at(1), foo_url);
2576 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); 2528 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
2577 2529
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
2655 EXPECT_EQ(main_url.GetOrigin().spec(), result + "/"); 2607 EXPECT_EQ(main_url.GetOrigin().spec(), result + "/");
2656 } 2608 }
2657 2609
2658 // Check that dynamic updates to iframe sandbox flags are propagated correctly. 2610 // Check that dynamic updates to iframe sandbox flags are propagated correctly.
2659 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DynamicSandboxFlags) { 2611 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DynamicSandboxFlags) {
2660 GURL main_url( 2612 GURL main_url(
2661 embedded_test_server()->GetURL("/frame_tree/page_with_two_frames.html")); 2613 embedded_test_server()->GetURL("/frame_tree/page_with_two_frames.html"));
2662 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 2614 EXPECT_TRUE(NavigateToURL(shell(), main_url));
2663 2615
2664 // It is safe to obtain the root frame tree node here, as it doesn't change. 2616 // It is safe to obtain the root frame tree node here, as it doesn't change.
2665 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 2617 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
2666 ->GetFrameTree()
2667 ->root();
2668 2618
2669 TestNavigationObserver observer(shell()->web_contents()); 2619 TestNavigationObserver observer(shell()->web_contents());
2670 ASSERT_EQ(2U, root->child_count()); 2620 ASSERT_EQ(2U, root->child_count());
2671 2621
2672 // Make sure first frame starts out at the correct cross-site page. 2622 // Make sure first frame starts out at the correct cross-site page.
2673 EXPECT_EQ(embedded_test_server()->GetURL("bar.com", "/title1.html"), 2623 EXPECT_EQ(embedded_test_server()->GetURL("bar.com", "/title1.html"),
2674 root->child_at(0)->current_url()); 2624 root->child_at(0)->current_url());
2675 2625
2676 // Navigate second frame to another cross-site page. 2626 // Navigate second frame to another cross-site page.
2677 GURL baz_url(embedded_test_server()->GetURL("baz.com", "/title1.html")); 2627 GURL baz_url(embedded_test_server()->GetURL("baz.com", "/title1.html"));
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
2779 } 2729 }
2780 2730
2781 // Check that dynamic updates to iframe sandbox flags are propagated correctly. 2731 // Check that dynamic updates to iframe sandbox flags are propagated correctly.
2782 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 2732 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
2783 DynamicSandboxFlagsRemoteToLocal) { 2733 DynamicSandboxFlagsRemoteToLocal) {
2784 GURL main_url( 2734 GURL main_url(
2785 embedded_test_server()->GetURL("/frame_tree/page_with_two_frames.html")); 2735 embedded_test_server()->GetURL("/frame_tree/page_with_two_frames.html"));
2786 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 2736 EXPECT_TRUE(NavigateToURL(shell(), main_url));
2787 2737
2788 // It is safe to obtain the root frame tree node here, as it doesn't change. 2738 // It is safe to obtain the root frame tree node here, as it doesn't change.
2789 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 2739 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
2790 ->GetFrameTree()
2791 ->root();
2792 2740
2793 TestNavigationObserver observer(shell()->web_contents()); 2741 TestNavigationObserver observer(shell()->web_contents());
2794 ASSERT_EQ(2U, root->child_count()); 2742 ASSERT_EQ(2U, root->child_count());
2795 2743
2796 // Make sure the two frames starts out at correct URLs. 2744 // Make sure the two frames starts out at correct URLs.
2797 EXPECT_EQ(embedded_test_server()->GetURL("bar.com", "/title1.html"), 2745 EXPECT_EQ(embedded_test_server()->GetURL("bar.com", "/title1.html"),
2798 root->child_at(0)->current_url()); 2746 root->child_at(0)->current_url());
2799 EXPECT_EQ(embedded_test_server()->GetURL("/title1.html"), 2747 EXPECT_EQ(embedded_test_server()->GetURL("/title1.html"),
2800 root->child_at(1)->current_url()); 2748 root->child_at(1)->current_url());
2801 2749
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
2853 } 2801 }
2854 2802
2855 // Check that dynamic updates to iframe sandbox flags are propagated correctly. 2803 // Check that dynamic updates to iframe sandbox flags are propagated correctly.
2856 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 2804 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
2857 DynamicSandboxFlagsRendererInitiatedNavigation) { 2805 DynamicSandboxFlagsRendererInitiatedNavigation) {
2858 GURL main_url( 2806 GURL main_url(
2859 embedded_test_server()->GetURL("/frame_tree/page_with_one_frame.html")); 2807 embedded_test_server()->GetURL("/frame_tree/page_with_one_frame.html"));
2860 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 2808 EXPECT_TRUE(NavigateToURL(shell(), main_url));
2861 2809
2862 // It is safe to obtain the root frame tree node here, as it doesn't change. 2810 // It is safe to obtain the root frame tree node here, as it doesn't change.
2863 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 2811 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
2864 ->GetFrameTree()
2865 ->root();
2866 2812
2867 TestNavigationObserver observer(shell()->web_contents()); 2813 TestNavigationObserver observer(shell()->web_contents());
2868 ASSERT_EQ(1U, root->child_count()); 2814 ASSERT_EQ(1U, root->child_count());
2869 2815
2870 // Make sure the frame starts out at the correct cross-site page. 2816 // Make sure the frame starts out at the correct cross-site page.
2871 EXPECT_EQ(embedded_test_server()->GetURL("baz.com", "/title1.html"), 2817 EXPECT_EQ(embedded_test_server()->GetURL("baz.com", "/title1.html"),
2872 root->child_at(0)->current_url()); 2818 root->child_at(0)->current_url());
2873 2819
2874 // The frame should not be sandboxed to start with. 2820 // The frame should not be sandboxed to start with.
2875 EXPECT_EQ(blink::WebSandboxFlags::None, 2821 EXPECT_EQ(blink::WebSandboxFlags::None,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
2934 // checking whether the grandchild frame added in step 3 sees proper sandbox 2880 // checking whether the grandchild frame added in step 3 sees proper sandbox
2935 // flags and origin for its (remote) parent. This wasn't addressed when 2881 // flags and origin for its (remote) parent. This wasn't addressed when
2936 // https://crbug.com/423587 was fixed. 2882 // https://crbug.com/423587 was fixed.
2937 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 2883 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
2938 ProxiesForNewChildFramesHaveCorrectReplicationState) { 2884 ProxiesForNewChildFramesHaveCorrectReplicationState) {
2939 GURL main_url( 2885 GURL main_url(
2940 embedded_test_server()->GetURL("/frame_tree/page_with_one_frame.html")); 2886 embedded_test_server()->GetURL("/frame_tree/page_with_one_frame.html"));
2941 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 2887 EXPECT_TRUE(NavigateToURL(shell(), main_url));
2942 2888
2943 // It is safe to obtain the root frame tree node here, as it doesn't change. 2889 // It is safe to obtain the root frame tree node here, as it doesn't change.
2944 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 2890 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
2945 ->GetFrameTree()
2946 ->root();
2947 TestNavigationObserver observer(shell()->web_contents()); 2891 TestNavigationObserver observer(shell()->web_contents());
2948 2892
2949 EXPECT_EQ( 2893 EXPECT_EQ(
2950 " Site A ------------ proxies for B\n" 2894 " Site A ------------ proxies for B\n"
2951 " +--Site B ------- proxies for A\n" 2895 " +--Site B ------- proxies for A\n"
2952 "Where A = http://127.0.0.1/\n" 2896 "Where A = http://127.0.0.1/\n"
2953 " B = http://baz.com/", 2897 " B = http://baz.com/",
2954 DepictFrameTree(root)); 2898 DepictFrameTree(root));
2955 2899
2956 // In the root frame, add a new sandboxed local frame, which itself has a 2900 // In the root frame, add a new sandboxed local frame, which itself has a
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
3015 EXPECT_TRUE(success); 2959 EXPECT_TRUE(success);
3016 EXPECT_EQ(1u, Shell::windows().size()); 2960 EXPECT_EQ(1u, Shell::windows().size());
3017 } 2961 }
3018 2962
3019 // Verify that a child frame can retrieve the name property set by its parent. 2963 // Verify that a child frame can retrieve the name property set by its parent.
3020 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, WindowNameReplication) { 2964 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, WindowNameReplication) {
3021 GURL main_url(embedded_test_server()->GetURL("/frame_tree/2-4.html")); 2965 GURL main_url(embedded_test_server()->GetURL("/frame_tree/2-4.html"));
3022 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 2966 EXPECT_TRUE(NavigateToURL(shell(), main_url));
3023 2967
3024 // It is safe to obtain the root frame tree node here, as it doesn't change. 2968 // It is safe to obtain the root frame tree node here, as it doesn't change.
3025 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 2969 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
3026 ->GetFrameTree()
3027 ->root();
3028 2970
3029 TestNavigationObserver observer(shell()->web_contents()); 2971 TestNavigationObserver observer(shell()->web_contents());
3030 2972
3031 // Load cross-site page into iframe. 2973 // Load cross-site page into iframe.
3032 GURL frame_url = 2974 GURL frame_url =
3033 embedded_test_server()->GetURL("foo.com", "/frame_tree/3-1.html"); 2975 embedded_test_server()->GetURL("foo.com", "/frame_tree/3-1.html");
3034 NavigateFrameToURL(root->child_at(0), frame_url); 2976 NavigateFrameToURL(root->child_at(0), frame_url);
3035 EXPECT_TRUE(observer.last_navigation_succeeded()); 2977 EXPECT_TRUE(observer.last_navigation_succeeded());
3036 EXPECT_EQ(frame_url, observer.last_navigation_url()); 2978 EXPECT_EQ(frame_url, observer.last_navigation_url());
3037 2979
(...skipping 10 matching lines...) Expand all
3048 EXPECT_EQ("3-1-name", result); 2990 EXPECT_EQ("3-1-name", result);
3049 } 2991 }
3050 2992
3051 // Verify that dynamic updates to a frame's window.name propagate to the 2993 // Verify that dynamic updates to a frame's window.name propagate to the
3052 // frame's proxies, so that the latest frame names can be used in navigations. 2994 // frame's proxies, so that the latest frame names can be used in navigations.
3053 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DynamicWindowName) { 2995 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DynamicWindowName) {
3054 GURL main_url(embedded_test_server()->GetURL("/frame_tree/2-4.html")); 2996 GURL main_url(embedded_test_server()->GetURL("/frame_tree/2-4.html"));
3055 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 2997 EXPECT_TRUE(NavigateToURL(shell(), main_url));
3056 2998
3057 // It is safe to obtain the root frame tree node here, as it doesn't change. 2999 // It is safe to obtain the root frame tree node here, as it doesn't change.
3058 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 3000 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
3059 ->GetFrameTree()
3060 ->root();
3061 TestNavigationObserver observer(shell()->web_contents()); 3001 TestNavigationObserver observer(shell()->web_contents());
3062 3002
3063 // Load cross-site page into iframe. 3003 // Load cross-site page into iframe.
3064 GURL frame_url = 3004 GURL frame_url =
3065 embedded_test_server()->GetURL("foo.com", "/frame_tree/3-1.html"); 3005 embedded_test_server()->GetURL("foo.com", "/frame_tree/3-1.html");
3066 NavigateFrameToURL(root->child_at(0), frame_url); 3006 NavigateFrameToURL(root->child_at(0), frame_url);
3067 EXPECT_TRUE(observer.last_navigation_succeeded()); 3007 EXPECT_TRUE(observer.last_navigation_succeeded());
3068 EXPECT_EQ(frame_url, observer.last_navigation_url()); 3008 EXPECT_EQ(frame_url, observer.last_navigation_url());
3069 3009
3070 // Browser process should know the child frame's original window.name 3010 // Browser process should know the child frame's original window.name
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3107 } 3047 }
3108 3048
3109 // Verify that when a frame is navigated to a new origin, the origin update 3049 // Verify that when a frame is navigated to a new origin, the origin update
3110 // propagates to the frame's proxies. 3050 // propagates to the frame's proxies.
3111 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OriginUpdatesReachProxies) { 3051 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OriginUpdatesReachProxies) {
3112 GURL main_url( 3052 GURL main_url(
3113 embedded_test_server()->GetURL("/frame_tree/page_with_two_frames.html")); 3053 embedded_test_server()->GetURL("/frame_tree/page_with_two_frames.html"));
3114 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 3054 EXPECT_TRUE(NavigateToURL(shell(), main_url));
3115 3055
3116 // It is safe to obtain the root frame tree node here, as it doesn't change. 3056 // It is safe to obtain the root frame tree node here, as it doesn't change.
3117 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 3057 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
3118 ->GetFrameTree()
3119 ->root();
3120 TestNavigationObserver observer(shell()->web_contents()); 3058 TestNavigationObserver observer(shell()->web_contents());
3121 3059
3122 EXPECT_EQ( 3060 EXPECT_EQ(
3123 " Site A ------------ proxies for B\n" 3061 " Site A ------------ proxies for B\n"
3124 " |--Site B ------- proxies for A\n" 3062 " |--Site B ------- proxies for A\n"
3125 " +--Site A ------- proxies for B\n" 3063 " +--Site A ------- proxies for B\n"
3126 "Where A = http://127.0.0.1/\n" 3064 "Where A = http://127.0.0.1/\n"
3127 " B = http://bar.com/", 3065 " B = http://bar.com/",
3128 DepictFrameTree(root)); 3066 DepictFrameTree(root));
3129 3067
(...skipping 30 matching lines...) Expand all
3160 << frame_origin << ")"; 3098 << frame_origin << ")";
3161 } 3099 }
3162 3100
3163 // Ensure that navigating subframes in --site-per-process mode properly fires 3101 // Ensure that navigating subframes in --site-per-process mode properly fires
3164 // the DidStopLoading event on WebContentsObserver. 3102 // the DidStopLoading event on WebContentsObserver.
3165 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteDidStopLoading) { 3103 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteDidStopLoading) {
3166 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); 3104 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html"));
3167 NavigateToURL(shell(), main_url); 3105 NavigateToURL(shell(), main_url);
3168 3106
3169 // It is safe to obtain the root frame tree node here, as it doesn't change. 3107 // It is safe to obtain the root frame tree node here, as it doesn't change.
3170 FrameTreeNode* root = 3108 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
3171 static_cast<WebContentsImpl*>(shell()->web_contents())->
3172 GetFrameTree()->root();
3173 3109
3174 TestNavigationObserver observer(shell()->web_contents()); 3110 TestNavigationObserver observer(shell()->web_contents());
3175 3111
3176 // Load same-site page into iframe. 3112 // Load same-site page into iframe.
3177 FrameTreeNode* child = root->child_at(0); 3113 FrameTreeNode* child = root->child_at(0);
3178 GURL http_url(embedded_test_server()->GetURL("/title1.html")); 3114 GURL http_url(embedded_test_server()->GetURL("/title1.html"));
3179 NavigateFrameToURL(child, http_url); 3115 NavigateFrameToURL(child, http_url);
3180 EXPECT_EQ(http_url, observer.last_navigation_url()); 3116 EXPECT_EQ(http_url, observer.last_navigation_url());
3181 EXPECT_TRUE(observer.last_navigation_succeeded()); 3117 EXPECT_TRUE(observer.last_navigation_succeeded());
3182 3118
(...skipping 13 matching lines...) Expand all
3196 3132
3197 // Ensure that the renderer does not crash when navigating a frame that has a 3133 // Ensure that the renderer does not crash when navigating a frame that has a
3198 // sibling RemoteFrame. See https://crbug.com/426953. 3134 // sibling RemoteFrame. See https://crbug.com/426953.
3199 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 3135 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
3200 NavigateWithSiblingRemoteFrame) { 3136 NavigateWithSiblingRemoteFrame) {
3201 GURL main_url( 3137 GURL main_url(
3202 embedded_test_server()->GetURL("/frame_tree/page_with_two_frames.html")); 3138 embedded_test_server()->GetURL("/frame_tree/page_with_two_frames.html"));
3203 NavigateToURL(shell(), main_url); 3139 NavigateToURL(shell(), main_url);
3204 3140
3205 // It is safe to obtain the root frame tree node here, as it doesn't change. 3141 // It is safe to obtain the root frame tree node here, as it doesn't change.
3206 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 3142 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
3207 ->GetFrameTree()
3208 ->root();
3209 TestNavigationObserver observer(shell()->web_contents()); 3143 TestNavigationObserver observer(shell()->web_contents());
3210 3144
3211 // Make sure the first frame is out of process. 3145 // Make sure the first frame is out of process.
3212 ASSERT_EQ(2U, root->child_count()); 3146 ASSERT_EQ(2U, root->child_count());
3213 FrameTreeNode* node2 = root->child_at(0); 3147 FrameTreeNode* node2 = root->child_at(0);
3214 EXPECT_NE(root->current_frame_host()->GetSiteInstance(), 3148 EXPECT_NE(root->current_frame_host()->GetSiteInstance(),
3215 node2->current_frame_host()->GetSiteInstance()); 3149 node2->current_frame_host()->GetSiteInstance());
3216 3150
3217 // Make sure the second frame is in the parent's process. 3151 // Make sure the second frame is in the parent's process.
3218 FrameTreeNode* node3 = root->child_at(1); 3152 FrameTreeNode* node3 = root->child_at(1);
(...skipping 13 matching lines...) Expand all
3232 // Ensure that the renderer does not crash when a local frame with a remote 3166 // Ensure that the renderer does not crash when a local frame with a remote
3233 // parent frame is swapped from local to remote, then back to local again. 3167 // parent frame is swapped from local to remote, then back to local again.
3234 // See https://crbug.com/585654. 3168 // See https://crbug.com/585654.
3235 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 3169 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
3236 NavigateSiblingsToSameProcess) { 3170 NavigateSiblingsToSameProcess) {
3237 GURL main_url( 3171 GURL main_url(
3238 embedded_test_server()->GetURL("/frame_tree/page_with_two_frames.html")); 3172 embedded_test_server()->GetURL("/frame_tree/page_with_two_frames.html"));
3239 NavigateToURL(shell(), main_url); 3173 NavigateToURL(shell(), main_url);
3240 3174
3241 // It is safe to obtain the root frame tree node here, as it doesn't change. 3175 // It is safe to obtain the root frame tree node here, as it doesn't change.
3242 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 3176 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
3243 ->GetFrameTree()
3244 ->root();
3245 3177
3246 FrameTreeNode* node2 = root->child_at(0); 3178 FrameTreeNode* node2 = root->child_at(0);
3247 FrameTreeNode* node3 = root->child_at(1); 3179 FrameTreeNode* node3 = root->child_at(1);
3248 3180
3249 // Navigate the second iframe to the same process as the first. 3181 // Navigate the second iframe to the same process as the first.
3250 GURL frame_url = embedded_test_server()->GetURL("bar.com", "/title1.html"); 3182 GURL frame_url = embedded_test_server()->GetURL("bar.com", "/title1.html");
3251 NavigateFrameToURL(node3, frame_url); 3183 NavigateFrameToURL(node3, frame_url);
3252 3184
3253 // Verify that they are in the same process. 3185 // Verify that they are in the same process.
3254 EXPECT_EQ(node2->current_frame_host()->GetSiteInstance(), 3186 EXPECT_EQ(node2->current_frame_host()->GetSiteInstance(),
(...skipping 24 matching lines...) Expand all
3279 { 3211 {
3280 GURL main_url( 3212 GURL main_url(
3281 embedded_test_server()->GetURL("/frame_with_load_event.html")); 3213 embedded_test_server()->GetURL("/frame_with_load_event.html"));
3282 base::string16 expected_title(base::UTF8ToUTF16("LOADED")); 3214 base::string16 expected_title(base::UTF8ToUTF16("LOADED"));
3283 TitleWatcher title_watcher(shell()->web_contents(), expected_title); 3215 TitleWatcher title_watcher(shell()->web_contents(), expected_title);
3284 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 3216 EXPECT_TRUE(NavigateToURL(shell(), main_url));
3285 EXPECT_EQ(title_watcher.WaitAndGetTitle(), expected_title); 3217 EXPECT_EQ(title_watcher.WaitAndGetTitle(), expected_title);
3286 } 3218 }
3287 3219
3288 // It is safe to obtain the root frame tree node here, as it doesn't change. 3220 // It is safe to obtain the root frame tree node here, as it doesn't change.
3289 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 3221 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
3290 ->GetFrameTree()
3291 ->root();
3292 3222
3293 // Load another cross-site page into the iframe and check that the load event 3223 // Load another cross-site page into the iframe and check that the load event
3294 // is fired. 3224 // is fired.
3295 { 3225 {
3296 GURL foo_url(embedded_test_server()->GetURL("foo.com", "/title1.html")); 3226 GURL foo_url(embedded_test_server()->GetURL("foo.com", "/title1.html"));
3297 base::string16 expected_title(base::UTF8ToUTF16("LOADEDLOADED")); 3227 base::string16 expected_title(base::UTF8ToUTF16("LOADEDLOADED"));
3298 TitleWatcher title_watcher(shell()->web_contents(), expected_title); 3228 TitleWatcher title_watcher(shell()->web_contents(), expected_title);
3299 TestNavigationObserver observer(shell()->web_contents()); 3229 TestNavigationObserver observer(shell()->web_contents());
3300 NavigateFrameToURL(root->child_at(0), foo_url); 3230 NavigateFrameToURL(root->child_at(0), foo_url);
3301 EXPECT_TRUE(observer.last_navigation_succeeded()); 3231 EXPECT_TRUE(observer.last_navigation_succeeded());
3302 EXPECT_EQ(foo_url, observer.last_navigation_url()); 3232 EXPECT_EQ(foo_url, observer.last_navigation_url());
3303 EXPECT_EQ(title_watcher.WaitAndGetTitle(), expected_title); 3233 EXPECT_EQ(title_watcher.WaitAndGetTitle(), expected_title);
3304 } 3234 }
3305 } 3235 }
3306 3236
3307 // Check that postMessage can be routed between cross-site iframes. 3237 // Check that postMessage can be routed between cross-site iframes.
3308 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, SubframePostMessage) { 3238 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, SubframePostMessage) {
3309 GURL main_url(embedded_test_server()->GetURL( 3239 GURL main_url(embedded_test_server()->GetURL(
3310 "/frame_tree/page_with_post_message_frames.html")); 3240 "/frame_tree/page_with_post_message_frames.html"));
3311 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 3241 EXPECT_TRUE(NavigateToURL(shell(), main_url));
3312 3242
3313 // It is safe to obtain the root frame tree node here, as it doesn't change. 3243 // It is safe to obtain the root frame tree node here, as it doesn't change.
3314 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 3244 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
3315 ->GetFrameTree()
3316 ->root();
3317 3245
3318 ASSERT_EQ(2U, root->child_count()); 3246 ASSERT_EQ(2U, root->child_count());
3319 3247
3320 // Verify the frames start at correct URLs. First frame should be 3248 // Verify the frames start at correct URLs. First frame should be
3321 // same-site; second frame should be cross-site. 3249 // same-site; second frame should be cross-site.
3322 GURL same_site_url(embedded_test_server()->GetURL("/post_message.html")); 3250 GURL same_site_url(embedded_test_server()->GetURL("/post_message.html"));
3323 EXPECT_EQ(same_site_url, root->child_at(0)->current_url()); 3251 EXPECT_EQ(same_site_url, root->child_at(0)->current_url());
3324 GURL foo_url(embedded_test_server()->GetURL("foo.com", 3252 GURL foo_url(embedded_test_server()->GetURL("foo.com",
3325 "/post_message.html")); 3253 "/post_message.html"));
3326 EXPECT_EQ(foo_url, root->child_at(1)->current_url()); 3254 EXPECT_EQ(foo_url, root->child_at(1)->current_url());
(...skipping 25 matching lines...) Expand all
3352 3280
3353 // Check that postMessage can be sent from a subframe on a cross-process opener 3281 // Check that postMessage can be sent from a subframe on a cross-process opener
3354 // tab, and that its event.source points to a valid proxy. 3282 // tab, and that its event.source points to a valid proxy.
3355 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 3283 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
3356 PostMessageWithSubframeOnOpenerChain) { 3284 PostMessageWithSubframeOnOpenerChain) {
3357 GURL main_url(embedded_test_server()->GetURL( 3285 GURL main_url(embedded_test_server()->GetURL(
3358 "a.com", "/frame_tree/page_with_post_message_frames.html")); 3286 "a.com", "/frame_tree/page_with_post_message_frames.html"));
3359 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 3287 EXPECT_TRUE(NavigateToURL(shell(), main_url));
3360 3288
3361 // It is safe to obtain the root frame tree node here, as it doesn't change. 3289 // It is safe to obtain the root frame tree node here, as it doesn't change.
3362 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 3290 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
3363 ->GetFrameTree()
3364 ->root();
3365 3291
3366 ASSERT_EQ(2U, root->child_count()); 3292 ASSERT_EQ(2U, root->child_count());
3367 3293
3368 // Verify the initial state of the world. First frame should be same-site; 3294 // Verify the initial state of the world. First frame should be same-site;
3369 // second frame should be cross-site. 3295 // second frame should be cross-site.
3370 EXPECT_EQ( 3296 EXPECT_EQ(
3371 " Site A ------------ proxies for B\n" 3297 " Site A ------------ proxies for B\n"
3372 " |--Site A ------- proxies for B\n" 3298 " |--Site A ------- proxies for B\n"
3373 " +--Site B ------- proxies for A\n" 3299 " +--Site B ------- proxies for A\n"
3374 "Where A = http://a.com/\n" 3300 "Where A = http://a.com/\n"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
3463 3389
3464 // Check that parent.frames[num] references correct sibling frames when the 3390 // Check that parent.frames[num] references correct sibling frames when the
3465 // parent is remote. See https://crbug.com/478792. 3391 // parent is remote. See https://crbug.com/478792.
3466 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, IndexedFrameAccess) { 3392 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, IndexedFrameAccess) {
3467 // Start on a page with three same-site subframes. 3393 // Start on a page with three same-site subframes.
3468 GURL main_url( 3394 GURL main_url(
3469 embedded_test_server()->GetURL("a.com", "/frame_tree/top.html")); 3395 embedded_test_server()->GetURL("a.com", "/frame_tree/top.html"));
3470 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 3396 EXPECT_TRUE(NavigateToURL(shell(), main_url));
3471 3397
3472 // It is safe to obtain the root frame tree node here, as it doesn't change. 3398 // It is safe to obtain the root frame tree node here, as it doesn't change.
3473 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 3399 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
3474 ->GetFrameTree()
3475 ->root();
3476 ASSERT_EQ(3U, root->child_count()); 3400 ASSERT_EQ(3U, root->child_count());
3477 FrameTreeNode* child0 = root->child_at(0); 3401 FrameTreeNode* child0 = root->child_at(0);
3478 FrameTreeNode* child1 = root->child_at(1); 3402 FrameTreeNode* child1 = root->child_at(1);
3479 FrameTreeNode* child2 = root->child_at(2); 3403 FrameTreeNode* child2 = root->child_at(2);
3480 3404
3481 // Send each of the frames to a different site. Each new renderer will first 3405 // Send each of the frames to a different site. Each new renderer will first
3482 // create proxies for the parent and two sibling subframes and then create 3406 // create proxies for the parent and two sibling subframes and then create
3483 // and insert the new RenderFrame into the frame tree. 3407 // and insert the new RenderFrame into the frame tree.
3484 GURL b_url(embedded_test_server()->GetURL("b.com", "/post_message.html")); 3408 GURL b_url(embedded_test_server()->GetURL("b.com", "/post_message.html"));
3485 GURL c_url(embedded_test_server()->GetURL("c.com", "/post_message.html")); 3409 GURL c_url(embedded_test_server()->GetURL("c.com", "/post_message.html"));
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
3540 EXPECT_EQ(1, GetReceivedMessages(child0)); 3464 EXPECT_EQ(1, GetReceivedMessages(child0));
3541 EXPECT_EQ(2, GetReceivedMessages(child1)); 3465 EXPECT_EQ(2, GetReceivedMessages(child1));
3542 EXPECT_EQ(1, GetReceivedMessages(child2)); 3466 EXPECT_EQ(1, GetReceivedMessages(child2));
3543 } 3467 }
3544 3468
3545 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, RFPHDestruction) { 3469 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, RFPHDestruction) {
3546 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); 3470 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html"));
3547 NavigateToURL(shell(), main_url); 3471 NavigateToURL(shell(), main_url);
3548 3472
3549 // It is safe to obtain the root frame tree node here, as it doesn't change. 3473 // It is safe to obtain the root frame tree node here, as it doesn't change.
3550 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 3474 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
3551 ->GetFrameTree()
3552 ->root();
3553 3475
3554 TestNavigationObserver observer(shell()->web_contents()); 3476 TestNavigationObserver observer(shell()->web_contents());
3555 3477
3556 // Load cross-site page into iframe. 3478 // Load cross-site page into iframe.
3557 FrameTreeNode* child = root->child_at(0); 3479 FrameTreeNode* child = root->child_at(0);
3558 GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html"); 3480 GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html");
3559 NavigateFrameToURL(root->child_at(0), url); 3481 NavigateFrameToURL(root->child_at(0), url);
3560 EXPECT_TRUE(observer.last_navigation_succeeded()); 3482 EXPECT_TRUE(observer.last_navigation_succeeded());
3561 EXPECT_EQ(url, observer.last_navigation_url()); 3483 EXPECT_EQ(url, observer.last_navigation_url());
3562 EXPECT_EQ( 3484 EXPECT_EQ(
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
3601 "Where A = http://127.0.0.1/", 3523 "Where A = http://127.0.0.1/",
3602 DepictFrameTree(root)); 3524 DepictFrameTree(root));
3603 } 3525 }
3604 3526
3605 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OpenPopupWithRemoteParent) { 3527 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OpenPopupWithRemoteParent) {
3606 GURL main_url( 3528 GURL main_url(
3607 embedded_test_server()->GetURL("a.com", "/site_per_process_main.html")); 3529 embedded_test_server()->GetURL("a.com", "/site_per_process_main.html"));
3608 NavigateToURL(shell(), main_url); 3530 NavigateToURL(shell(), main_url);
3609 3531
3610 // It is safe to obtain the root frame tree node here, as it doesn't change. 3532 // It is safe to obtain the root frame tree node here, as it doesn't change.
3611 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 3533 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
3612 ->GetFrameTree()
3613 ->root();
3614 3534
3615 // Navigate first child cross-site. 3535 // Navigate first child cross-site.
3616 GURL frame_url(embedded_test_server()->GetURL("b.com", "/title1.html")); 3536 GURL frame_url(embedded_test_server()->GetURL("b.com", "/title1.html"));
3617 NavigateFrameToURL(root->child_at(0), frame_url); 3537 NavigateFrameToURL(root->child_at(0), frame_url);
3618 3538
3619 // Open a popup from the first child. 3539 // Open a popup from the first child.
3620 Shell* new_shell = OpenPopup(root->child_at(0)->current_frame_host(), 3540 Shell* new_shell = OpenPopup(root->child_at(0)->current_frame_host(),
3621 GURL(url::kAboutBlankURL), ""); 3541 GURL(url::kAboutBlankURL), "");
3622 EXPECT_TRUE(new_shell); 3542 EXPECT_TRUE(new_shell);
3623 3543
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
3669 3589
3670 // Verify that named frames are discoverable from their opener's ancestors. 3590 // Verify that named frames are discoverable from their opener's ancestors.
3671 // See https://crbug.com/511474. 3591 // See https://crbug.com/511474.
3672 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 3592 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
3673 DiscoverNamedFrameFromAncestorOfOpener) { 3593 DiscoverNamedFrameFromAncestorOfOpener) {
3674 GURL main_url( 3594 GURL main_url(
3675 embedded_test_server()->GetURL("a.com", "/site_per_process_main.html")); 3595 embedded_test_server()->GetURL("a.com", "/site_per_process_main.html"));
3676 NavigateToURL(shell(), main_url); 3596 NavigateToURL(shell(), main_url);
3677 3597
3678 // It is safe to obtain the root frame tree node here, as it doesn't change. 3598 // It is safe to obtain the root frame tree node here, as it doesn't change.
3679 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 3599 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
3680 ->GetFrameTree()
3681 ->root();
3682 3600
3683 // Navigate first child cross-site. 3601 // Navigate first child cross-site.
3684 GURL frame_url(embedded_test_server()->GetURL("b.com", "/title1.html")); 3602 GURL frame_url(embedded_test_server()->GetURL("b.com", "/title1.html"));
3685 NavigateFrameToURL(root->child_at(0), frame_url); 3603 NavigateFrameToURL(root->child_at(0), frame_url);
3686 3604
3687 // Open a popup named "foo" from the first child. 3605 // Open a popup named "foo" from the first child.
3688 Shell* foo_shell = OpenPopup(root->child_at(0)->current_frame_host(), 3606 Shell* foo_shell = OpenPopup(root->child_at(0)->current_frame_host(),
3689 GURL(url::kAboutBlankURL), "foo"); 3607 GURL(url::kAboutBlankURL), "foo");
3690 EXPECT_TRUE(foo_shell); 3608 EXPECT_TRUE(foo_shell);
3691 3609
(...skipping 30 matching lines...) Expand all
3722 // still be discoverable from its opener's ancestors. Also, instead of using 3640 // still be discoverable from its opener's ancestors. Also, instead of using
3723 // an opener's ancestor, this test uses a popup with same origin as that 3641 // an opener's ancestor, this test uses a popup with same origin as that
3724 // ancestor. See https://crbug.com/511474. 3642 // ancestor. See https://crbug.com/511474.
3725 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 3643 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
3726 DiscoverFrameAfterSettingWindowName) { 3644 DiscoverFrameAfterSettingWindowName) {
3727 GURL main_url( 3645 GURL main_url(
3728 embedded_test_server()->GetURL("a.com", "/site_per_process_main.html")); 3646 embedded_test_server()->GetURL("a.com", "/site_per_process_main.html"));
3729 NavigateToURL(shell(), main_url); 3647 NavigateToURL(shell(), main_url);
3730 3648
3731 // It is safe to obtain the root frame tree node here, as it doesn't change. 3649 // It is safe to obtain the root frame tree node here, as it doesn't change.
3732 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 3650 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
3733 ->GetFrameTree()
3734 ->root();
3735 3651
3736 // Open a same-site popup from the main frame. 3652 // Open a same-site popup from the main frame.
3737 GURL a_com_url(embedded_test_server()->GetURL("a.com", "/title3.html")); 3653 GURL a_com_url(embedded_test_server()->GetURL("a.com", "/title3.html"));
3738 Shell* a_com_shell = 3654 Shell* a_com_shell =
3739 OpenPopup(root->child_at(0)->current_frame_host(), a_com_url, ""); 3655 OpenPopup(root->child_at(0)->current_frame_host(), a_com_url, "");
3740 EXPECT_TRUE(a_com_shell); 3656 EXPECT_TRUE(a_com_shell);
3741 3657
3742 // Navigate first child on main frame cross-site. 3658 // Navigate first child on main frame cross-site.
3743 GURL frame_url(embedded_test_server()->GetURL("b.com", "/title1.html")); 3659 GURL frame_url(embedded_test_server()->GetURL("b.com", "/title1.html"));
3744 NavigateFrameToURL(root->child_at(0), frame_url); 3660 NavigateFrameToURL(root->child_at(0), frame_url);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
3782 // ^ | 3698 // ^ |
3783 // +--------------------+ 3699 // +--------------------+
3784 // 3700 //
3785 // The sites are carefully set up so that both opener updates are cross-process 3701 // The sites are carefully set up so that both opener updates are cross-process
3786 // but still allowed by Blink's navigation checks. 3702 // but still allowed by Blink's navigation checks.
3787 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, UpdateSubframeOpener) { 3703 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, UpdateSubframeOpener) {
3788 GURL main_url = embedded_test_server()->GetURL( 3704 GURL main_url = embedded_test_server()->GetURL(
3789 "foo.com", "/frame_tree/page_with_two_frames.html"); 3705 "foo.com", "/frame_tree/page_with_two_frames.html");
3790 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 3706 EXPECT_TRUE(NavigateToURL(shell(), main_url));
3791 3707
3792 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 3708 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
3793 ->GetFrameTree()
3794 ->root();
3795 EXPECT_EQ(2U, root->child_count()); 3709 EXPECT_EQ(2U, root->child_count());
3796 3710
3797 // From the top frame, open a popup and navigate it to a cross-site page with 3711 // From the top frame, open a popup and navigate it to a cross-site page with
3798 // two subframes. 3712 // two subframes.
3799 Shell* popup_shell = 3713 Shell* popup_shell =
3800 OpenPopup(shell()->web_contents(), GURL(url::kAboutBlankURL), "popup"); 3714 OpenPopup(shell()->web_contents(), GURL(url::kAboutBlankURL), "popup");
3801 EXPECT_TRUE(popup_shell); 3715 EXPECT_TRUE(popup_shell);
3802 GURL popup_url(embedded_test_server()->GetURL( 3716 GURL popup_url(embedded_test_server()->GetURL(
3803 "bar.com", "/frame_tree/page_with_post_message_frames.html")); 3717 "bar.com", "/frame_tree/page_with_post_message_frames.html"));
3804 NavigateToURL(popup_shell, popup_url); 3718 NavigateToURL(popup_shell, popup_url);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
3857 3771
3858 // Check that when a subframe navigates to a new SiteInstance, the new 3772 // Check that when a subframe navigates to a new SiteInstance, the new
3859 // SiteInstance will get a proxy for the opener of subframe's parent. I.e., 3773 // SiteInstance will get a proxy for the opener of subframe's parent. I.e.,
3860 // accessing parent.opener from the subframe should still work after a 3774 // accessing parent.opener from the subframe should still work after a
3861 // cross-process navigation. 3775 // cross-process navigation.
3862 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 3776 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
3863 NavigatingSubframePreservesOpenerInParent) { 3777 NavigatingSubframePreservesOpenerInParent) {
3864 GURL main_url = embedded_test_server()->GetURL("a.com", "/post_message.html"); 3778 GURL main_url = embedded_test_server()->GetURL("a.com", "/post_message.html");
3865 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 3779 EXPECT_TRUE(NavigateToURL(shell(), main_url));
3866 3780
3867 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 3781 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
3868 ->GetFrameTree()
3869 ->root();
3870 3782
3871 // Open a popup with a cross-site page that has a subframe. 3783 // Open a popup with a cross-site page that has a subframe.
3872 GURL popup_url(embedded_test_server()->GetURL( 3784 GURL popup_url(embedded_test_server()->GetURL(
3873 "b.com", "/cross_site_iframe_factory.html?b(b)")); 3785 "b.com", "/cross_site_iframe_factory.html?b(b)"));
3874 Shell* popup_shell = OpenPopup(shell()->web_contents(), popup_url, "popup"); 3786 Shell* popup_shell = OpenPopup(shell()->web_contents(), popup_url, "popup");
3875 EXPECT_TRUE(popup_shell); 3787 EXPECT_TRUE(popup_shell);
3876 FrameTreeNode* popup_root = 3788 FrameTreeNode* popup_root =
3877 static_cast<WebContentsImpl*>(popup_shell->web_contents()) 3789 static_cast<WebContentsImpl*>(popup_shell->web_contents())
3878 ->GetFrameTree() 3790 ->GetFrameTree()
3879 ->root(); 3791 ->root();
(...skipping 26 matching lines...) Expand all
3906 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 3818 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
3907 } 3819 }
3908 3820
3909 // Check that if a subframe has an opener, that opener is preserved when the 3821 // Check that if a subframe has an opener, that opener is preserved when the
3910 // subframe navigates cross-site. 3822 // subframe navigates cross-site.
3911 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, NavigateSubframeWithOpener) { 3823 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, NavigateSubframeWithOpener) {
3912 GURL main_url(embedded_test_server()->GetURL( 3824 GURL main_url(embedded_test_server()->GetURL(
3913 "foo.com", "/frame_tree/page_with_two_frames.html")); 3825 "foo.com", "/frame_tree/page_with_two_frames.html"));
3914 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 3826 EXPECT_TRUE(NavigateToURL(shell(), main_url));
3915 3827
3916 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 3828 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
3917 ->GetFrameTree()
3918 ->root();
3919 EXPECT_EQ( 3829 EXPECT_EQ(
3920 " Site A ------------ proxies for B\n" 3830 " Site A ------------ proxies for B\n"
3921 " |--Site B ------- proxies for A\n" 3831 " |--Site B ------- proxies for A\n"
3922 " +--Site A ------- proxies for B\n" 3832 " +--Site A ------- proxies for B\n"
3923 "Where A = http://foo.com/\n" 3833 "Where A = http://foo.com/\n"
3924 " B = http://bar.com/", 3834 " B = http://bar.com/",
3925 DepictFrameTree(root)); 3835 DepictFrameTree(root));
3926 3836
3927 // Update the first (cross-site) subframe's opener to root frame. 3837 // Update the first (cross-site) subframe's opener to root frame.
3928 bool success = false; 3838 bool success = false;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
3973 // RenderFrameProxy is created for that subframe in another renderer process. 3883 // RenderFrameProxy is created for that subframe in another renderer process.
3974 // Similar to NavigateSubframeWithOpener, but this test verifies the subframe 3884 // Similar to NavigateSubframeWithOpener, but this test verifies the subframe
3975 // opener plumbing for FrameMsg_NewFrameProxy, whereas 3885 // opener plumbing for FrameMsg_NewFrameProxy, whereas
3976 // NavigateSubframeWithOpener targets FrameMsg_NewFrame. 3886 // NavigateSubframeWithOpener targets FrameMsg_NewFrame.
3977 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 3887 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
3978 NewRenderFrameProxyPreservesOpener) { 3888 NewRenderFrameProxyPreservesOpener) {
3979 GURL main_url( 3889 GURL main_url(
3980 embedded_test_server()->GetURL("foo.com", "/post_message.html")); 3890 embedded_test_server()->GetURL("foo.com", "/post_message.html"));
3981 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 3891 EXPECT_TRUE(NavigateToURL(shell(), main_url));
3982 3892
3983 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 3893 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
3984 ->GetFrameTree()
3985 ->root();
3986 3894
3987 // Open a popup with a cross-site page that has two subframes. 3895 // Open a popup with a cross-site page that has two subframes.
3988 GURL popup_url(embedded_test_server()->GetURL( 3896 GURL popup_url(embedded_test_server()->GetURL(
3989 "bar.com", "/frame_tree/page_with_post_message_frames.html")); 3897 "bar.com", "/frame_tree/page_with_post_message_frames.html"));
3990 Shell* popup_shell = OpenPopup(shell()->web_contents(), popup_url, "popup"); 3898 Shell* popup_shell = OpenPopup(shell()->web_contents(), popup_url, "popup");
3991 EXPECT_TRUE(popup_shell); 3899 EXPECT_TRUE(popup_shell);
3992 FrameTreeNode* popup_root = 3900 FrameTreeNode* popup_root =
3993 static_cast<WebContentsImpl*>(popup_shell->web_contents()) 3901 static_cast<WebContentsImpl*>(popup_shell->web_contents())
3994 ->GetFrameTree() 3902 ->GetFrameTree()
3995 ->root(); 3903 ->root();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
4062 DISABLED_RenderViewHostPendingDeletionIsNotReused 3970 DISABLED_RenderViewHostPendingDeletionIsNotReused
4063 #else 3971 #else
4064 #define MAYBE_RenderViewHostPendingDeletionIsNotReused \ 3972 #define MAYBE_RenderViewHostPendingDeletionIsNotReused \
4065 RenderViewHostPendingDeletionIsNotReused 3973 RenderViewHostPendingDeletionIsNotReused
4066 #endif 3974 #endif
4067 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 3975 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
4068 MAYBE_RenderViewHostPendingDeletionIsNotReused) { 3976 MAYBE_RenderViewHostPendingDeletionIsNotReused) {
4069 GURL a_url(embedded_test_server()->GetURL("a.com", "/title1.html")); 3977 GURL a_url(embedded_test_server()->GetURL("a.com", "/title1.html"));
4070 NavigateToURL(shell(), a_url); 3978 NavigateToURL(shell(), a_url);
4071 3979
4072 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 3980 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
4073 ->GetFrameTree()
4074 ->root();
4075 RenderFrameHostImpl* rfh = root->current_frame_host(); 3981 RenderFrameHostImpl* rfh = root->current_frame_host();
4076 RenderViewHostImpl* rvh = rfh->render_view_host(); 3982 RenderViewHostImpl* rvh = rfh->render_view_host();
4077 RenderFrameDeletedObserver deleted_observer(rfh); 3983 RenderFrameDeletedObserver deleted_observer(rfh);
4078 3984
4079 // Install a BrowserMessageFilter to drop SwapOut ACK messages in A's 3985 // Install a BrowserMessageFilter to drop SwapOut ACK messages in A's
4080 // process. 3986 // process.
4081 scoped_refptr<SwapoutACKMessageFilter> filter = new SwapoutACKMessageFilter(); 3987 scoped_refptr<SwapoutACKMessageFilter> filter = new SwapoutACKMessageFilter();
4082 rfh->GetProcess()->AddFilter(filter.get()); 3988 rfh->GetProcess()->AddFilter(filter.get());
4083 3989
4084 // Navigate to B. This must wait for DidCommitProvisionalLoad, as opposed to 3990 // Navigate to B. This must wait for DidCommitProvisionalLoad, as opposed to
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
4125 // Check that when a cross-process frame acquires focus, the old focused frame 4031 // Check that when a cross-process frame acquires focus, the old focused frame
4126 // loses focus and fires blur events. Starting on a page with a cross-site 4032 // loses focus and fires blur events. Starting on a page with a cross-site
4127 // subframe, simulate mouse clicks to switch focus from root frame to subframe 4033 // subframe, simulate mouse clicks to switch focus from root frame to subframe
4128 // and then back to root frame. 4034 // and then back to root frame.
4129 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 4035 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
4130 CrossProcessFocusChangeFiresBlurEvents) { 4036 CrossProcessFocusChangeFiresBlurEvents) {
4131 GURL main_url( 4037 GURL main_url(
4132 embedded_test_server()->GetURL("a.com", "/page_with_input_field.html")); 4038 embedded_test_server()->GetURL("a.com", "/page_with_input_field.html"));
4133 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 4039 EXPECT_TRUE(NavigateToURL(shell(), main_url));
4134 4040
4135 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 4041 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
4136 ->GetFrameTree()
4137 ->root();
4138 4042
4139 EXPECT_EQ( 4043 EXPECT_EQ(
4140 " Site A ------------ proxies for B\n" 4044 " Site A ------------ proxies for B\n"
4141 " +--Site B ------- proxies for A\n" 4045 " +--Site B ------- proxies for A\n"
4142 "Where A = http://a.com/\n" 4046 "Where A = http://a.com/\n"
4143 " B = http://b.com/", 4047 " B = http://b.com/",
4144 DepictFrameTree(root)); 4048 DepictFrameTree(root));
4145 4049
4146 // Focus the main frame's text field. The return value "input-focus" 4050 // Focus the main frame's text field. The return value "input-focus"
4147 // indicates that the focus event was fired correctly. 4051 // indicates that the focus event was fired correctly.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
4187 4091
4188 // Check that when a cross-process subframe is focused, its parent's 4092 // Check that when a cross-process subframe is focused, its parent's
4189 // document.activeElement correctly returns the corresponding <iframe> element. 4093 // document.activeElement correctly returns the corresponding <iframe> element.
4190 // The test sets up an A-embed-B-embed-C page and shifts focus A->B->A->C, 4094 // The test sets up an A-embed-B-embed-C page and shifts focus A->B->A->C,
4191 // checking document.activeElement after each change. 4095 // checking document.activeElement after each change.
4192 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DocumentActiveElement) { 4096 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DocumentActiveElement) {
4193 GURL main_url(embedded_test_server()->GetURL( 4097 GURL main_url(embedded_test_server()->GetURL(
4194 "a.com", "/cross_site_iframe_factory.html?a(b(c))")); 4098 "a.com", "/cross_site_iframe_factory.html?a(b(c))"));
4195 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 4099 EXPECT_TRUE(NavigateToURL(shell(), main_url));
4196 4100
4197 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 4101 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
4198 ->GetFrameTree()
4199 ->root();
4200 4102
4201 EXPECT_EQ( 4103 EXPECT_EQ(
4202 " Site A ------------ proxies for B C\n" 4104 " Site A ------------ proxies for B C\n"
4203 " +--Site B ------- proxies for A C\n" 4105 " +--Site B ------- proxies for A C\n"
4204 " +--Site C -- proxies for A B\n" 4106 " +--Site C -- proxies for A B\n"
4205 "Where A = http://a.com/\n" 4107 "Where A = http://a.com/\n"
4206 " B = http://b.com/\n" 4108 " B = http://b.com/\n"
4207 " C = http://c.com/", 4109 " C = http://c.com/",
4208 DepictFrameTree(root)); 4110 DepictFrameTree(root));
4209 4111
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
4266 // The test builds a page with four cross-site frames and then focuses them one 4168 // The test builds a page with four cross-site frames and then focuses them one
4267 // by one, checking the value of document.hasFocus() in all frames. For any 4169 // by one, checking the value of document.hasFocus() in all frames. For any
4268 // given focused frame, document.hasFocus() should return true for that frame 4170 // given focused frame, document.hasFocus() should return true for that frame
4269 // and all its ancestor frames. 4171 // and all its ancestor frames.
4270 // Disabled due to flakes; see https://crbug.com/559273. 4172 // Disabled due to flakes; see https://crbug.com/559273.
4271 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DISABLED_DocumentHasFocus) { 4173 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DISABLED_DocumentHasFocus) {
4272 GURL main_url(embedded_test_server()->GetURL( 4174 GURL main_url(embedded_test_server()->GetURL(
4273 "a.com", "/cross_site_iframe_factory.html?a(b(c),d)")); 4175 "a.com", "/cross_site_iframe_factory.html?a(b(c),d)"));
4274 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 4176 EXPECT_TRUE(NavigateToURL(shell(), main_url));
4275 4177
4276 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 4178 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
4277 ->GetFrameTree()
4278 ->root();
4279 4179
4280 EXPECT_EQ( 4180 EXPECT_EQ(
4281 " Site A ------------ proxies for B C D\n" 4181 " Site A ------------ proxies for B C D\n"
4282 " |--Site B ------- proxies for A C D\n" 4182 " |--Site B ------- proxies for A C D\n"
4283 " | +--Site C -- proxies for A B D\n" 4183 " | +--Site C -- proxies for A B D\n"
4284 " +--Site D ------- proxies for A B C\n" 4184 " +--Site D ------- proxies for A B C\n"
4285 "Where A = http://a.com/\n" 4185 "Where A = http://a.com/\n"
4286 " B = http://b.com/\n" 4186 " B = http://b.com/\n"
4287 " C = http://c.com/\n" 4187 " C = http://c.com/\n"
4288 " D = http://d.com/", 4188 " D = http://d.com/",
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
4334 EXPECT_FALSE(document_has_focus(grandchild)); 4234 EXPECT_FALSE(document_has_focus(grandchild));
4335 EXPECT_TRUE(document_has_focus(child2)); 4235 EXPECT_TRUE(document_has_focus(child2));
4336 } 4236 }
4337 4237
4338 // Check that window.focus works for cross-process subframes. 4238 // Check that window.focus works for cross-process subframes.
4339 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, SubframeWindowFocus) { 4239 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, SubframeWindowFocus) {
4340 GURL main_url(embedded_test_server()->GetURL( 4240 GURL main_url(embedded_test_server()->GetURL(
4341 "a.com", "/cross_site_iframe_factory.html?a(b,c)")); 4241 "a.com", "/cross_site_iframe_factory.html?a(b,c)"));
4342 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 4242 EXPECT_TRUE(NavigateToURL(shell(), main_url));
4343 4243
4344 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 4244 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
4345 ->GetFrameTree()
4346 ->root();
4347 4245
4348 EXPECT_EQ( 4246 EXPECT_EQ(
4349 " Site A ------------ proxies for B C\n" 4247 " Site A ------------ proxies for B C\n"
4350 " |--Site B ------- proxies for A C\n" 4248 " |--Site B ------- proxies for A C\n"
4351 " +--Site C ------- proxies for A B\n" 4249 " +--Site C ------- proxies for A B\n"
4352 "Where A = http://a.com/\n" 4250 "Where A = http://a.com/\n"
4353 " B = http://b.com/\n" 4251 " B = http://b.com/\n"
4354 " C = http://c.com/", 4252 " C = http://c.com/",
4355 DepictFrameTree(root)); 4253 DepictFrameTree(root));
4356 4254
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
4473 4371
4474 // Verify that we receive a mouse cursor update message when we mouse over 4372 // Verify that we receive a mouse cursor update message when we mouse over
4475 // a text field contained in an out-of-process iframe. 4373 // a text field contained in an out-of-process iframe.
4476 // Fails under TSan. http://crbug.com/545237 4374 // Fails under TSan. http://crbug.com/545237
4477 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 4375 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
4478 DISABLED_CursorUpdateFromReceivedFromCrossSiteIframe) { 4376 DISABLED_CursorUpdateFromReceivedFromCrossSiteIframe) {
4479 GURL main_url(embedded_test_server()->GetURL( 4377 GURL main_url(embedded_test_server()->GetURL(
4480 "/frame_tree/page_with_positioned_frame.html")); 4378 "/frame_tree/page_with_positioned_frame.html"));
4481 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 4379 EXPECT_TRUE(NavigateToURL(shell(), main_url));
4482 4380
4483 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 4381 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
4484 ->GetFrameTree()
4485 ->root();
4486 4382
4487 FrameTreeNode* child_node = root->child_at(0); 4383 FrameTreeNode* child_node = root->child_at(0);
4488 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), 4384 EXPECT_NE(shell()->web_contents()->GetSiteInstance(),
4489 child_node->current_frame_host()->GetSiteInstance()); 4385 child_node->current_frame_host()->GetSiteInstance());
4490 4386
4491 scoped_refptr<CursorMessageFilter> filter = new CursorMessageFilter(); 4387 scoped_refptr<CursorMessageFilter> filter = new CursorMessageFilter();
4492 child_node->current_frame_host()->GetProcess()->AddFilter(filter.get()); 4388 child_node->current_frame_host()->GetProcess()->AddFilter(filter.get());
4493 4389
4494 // Send a MouseMove to the subframe. The frame contains text, and moving the 4390 // Send a MouseMove to the subframe. The frame contains text, and moving the
4495 // mouse over it should cause the renderer to send a mouse cursor update. 4391 // mouse over it should cause the renderer to send a mouse cursor update.
4496 blink::WebMouseEvent mouse_event; 4392 blink::WebMouseEvent mouse_event;
4497 mouse_event.type = blink::WebInputEvent::MouseMove; 4393 mouse_event.type = blink::WebInputEvent::MouseMove;
4498 mouse_event.x = 60; 4394 mouse_event.x = 60;
4499 mouse_event.y = 60; 4395 mouse_event.y = 60;
4500 RenderWidgetHost* rwh_child = 4396 RenderWidgetHost* rwh_child =
4501 root->child_at(0)->current_frame_host()->GetRenderWidgetHost(); 4397 root->child_at(0)->current_frame_host()->GetRenderWidgetHost();
4502 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( 4398 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>(
4503 root->current_frame_host()->GetRenderWidgetHost()->GetView()); 4399 root->current_frame_host()->GetRenderWidgetHost()->GetView());
4504 static_cast<WebContentsImpl*>(shell()->web_contents()) 4400 GetWebContents()->GetInputEventRouter()->RouteMouseEvent(root_view,
4505 ->GetInputEventRouter() 4401 &mouse_event);
4506 ->RouteMouseEvent(root_view, &mouse_event);
4507 4402
4508 // CursorMessageFilter::Wait() implicitly tests whether we receive a 4403 // CursorMessageFilter::Wait() implicitly tests whether we receive a
4509 // ViewHostMsg_SetCursor message from the renderer process, because it does 4404 // ViewHostMsg_SetCursor message from the renderer process, because it does
4510 // does not return otherwise. 4405 // does not return otherwise.
4511 filter->Wait(); 4406 filter->Wait();
4512 EXPECT_EQ(filter->last_set_cursor_routing_id(), rwh_child->GetRoutingID()); 4407 EXPECT_EQ(filter->last_set_cursor_routing_id(), rwh_child->GetRoutingID());
4513 } 4408 }
4514 #endif 4409 #endif
4515 4410
4516 // Tests that we are using the correct RenderFrameProxy when navigating an 4411 // Tests that we are using the correct RenderFrameProxy when navigating an
(...skipping 22 matching lines...) Expand all
4539 #if defined(USE_AURA) 4434 #if defined(USE_AURA)
4540 // Browser process hit testing is not implemented on Android, and this test 4435 // Browser process hit testing is not implemented on Android, and this test
4541 // requires Aura for RenderWidgetHostViewAura::OnTouchEvent(). 4436 // requires Aura for RenderWidgetHostViewAura::OnTouchEvent().
4542 // https://crbug.com/491334 4437 // https://crbug.com/491334
4543 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 4438 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
4544 SubframeTouchEventRouting) { 4439 SubframeTouchEventRouting) {
4545 GURL main_url(embedded_test_server()->GetURL( 4440 GURL main_url(embedded_test_server()->GetURL(
4546 "/frame_tree/page_with_positioned_nested_frames.html")); 4441 "/frame_tree/page_with_positioned_nested_frames.html"));
4547 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 4442 EXPECT_TRUE(NavigateToURL(shell(), main_url));
4548 4443
4549 WebContentsImpl* web_contents = 4444 WebContentsImpl* web_contents = GetWebContents();
4550 static_cast<WebContentsImpl*>(shell()->web_contents());
4551 FrameTreeNode* root = web_contents->GetFrameTree()->root(); 4445 FrameTreeNode* root = web_contents->GetFrameTree()->root();
4552 ASSERT_EQ(1U, root->child_count()); 4446 ASSERT_EQ(1U, root->child_count());
4553 4447
4554 GURL frame_url( 4448 GURL frame_url(
4555 embedded_test_server()->GetURL("b.com", "/page_with_touch_handler.html")); 4449 embedded_test_server()->GetURL("b.com", "/page_with_touch_handler.html"));
4556 NavigateFrameToURL(root->child_at(0), frame_url); 4450 NavigateFrameToURL(root->child_at(0), frame_url);
4557 EXPECT_TRUE(WaitForRenderFrameReady(root->child_at(0)->current_frame_host())); 4451 EXPECT_TRUE(WaitForRenderFrameReady(root->child_at(0)->current_frame_host()));
4558 4452
4559 // Synchronize with the child and parent renderers to guarantee that the 4453 // Synchronize with the child and parent renderers to guarantee that the
4560 // surface information required for event hit testing is ready. 4454 // surface information required for event hit testing is ready.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
4596 #define MAYBE_SubframeGestureEventRouting DISABLED_SubframeGestureEventRouting 4490 #define MAYBE_SubframeGestureEventRouting DISABLED_SubframeGestureEventRouting
4597 #else 4491 #else
4598 #define MAYBE_SubframeGestureEventRouting SubframeGestureEventRouting 4492 #define MAYBE_SubframeGestureEventRouting SubframeGestureEventRouting
4599 #endif 4493 #endif
4600 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 4494 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
4601 MAYBE_SubframeGestureEventRouting) { 4495 MAYBE_SubframeGestureEventRouting) {
4602 GURL main_url(embedded_test_server()->GetURL( 4496 GURL main_url(embedded_test_server()->GetURL(
4603 "/frame_tree/page_with_positioned_nested_frames.html")); 4497 "/frame_tree/page_with_positioned_nested_frames.html"));
4604 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 4498 EXPECT_TRUE(NavigateToURL(shell(), main_url));
4605 4499
4606 WebContentsImpl* web_contents = 4500 WebContentsImpl* web_contents = GetWebContents();
4607 static_cast<WebContentsImpl*>(shell()->web_contents());
4608 FrameTreeNode* root = web_contents->GetFrameTree()->root(); 4501 FrameTreeNode* root = web_contents->GetFrameTree()->root();
4609 ASSERT_EQ(1U, root->child_count()); 4502 ASSERT_EQ(1U, root->child_count());
4610 4503
4611 GURL frame_url( 4504 GURL frame_url(
4612 embedded_test_server()->GetURL("b.com", "/page_with_click_handler.html")); 4505 embedded_test_server()->GetURL("b.com", "/page_with_click_handler.html"));
4613 NavigateFrameToURL(root->child_at(0), frame_url); 4506 NavigateFrameToURL(root->child_at(0), frame_url);
4614 auto child_frame_host = root->child_at(0)->current_frame_host(); 4507 auto child_frame_host = root->child_at(0)->current_frame_host();
4615 EXPECT_TRUE(WaitForRenderFrameReady(child_frame_host)); 4508 EXPECT_TRUE(WaitForRenderFrameReady(child_frame_host));
4616 4509
4617 // Synchronize with the child and parent renderers to guarantee that the 4510 // Synchronize with the child and parent renderers to guarantee that the
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
4732 } 4625 }
4733 4626
4734 } // namespace anonymous 4627 } // namespace anonymous
4735 4628
4736 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 4629 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
4737 InputEventRouterGestureTargetQueueTest) { 4630 InputEventRouterGestureTargetQueueTest) {
4738 GURL main_url(embedded_test_server()->GetURL( 4631 GURL main_url(embedded_test_server()->GetURL(
4739 "/frame_tree/page_with_positioned_nested_frames.html")); 4632 "/frame_tree/page_with_positioned_nested_frames.html"));
4740 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 4633 EXPECT_TRUE(NavigateToURL(shell(), main_url));
4741 4634
4742 WebContentsImpl* web_contents = 4635 WebContentsImpl* web_contents = GetWebContents();
4743 static_cast<WebContentsImpl*>(shell()->web_contents());
4744 FrameTreeNode* root = web_contents->GetFrameTree()->root(); 4636 FrameTreeNode* root = web_contents->GetFrameTree()->root();
4745 ASSERT_EQ(1U, root->child_count()); 4637 ASSERT_EQ(1U, root->child_count());
4746 4638
4747 GURL frame_url( 4639 GURL frame_url(
4748 embedded_test_server()->GetURL("b.com", "/page_with_click_handler.html")); 4640 embedded_test_server()->GetURL("b.com", "/page_with_click_handler.html"));
4749 NavigateFrameToURL(root->child_at(0), frame_url); 4641 NavigateFrameToURL(root->child_at(0), frame_url);
4750 auto child_frame_host = root->child_at(0)->current_frame_host(); 4642 auto child_frame_host = root->child_at(0)->current_frame_host();
4751 EXPECT_TRUE(WaitForRenderFrameReady(child_frame_host)); 4643 EXPECT_TRUE(WaitForRenderFrameReady(child_frame_host));
4752 4644
4753 // Synchronize with the child and parent renderers to guarantee that the 4645 // Synchronize with the child and parent renderers to guarantee that the
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
4821 #endif // defined(USE_AURA) 4713 #endif // defined(USE_AURA)
4822 4714
4823 // Ensure that a cross-process subframe can receive keyboard events when in 4715 // Ensure that a cross-process subframe can receive keyboard events when in
4824 // focus. 4716 // focus.
4825 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 4717 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
4826 SubframeKeyboardEventRouting) { 4718 SubframeKeyboardEventRouting) {
4827 GURL main_url(embedded_test_server()->GetURL( 4719 GURL main_url(embedded_test_server()->GetURL(
4828 "a.com", "/frame_tree/page_with_one_frame.html")); 4720 "a.com", "/frame_tree/page_with_one_frame.html"));
4829 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 4721 EXPECT_TRUE(NavigateToURL(shell(), main_url));
4830 4722
4831 WebContentsImpl* web_contents = 4723 WebContentsImpl* web_contents = GetWebContents();
4832 static_cast<WebContentsImpl*>(shell()->web_contents());
4833 FrameTreeNode* root = web_contents->GetFrameTree()->root(); 4724 FrameTreeNode* root = web_contents->GetFrameTree()->root();
4834 4725
4835 GURL frame_url( 4726 GURL frame_url(
4836 embedded_test_server()->GetURL("b.com", "/page_with_input_field.html")); 4727 embedded_test_server()->GetURL("b.com", "/page_with_input_field.html"));
4837 NavigateFrameToURL(root->child_at(0), frame_url); 4728 NavigateFrameToURL(root->child_at(0), frame_url);
4838 EXPECT_TRUE(WaitForRenderFrameReady(root->child_at(0)->current_frame_host())); 4729 EXPECT_TRUE(WaitForRenderFrameReady(root->child_at(0)->current_frame_host()));
4839 4730
4840 // Focus the subframe and then its input field. The return value 4731 // Focus the subframe and then its input field. The return value
4841 // "input-focus" will be sent once the input field's focus event fires. 4732 // "input-focus" will be sent once the input field's focus event fires.
4842 FocusFrame(root->child_at(0)); 4733 FocusFrame(root->child_at(0));
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
4987 #define MAYBE_CreateContextMenuTest DISABLED_CreateContextMenuTest 4878 #define MAYBE_CreateContextMenuTest DISABLED_CreateContextMenuTest
4988 #else 4879 #else
4989 #define MAYBE_CreateContextMenuTest CreateContextMenuTest 4880 #define MAYBE_CreateContextMenuTest CreateContextMenuTest
4990 #endif 4881 #endif
4991 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_CreateContextMenuTest) { 4882 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_CreateContextMenuTest) {
4992 GURL main_url(embedded_test_server()->GetURL( 4883 GURL main_url(embedded_test_server()->GetURL(
4993 "/frame_tree/page_with_positioned_frame.html")); 4884 "/frame_tree/page_with_positioned_frame.html"));
4994 NavigateToURL(shell(), main_url); 4885 NavigateToURL(shell(), main_url);
4995 4886
4996 // It is safe to obtain the root frame tree node here, as it doesn't change. 4887 // It is safe to obtain the root frame tree node here, as it doesn't change.
4997 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 4888 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
4998 ->GetFrameTree()
4999 ->root();
5000 ASSERT_EQ(1U, root->child_count()); 4889 ASSERT_EQ(1U, root->child_count());
5001 4890
5002 FrameTreeNode* child_node = root->child_at(0); 4891 FrameTreeNode* child_node = root->child_at(0);
5003 GURL site_url(embedded_test_server()->GetURL("baz.com", "/title1.html")); 4892 GURL site_url(embedded_test_server()->GetURL("baz.com", "/title1.html"));
5004 EXPECT_EQ(site_url, child_node->current_url()); 4893 EXPECT_EQ(site_url, child_node->current_url());
5005 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), 4894 EXPECT_NE(shell()->web_contents()->GetSiteInstance(),
5006 child_node->current_frame_host()->GetSiteInstance()); 4895 child_node->current_frame_host()->GetSiteInstance());
5007 4896
5008 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( 4897 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>(
5009 root->current_frame_host()->GetRenderWidgetHost()->GetView()); 4898 root->current_frame_host()->GetRenderWidgetHost()->GetView());
(...skipping 12 matching lines...) Expand all
5022 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 4911 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
5023 FROM_HERE, run_loop.QuitClosure(), TestTimeouts::tiny_timeout()); 4912 FROM_HERE, run_loop.QuitClosure(), TestTimeouts::tiny_timeout());
5024 run_loop.Run(); 4913 run_loop.Run();
5025 } 4914 }
5026 4915
5027 // A WebContentsDelegate to listen for the ShowContextMenu message. 4916 // A WebContentsDelegate to listen for the ShowContextMenu message.
5028 ContextMenuObserverDelegate context_menu_delegate; 4917 ContextMenuObserverDelegate context_menu_delegate;
5029 shell()->web_contents()->SetDelegate(&context_menu_delegate); 4918 shell()->web_contents()->SetDelegate(&context_menu_delegate);
5030 4919
5031 RenderWidgetHostInputEventRouter* router = 4920 RenderWidgetHostInputEventRouter* router =
5032 static_cast<WebContentsImpl*>(shell()->web_contents()) 4921 GetWebContents()->GetInputEventRouter();
5033 ->GetInputEventRouter();
5034 4922
5035 // Target right-click event to child frame. 4923 // Target right-click event to child frame.
5036 blink::WebMouseEvent click_event; 4924 blink::WebMouseEvent click_event;
5037 click_event.type = blink::WebInputEvent::MouseDown; 4925 click_event.type = blink::WebInputEvent::MouseDown;
5038 click_event.button = blink::WebPointerProperties::ButtonRight; 4926 click_event.button = blink::WebPointerProperties::ButtonRight;
5039 click_event.x = 75; 4927 click_event.x = 75;
5040 click_event.y = 75; 4928 click_event.y = 75;
5041 click_event.clickCount = 1; 4929 click_event.clickCount = 1;
5042 router->RouteMouseEvent(root_view, &click_event); 4930 router->RouteMouseEvent(root_view, &click_event);
5043 4931
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
5225 // if a pending cross-process navigation is cancelled. The test works by trying 5113 // if a pending cross-process navigation is cancelled. The test works by trying
5226 // to create a new RenderFrame with the same routing id. If there is an 5114 // to create a new RenderFrame with the same routing id. If there is an
5227 // entry with the same routing ID, a CHECK is hit and the process crashes. 5115 // entry with the same routing ID, a CHECK is hit and the process crashes.
5228 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 5116 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
5229 SubframePendingAndBackToSameSiteInstance) { 5117 SubframePendingAndBackToSameSiteInstance) {
5230 GURL main_url(embedded_test_server()->GetURL( 5118 GURL main_url(embedded_test_server()->GetURL(
5231 "a.com", "/cross_site_iframe_factory.html?a(b)")); 5119 "a.com", "/cross_site_iframe_factory.html?a(b)"));
5232 NavigateToURL(shell(), main_url); 5120 NavigateToURL(shell(), main_url);
5233 5121
5234 // Capture the FrameTreeNode this test will be navigating. 5122 // Capture the FrameTreeNode this test will be navigating.
5235 FrameTreeNode* node = static_cast<WebContentsImpl*>(shell()->web_contents()) 5123 FrameTreeNode* node = GetWebContents()->GetFrameTree()->root()->child_at(0);
5236 ->GetFrameTree()
5237 ->root()
5238 ->child_at(0);
5239 EXPECT_TRUE(node); 5124 EXPECT_TRUE(node);
5240 EXPECT_NE(node->current_frame_host()->GetSiteInstance(), 5125 EXPECT_NE(node->current_frame_host()->GetSiteInstance(),
5241 node->parent()->current_frame_host()->GetSiteInstance()); 5126 node->parent()->current_frame_host()->GetSiteInstance());
5242 5127
5243 // Navigate to the site of the parent, but to a page that will not commit. 5128 // Navigate to the site of the parent, but to a page that will not commit.
5244 GURL same_site_url(embedded_test_server()->GetURL("a.com", "/title1.html")); 5129 GURL same_site_url(embedded_test_server()->GetURL("a.com", "/title1.html"));
5245 NavigationStallDelegate stall_delegate(same_site_url); 5130 NavigationStallDelegate stall_delegate(same_site_url);
5246 ResourceDispatcherHost::Get()->SetDelegate(&stall_delegate); 5131 ResourceDispatcherHost::Get()->SetDelegate(&stall_delegate);
5247 { 5132 {
5248 NavigationController::LoadURLParams params(same_site_url); 5133 NavigationController::LoadURLParams params(same_site_url);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
5302 5187
5303 // This test ensures that the RenderFrame isn't leaked in the renderer process 5188 // This test ensures that the RenderFrame isn't leaked in the renderer process
5304 // when a remote parent detaches a child frame. The test works by trying 5189 // when a remote parent detaches a child frame. The test works by trying
5305 // to create a new RenderFrame with the same routing id. If there is an 5190 // to create a new RenderFrame with the same routing id. If there is an
5306 // entry with the same routing ID, a CHECK is hit and the process crashes. 5191 // entry with the same routing ID, a CHECK is hit and the process crashes.
5307 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ParentDetachRemoteChild) { 5192 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ParentDetachRemoteChild) {
5308 GURL main_url(embedded_test_server()->GetURL( 5193 GURL main_url(embedded_test_server()->GetURL(
5309 "a.com", "/cross_site_iframe_factory.html?a(b,b)")); 5194 "a.com", "/cross_site_iframe_factory.html?a(b,b)"));
5310 NavigateToURL(shell(), main_url); 5195 NavigateToURL(shell(), main_url);
5311 5196
5312 WebContentsImpl* web_contents = 5197 WebContentsImpl* web_contents = GetWebContents();
5313 static_cast<WebContentsImpl*>(shell()->web_contents());
5314 EXPECT_EQ(2U, web_contents->GetFrameTree()->root()->child_count()); 5198 EXPECT_EQ(2U, web_contents->GetFrameTree()->root()->child_count());
5315 5199
5316 // Capture the FrameTreeNode this test will be navigating. 5200 // Capture the FrameTreeNode this test will be navigating.
5317 FrameTreeNode* node = web_contents->GetFrameTree()->root()->child_at(0); 5201 FrameTreeNode* node = web_contents->GetFrameTree()->root()->child_at(0);
5318 EXPECT_TRUE(node); 5202 EXPECT_TRUE(node);
5319 EXPECT_NE(node->current_frame_host()->GetSiteInstance(), 5203 EXPECT_NE(node->current_frame_host()->GetSiteInstance(),
5320 node->parent()->current_frame_host()->GetSiteInstance()); 5204 node->parent()->current_frame_host()->GetSiteInstance());
5321 5205
5322 // Grab the routing id of the first child RenderFrameHost and set up a process 5206 // Grab the routing id of the first child RenderFrameHost and set up a process
5323 // observer to ensure there is no crash when a new RenderFrame creation is 5207 // observer to ensure there is no crash when a new RenderFrame creation is
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
5367 5251
5368 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, VisibilityChanged) { 5252 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, VisibilityChanged) {
5369 GURL main_url( 5253 GURL main_url(
5370 embedded_test_server()->GetURL("a.com", "/page_with_iframe.html")); 5254 embedded_test_server()->GetURL("a.com", "/page_with_iframe.html"));
5371 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 5255 EXPECT_TRUE(NavigateToURL(shell(), main_url));
5372 EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), main_url); 5256 EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), main_url);
5373 5257
5374 GURL cross_site_url = 5258 GURL cross_site_url =
5375 embedded_test_server()->GetURL("oopif.com", "/title1.html"); 5259 embedded_test_server()->GetURL("oopif.com", "/title1.html");
5376 5260
5377 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 5261 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
5378 ->GetFrameTree()
5379 ->root();
5380 5262
5381 TestNavigationObserver observer(shell()->web_contents()); 5263 TestNavigationObserver observer(shell()->web_contents());
5382 5264
5383 NavigateFrameToURL(root->child_at(0), cross_site_url); 5265 NavigateFrameToURL(root->child_at(0), cross_site_url);
5384 EXPECT_EQ(cross_site_url, observer.last_navigation_url()); 5266 EXPECT_EQ(cross_site_url, observer.last_navigation_url());
5385 EXPECT_TRUE(observer.last_navigation_succeeded()); 5267 EXPECT_TRUE(observer.last_navigation_succeeded());
5386 5268
5387 RenderWidgetHostImpl* render_widget_host = 5269 RenderWidgetHostImpl* render_widget_host =
5388 root->child_at(0)->current_frame_host()->GetRenderWidgetHost(); 5270 root->child_at(0)->current_frame_host()->GetRenderWidgetHost();
5389 EXPECT_FALSE(render_widget_host->is_hidden()); 5271 EXPECT_FALSE(render_widget_host->is_hidden());
(...skipping 17 matching lines...) Expand all
5407 } 5289 }
5408 5290
5409 // Verify that sandbox flags inheritance works across multiple levels of 5291 // Verify that sandbox flags inheritance works across multiple levels of
5410 // frames. See https://crbug.com/576845. 5292 // frames. See https://crbug.com/576845.
5411 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, SandboxFlagsInheritance) { 5293 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, SandboxFlagsInheritance) {
5412 GURL main_url(embedded_test_server()->GetURL( 5294 GURL main_url(embedded_test_server()->GetURL(
5413 "a.com", "/cross_site_iframe_factory.html?a(a)")); 5295 "a.com", "/cross_site_iframe_factory.html?a(a)"));
5414 NavigateToURL(shell(), main_url); 5296 NavigateToURL(shell(), main_url);
5415 5297
5416 // It is safe to obtain the root frame tree node here, as it doesn't change. 5298 // It is safe to obtain the root frame tree node here, as it doesn't change.
5417 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 5299 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
5418 ->GetFrameTree()
5419 ->root();
5420 5300
5421 // Set sandbox flags for child frame. 5301 // Set sandbox flags for child frame.
5422 EXPECT_TRUE(ExecuteScript( 5302 EXPECT_TRUE(ExecuteScript(
5423 root->current_frame_host(), 5303 root->current_frame_host(),
5424 "document.querySelector('iframe').sandbox = 'allow-scripts';")); 5304 "document.querySelector('iframe').sandbox = 'allow-scripts';"));
5425 5305
5426 // Calculate expected flags. Note that "allow-scripts" resets both 5306 // Calculate expected flags. Note that "allow-scripts" resets both
5427 // WebSandboxFlags::Scripts and WebSandboxFlags::AutomaticFeatures bits per 5307 // WebSandboxFlags::Scripts and WebSandboxFlags::AutomaticFeatures bits per
5428 // blink::parseSandboxPolicy(). 5308 // blink::parseSandboxPolicy().
5429 blink::WebSandboxFlags expected_flags = 5309 blink::WebSandboxFlags expected_flags =
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
5463 // a child frame, update its sandbox flags but don't navigate the frame, and 5343 // a child frame, update its sandbox flags but don't navigate the frame, and
5464 // ensure that a new cross-site grandchild frame doesn't inherit the new flags 5344 // ensure that a new cross-site grandchild frame doesn't inherit the new flags
5465 // (which shouldn't have taken effect). 5345 // (which shouldn't have taken effect).
5466 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 5346 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
5467 SandboxFlagsNotInheritedBeforeNavigation) { 5347 SandboxFlagsNotInheritedBeforeNavigation) {
5468 GURL main_url(embedded_test_server()->GetURL( 5348 GURL main_url(embedded_test_server()->GetURL(
5469 "a.com", "/cross_site_iframe_factory.html?a(a)")); 5349 "a.com", "/cross_site_iframe_factory.html?a(a)"));
5470 NavigateToURL(shell(), main_url); 5350 NavigateToURL(shell(), main_url);
5471 5351
5472 // It is safe to obtain the root frame tree node here, as it doesn't change. 5352 // It is safe to obtain the root frame tree node here, as it doesn't change.
5473 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 5353 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
5474 ->GetFrameTree()
5475 ->root();
5476 5354
5477 // Set sandbox flags for child frame. 5355 // Set sandbox flags for child frame.
5478 EXPECT_TRUE(ExecuteScript( 5356 EXPECT_TRUE(ExecuteScript(
5479 root->current_frame_host(), 5357 root->current_frame_host(),
5480 "document.querySelector('iframe').sandbox = 'allow-scripts';")); 5358 "document.querySelector('iframe').sandbox = 'allow-scripts';"));
5481 5359
5482 // These flags should be pending but not take effect, since there's been no 5360 // These flags should be pending but not take effect, since there's been no
5483 // navigation. 5361 // navigation.
5484 blink::WebSandboxFlags expected_flags = 5362 blink::WebSandboxFlags expected_flags =
5485 blink::WebSandboxFlags::All & ~blink::WebSandboxFlags::Scripts & 5363 blink::WebSandboxFlags::All & ~blink::WebSandboxFlags::Scripts &
(...skipping 29 matching lines...) Expand all
5515 // Verify that popups opened from sandboxed frames inherit sandbox flags from 5393 // Verify that popups opened from sandboxed frames inherit sandbox flags from
5516 // their opener, and that they keep these inherited flags after being navigated 5394 // their opener, and that they keep these inherited flags after being navigated
5517 // cross-site. See https://crbug.com/483584. 5395 // cross-site. See https://crbug.com/483584.
5518 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 5396 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
5519 NewPopupInheritsSandboxFlagsFromOpener) { 5397 NewPopupInheritsSandboxFlagsFromOpener) {
5520 GURL main_url(embedded_test_server()->GetURL( 5398 GURL main_url(embedded_test_server()->GetURL(
5521 "a.com", "/cross_site_iframe_factory.html?a(a)")); 5399 "a.com", "/cross_site_iframe_factory.html?a(a)"));
5522 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 5400 EXPECT_TRUE(NavigateToURL(shell(), main_url));
5523 5401
5524 // It is safe to obtain the root frame tree node here, as it doesn't change. 5402 // It is safe to obtain the root frame tree node here, as it doesn't change.
5525 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 5403 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
5526 ->GetFrameTree()
5527 ->root();
5528 5404
5529 // Set sandbox flags for child frame. 5405 // Set sandbox flags for child frame.
5530 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), 5406 EXPECT_TRUE(ExecuteScript(root->current_frame_host(),
5531 "document.querySelector('iframe').sandbox = " 5407 "document.querySelector('iframe').sandbox = "
5532 " 'allow-scripts allow-popups';")); 5408 " 'allow-scripts allow-popups';"));
5533 5409
5534 // Calculate expected flags. Note that "allow-scripts" resets both 5410 // Calculate expected flags. Note that "allow-scripts" resets both
5535 // WebSandboxFlags::Scripts and WebSandboxFlags::AutomaticFeatures bits per 5411 // WebSandboxFlags::Scripts and WebSandboxFlags::AutomaticFeatures bits per
5536 // blink::parseSandboxPolicy(). 5412 // blink::parseSandboxPolicy().
5537 blink::WebSandboxFlags expected_flags = 5413 blink::WebSandboxFlags expected_flags =
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
5586 // Verify that popups opened from frames sandboxed with the 5462 // Verify that popups opened from frames sandboxed with the
5587 // "allow-popups-to-escape-sandbox" directive do *not* inherit sandbox flags 5463 // "allow-popups-to-escape-sandbox" directive do *not* inherit sandbox flags
5588 // from their opener. 5464 // from their opener.
5589 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 5465 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
5590 OpenUnsandboxedPopupFromSandboxedFrame) { 5466 OpenUnsandboxedPopupFromSandboxedFrame) {
5591 GURL main_url(embedded_test_server()->GetURL( 5467 GURL main_url(embedded_test_server()->GetURL(
5592 "a.com", "/cross_site_iframe_factory.html?a(a)")); 5468 "a.com", "/cross_site_iframe_factory.html?a(a)"));
5593 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 5469 EXPECT_TRUE(NavigateToURL(shell(), main_url));
5594 5470
5595 // It is safe to obtain the root frame tree node here, as it doesn't change. 5471 // It is safe to obtain the root frame tree node here, as it doesn't change.
5596 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 5472 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
5597 ->GetFrameTree()
5598 ->root();
5599 5473
5600 // Set sandbox flags for child frame, specifying that popups opened from it 5474 // Set sandbox flags for child frame, specifying that popups opened from it
5601 // should not be sandboxed. 5475 // should not be sandboxed.
5602 EXPECT_TRUE(ExecuteScript( 5476 EXPECT_TRUE(ExecuteScript(
5603 root->current_frame_host(), 5477 root->current_frame_host(),
5604 "document.querySelector('iframe').sandbox = " 5478 "document.querySelector('iframe').sandbox = "
5605 " 'allow-scripts allow-popups allow-popups-to-escape-sandbox';")); 5479 " 'allow-scripts allow-popups allow-popups-to-escape-sandbox';"));
5606 5480
5607 // Set expected flags for the child frame. Note that "allow-scripts" resets 5481 // Set expected flags for the child frame. Note that "allow-scripts" resets
5608 // both WebSandboxFlags::Scripts and WebSandboxFlags::AutomaticFeatures bits 5482 // both WebSandboxFlags::Scripts and WebSandboxFlags::AutomaticFeatures bits
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
5657 SetupCrossSiteRedirector(&https_server); 5531 SetupCrossSiteRedirector(&https_server);
5658 5532
5659 GURL iframe_url( 5533 GURL iframe_url(
5660 https_server.GetURL("/mixed-content/basic-passive-in-iframe.html")); 5534 https_server.GetURL("/mixed-content/basic-passive-in-iframe.html"));
5661 EXPECT_TRUE(NavigateToURL(shell(), iframe_url)); 5535 EXPECT_TRUE(NavigateToURL(shell(), iframe_url));
5662 EXPECT_TRUE(shell()->web_contents()->DisplayedInsecureContent()); 5536 EXPECT_TRUE(shell()->web_contents()->DisplayedInsecureContent());
5663 5537
5664 // When the subframe navigates, the WebContents should still be marked 5538 // When the subframe navigates, the WebContents should still be marked
5665 // as having displayed insecure content. 5539 // as having displayed insecure content.
5666 GURL navigate_url(https_server.GetURL("/title1.html")); 5540 GURL navigate_url(https_server.GetURL("/title1.html"));
5667 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 5541 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
5668 ->GetFrameTree()
5669 ->root();
5670 NavigateFrameToURL(root->child_at(0), navigate_url); 5542 NavigateFrameToURL(root->child_at(0), navigate_url);
5671 EXPECT_TRUE(shell()->web_contents()->DisplayedInsecureContent()); 5543 EXPECT_TRUE(shell()->web_contents()->DisplayedInsecureContent());
5672 5544
5673 // When the main frame navigates, it should no longer be marked as 5545 // When the main frame navigates, it should no longer be marked as
5674 // displaying insecure content. 5546 // displaying insecure content.
5675 EXPECT_TRUE( 5547 EXPECT_TRUE(
5676 NavigateToURL(shell(), https_server.GetURL("b.com", "/title1.html"))); 5548 NavigateToURL(shell(), https_server.GetURL("b.com", "/title1.html")));
5677 EXPECT_FALSE(shell()->web_contents()->DisplayedInsecureContent()); 5549 EXPECT_FALSE(shell()->web_contents()->DisplayedInsecureContent());
5678 } 5550 }
5679 5551
5680 // Tests that, when a parent frame is set to strictly block mixed 5552 // Tests that, when a parent frame is set to strictly block mixed
5681 // content via Content Security Policy, child OOPIFs cannot display 5553 // content via Content Security Policy, child OOPIFs cannot display
5682 // mixed content. 5554 // mixed content.
5683 IN_PROC_BROWSER_TEST_F(SitePerProcessIgnoreCertErrorsBrowserTest, 5555 IN_PROC_BROWSER_TEST_F(SitePerProcessIgnoreCertErrorsBrowserTest,
5684 PassiveMixedContentInIframeWithStrictBlocking) { 5556 PassiveMixedContentInIframeWithStrictBlocking) {
5685 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); 5557 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS);
5686 https_server.ServeFilesFromSourceDirectory("content/test/data"); 5558 https_server.ServeFilesFromSourceDirectory("content/test/data");
5687 ASSERT_TRUE(https_server.Start()); 5559 ASSERT_TRUE(https_server.Start());
5688 SetupCrossSiteRedirector(&https_server); 5560 SetupCrossSiteRedirector(&https_server);
5689 5561
5690 GURL iframe_url_with_strict_blocking(https_server.GetURL( 5562 GURL iframe_url_with_strict_blocking(https_server.GetURL(
5691 "/mixed-content/basic-passive-in-iframe-with-strict-blocking.html")); 5563 "/mixed-content/basic-passive-in-iframe-with-strict-blocking.html"));
5692 EXPECT_TRUE(NavigateToURL(shell(), iframe_url_with_strict_blocking)); 5564 EXPECT_TRUE(NavigateToURL(shell(), iframe_url_with_strict_blocking));
5693 EXPECT_FALSE(shell()->web_contents()->DisplayedInsecureContent()); 5565 EXPECT_FALSE(shell()->web_contents()->DisplayedInsecureContent());
5694 5566
5695 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 5567 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
5696 ->GetFrameTree()
5697 ->root();
5698 EXPECT_TRUE(root->current_replication_state() 5568 EXPECT_TRUE(root->current_replication_state()
5699 .should_enforce_strict_mixed_content_checking); 5569 .should_enforce_strict_mixed_content_checking);
5700 EXPECT_TRUE(root->child_at(0) 5570 EXPECT_TRUE(root->child_at(0)
5701 ->current_replication_state() 5571 ->current_replication_state()
5702 .should_enforce_strict_mixed_content_checking); 5572 .should_enforce_strict_mixed_content_checking);
5703 5573
5704 // When the subframe navigates, it should still be marked as enforcing 5574 // When the subframe navigates, it should still be marked as enforcing
5705 // strict mixed content. 5575 // strict mixed content.
5706 GURL navigate_url(https_server.GetURL("/title1.html")); 5576 GURL navigate_url(https_server.GetURL("/title1.html"));
5707 NavigateFrameToURL(root->child_at(0), navigate_url); 5577 NavigateFrameToURL(root->child_at(0), navigate_url);
(...skipping 18 matching lines...) Expand all
5726 IN_PROC_BROWSER_TEST_F(SitePerProcessIgnoreCertErrorsBrowserTest, 5596 IN_PROC_BROWSER_TEST_F(SitePerProcessIgnoreCertErrorsBrowserTest,
5727 ActiveMixedContentInIframe) { 5597 ActiveMixedContentInIframe) {
5728 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); 5598 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS);
5729 https_server.ServeFilesFromSourceDirectory("content/test/data"); 5599 https_server.ServeFilesFromSourceDirectory("content/test/data");
5730 ASSERT_TRUE(https_server.Start()); 5600 ASSERT_TRUE(https_server.Start());
5731 SetupCrossSiteRedirector(&https_server); 5601 SetupCrossSiteRedirector(&https_server);
5732 5602
5733 GURL iframe_url( 5603 GURL iframe_url(
5734 https_server.GetURL("/mixed-content/basic-active-in-iframe.html")); 5604 https_server.GetURL("/mixed-content/basic-active-in-iframe.html"));
5735 EXPECT_TRUE(NavigateToURL(shell(), iframe_url)); 5605 EXPECT_TRUE(NavigateToURL(shell(), iframe_url));
5736 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 5606 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
5737 ->GetFrameTree()
5738 ->root();
5739 ASSERT_EQ(1U, root->child_count()); 5607 ASSERT_EQ(1U, root->child_count());
5740 FrameTreeNode* mixed_child = root->child_at(0)->child_at(0); 5608 FrameTreeNode* mixed_child = root->child_at(0)->child_at(0);
5741 ASSERT_TRUE(mixed_child); 5609 ASSERT_TRUE(mixed_child);
5742 // The child iframe attempted to create a mixed iframe; this should 5610 // The child iframe attempted to create a mixed iframe; this should
5743 // have been blocked, so the mixed iframe should not have committed a 5611 // have been blocked, so the mixed iframe should not have committed a
5744 // load. 5612 // load.
5745 EXPECT_FALSE(mixed_child->has_committed_real_load()); 5613 EXPECT_FALSE(mixed_child->has_committed_real_load());
5746 } 5614 }
5747 5615
5748 // Test setting a cross-origin iframe to display: none. 5616 // Test setting a cross-origin iframe to display: none.
5749 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframeDisplayNone) { 5617 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframeDisplayNone) {
5750 GURL main_url(embedded_test_server()->GetURL( 5618 GURL main_url(embedded_test_server()->GetURL(
5751 "a.com", "/cross_site_iframe_factory.html?a(b)")); 5619 "a.com", "/cross_site_iframe_factory.html?a(b)"));
5752 NavigateToURL(shell(), main_url); 5620 NavigateToURL(shell(), main_url);
5753 5621
5754 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 5622 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
5755 ->GetFrameTree()
5756 ->root();
5757 RenderWidgetHost* root_render_widget_host = 5623 RenderWidgetHost* root_render_widget_host =
5758 root->current_frame_host()->GetRenderWidgetHost(); 5624 root->current_frame_host()->GetRenderWidgetHost();
5759 5625
5760 // Set the iframe to display: none. 5626 // Set the iframe to display: none.
5761 EXPECT_TRUE( 5627 EXPECT_TRUE(
5762 ExecuteScript(shell()->web_contents(), 5628 ExecuteScript(shell()->web_contents(),
5763 "document.querySelector('iframe').style.display = 'none'")); 5629 "document.querySelector('iframe').style.display = 'none'"));
5764 5630
5765 // Waits until pending frames are done. 5631 // Waits until pending frames are done.
5766 scoped_ptr<MainThreadFrameObserver> observer( 5632 scoped_ptr<MainThreadFrameObserver> observer(
5767 new MainThreadFrameObserver(root_render_widget_host)); 5633 new MainThreadFrameObserver(root_render_widget_host));
5768 observer->Wait(); 5634 observer->Wait();
5769 5635
5770 // Force the renderer to generate a new frame. 5636 // Force the renderer to generate a new frame.
5771 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), 5637 EXPECT_TRUE(ExecuteScript(shell()->web_contents(),
5772 "document.body.style.background = 'black'")); 5638 "document.body.style.background = 'black'"));
5773 5639
5774 // Waits for the next frame. 5640 // Waits for the next frame.
5775 observer->Wait(); 5641 observer->Wait();
5776 } 5642 }
5777 5643
5644 // This class will sniff incoming IPC for ViewHostMsg_TextInputStateChanged.
5645 class TextInputStateChangedMessageFilter : public BrowserMessageFilter {
5646 public:
5647 explicit TextInputStateChangedMessageFilter(
5648 RenderWidgetHostImpl* render_widget_host)
5649 : BrowserMessageFilter(ViewMsgStart), text_input_state_changed_(false) {
5650 if (!render_widget_host || !render_widget_host->GetProcess())
5651 text_input_state_changed_ = true;
5652 old_state = *render_widget_host->GetView()->text_input_state();
5653 render_widget_host->GetProcess()->AddFilter(this);
5654 }
5655
5656 void WaitUntilTextInputStateChanges() {
5657 if (!text_input_state_changed_) {
5658 message_loop_runner_ = new MessageLoopRunner;
5659 message_loop_runner_->Run();
5660 }
5661 }
5662
5663 private:
5664 ~TextInputStateChangedMessageFilter() override {}
5665
5666 bool OnMessageReceived(const IPC::Message& msg) override {
5667 IPC_BEGIN_MESSAGE_MAP(TextInputStateChangedMessageFilter, msg)
5668 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged,
5669 OnTextInputStateChangedMessageReceived)
5670 IPC_END_MESSAGE_MAP()
5671 return false;
5672 }
5673
5674 void OnTextInputStateChangedMessageReceived(const TextInputState& new_state) {
5675 if (new_state.type != old_state.type || new_state.mode != old_state.mode ||
5676 new_state.value != old_state.value) {
5677 text_input_state_changed_ = true;
5678 if (message_loop_runner_)
5679 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
5680 message_loop_runner_->QuitClosure());
5681 }
5682 }
5683
5684 bool text_input_state_changed_;
5685 scoped_refptr<MessageLoopRunner> message_loop_runner_;
5686 TextInputState old_state;
5687
5688 DISALLOW_COPY_AND_ASSIGN(TextInputStateChangedMessageFilter);
5689 };
5690
5691 // Verify that when moving the focus between different frames, the WebContents
5692 // properly keeps track of the text input state.
5693 // The test loads a page with one input field, two out of process frames, and a
5694 // second input field positioned after the last <iframe>. Then a sequence of TAB
5695 // inputs are faked to navigate focus in between the different <input> elements.
5696 // After each change, we check with the RWHV of the frame as well as the
5697 // WebContents to make sure the text input state is as expected.
5698 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, TextInputStateChanged) {
5699 GURL main_page_url(embedded_test_server()->GetURL(
5700 "a.com", "/textinput/page_with_input_iframeX2_input.html"));
5701 NavigateToURL(shell(), main_page_url);
5702
5703 WebContents* contents = shell()->web_contents();
5704
5705 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
5706
5707 FrameTreeNode* child_b = root->child_at(0);
5708 GURL child_b_url(embedded_test_server()->GetURL(
5709 "b.com", "/textinput/page_with_input.html"));
5710 NavigateFrameToURL(child_b, child_b_url);
5711 EXPECT_TRUE(WaitForRenderFrameReady(child_b->current_frame_host()));
5712
5713 FrameTreeNode* child_c = root->child_at(1);
5714 GURL child_c_url(embedded_test_server()->GetURL(
5715 "c.com", "/textinput/page_with_input.html"));
5716 NavigateFrameToURL(child_c, child_c_url);
5717 EXPECT_TRUE(WaitForRenderFrameReady(child_c->current_frame_host()));
5718
5719 RenderWidgetHostImpl* root_rwh =
5720 root->current_frame_host()->GetRenderWidgetHost();
5721 RenderWidgetHostViewBase* root_rwhv = root_rwh->GetView();
5722
5723 RenderWidgetHostImpl* child_b_rwh =
5724 child_b->current_frame_host()->GetRenderWidgetHost();
5725 RenderWidgetHostViewBase* child_b_rwhv = child_b_rwh->GetView();
5726
5727 RenderWidgetHostImpl* child_c_rwh =
5728 child_c->current_frame_host()->GetRenderWidgetHost();
5729 RenderWidgetHostViewBase* child_c_rwhv = child_c_rwh->GetView();
5730
5731 // Change the text value in <input> field of either frame so that we can
5732 // later track the changes.
5733 EXPECT_TRUE(
5734 ExecuteScript(child_b->current_frame_host(),
5735 "document.querySelector('input').value = 'second';"));
5736 EXPECT_TRUE(
5737 ExecuteScript(child_c->current_frame_host(),
5738 "document.querySelector('input').value = 'third';"));
5739
5740 // Verfy the input type is none in the begning.
5741 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, root_rwhv->text_input_state()->type);
5742
5743 // A helper function to send a tab key to the frame and wait for a state
5744 // changed message.
5745 auto press_tab_and_wait_for_text_input_state_change =
5746 [contents](RenderWidgetHostImpl* rwh) {
5747 scoped_refptr<TextInputStateChangedMessageFilter> filter =
5748 new TextInputStateChangedMessageFilter(rwh);
5749 SimulateKeyPress(contents, ui::VKEY_TAB, false, false, false, false);
5750 filter->WaitUntilTextInputStateChanges();
5751 };
5752
5753 // Send focus to the first input field
5754 press_tab_and_wait_for_text_input_state_change(root_rwh);
5755 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, root_rwhv->text_input_state()->type);
5756 EXPECT_EQ("first", root_rwhv->text_input_state()->value);
5757
5758 // Verify the top-level state is changed.
5759 EXPECT_EQ("first", GetWebContents()->GetTextInputState().value);
5760
5761 // Send focus to the input field in frame b.
5762 press_tab_and_wait_for_text_input_state_change(child_b_rwh);
5763 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, child_b_rwhv->text_input_state()->type);
5764 EXPECT_EQ("second", child_b_rwhv->text_input_state()->value);
5765
5766 EXPECT_EQ("second", GetWebContents()->GetTextInputState().value);
5767
5768 // Send focus to the input field in frame c.
5769 press_tab_and_wait_for_text_input_state_change(child_c_rwh);
5770 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, child_c_rwhv->text_input_state()->type);
5771 EXPECT_EQ("third", child_c_rwhv->text_input_state()->value);
5772
5773 EXPECT_EQ("third", GetWebContents()->GetTextInputState().value);
5774
5775 // Send focus to the last input field in top frame.
5776 press_tab_and_wait_for_text_input_state_change(root_rwh);
5777 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, root_rwhv->text_input_state()->type);
5778 EXPECT_EQ("fourth", root_rwhv->text_input_state()->value);
5779
5780 EXPECT_EQ("fourth", GetWebContents()->GetTextInputState().value);
5781 }
5782
5778 // Test that a cross-origin iframe can be blocked by X-Frame-Options and CSP 5783 // Test that a cross-origin iframe can be blocked by X-Frame-Options and CSP
5779 // frame-ancestors. 5784 // frame-ancestors.
5780 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 5785 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
5781 CrossSiteIframeBlockedByXFrameOptionsOrCSP) { 5786 CrossSiteIframeBlockedByXFrameOptionsOrCSP) {
5782 GURL main_url(embedded_test_server()->GetURL( 5787 GURL main_url(embedded_test_server()->GetURL(
5783 "a.com", "/cross_site_iframe_factory.html?a(a)")); 5788 "a.com", "/cross_site_iframe_factory.html?a(a)"));
5784 NavigateToURL(shell(), main_url); 5789 NavigateToURL(shell(), main_url);
5785 5790
5786 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 5791 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
5787 ->GetFrameTree()
5788 ->root();
5789 5792
5790 // Add a load event handler for the iframe element. 5793 // Add a load event handler for the iframe element.
5791 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), 5794 EXPECT_TRUE(ExecuteScript(shell()->web_contents(),
5792 "document.querySelector('iframe').onload = " 5795 "document.querySelector('iframe').onload = "
5793 " function() { document.title = 'loaded'; };")); 5796 " function() { document.title = 'loaded'; };"));
5794 5797
5795 GURL blocked_urls[] = { 5798 GURL blocked_urls[] = {
5796 embedded_test_server()->GetURL("b.com", "/frame-ancestors-none.html"), 5799 embedded_test_server()->GetURL("b.com", "/frame-ancestors-none.html"),
5797 embedded_test_server()->GetURL("b.com", "/x-frame-options-deny.html") 5800 embedded_test_server()->GetURL("b.com", "/x-frame-options-deny.html")
5798 }; 5801 };
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
5846 EXPECT_EQ(blink::WebSandboxFlags::None, 5849 EXPECT_EQ(blink::WebSandboxFlags::None,
5847 root->child_at(0)->effective_sandbox_flags()); 5850 root->child_at(0)->effective_sandbox_flags());
5848 } 5851 }
5849 } 5852 }
5850 5853
5851 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ScreenCoordinates) { 5854 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ScreenCoordinates) {
5852 GURL main_url(embedded_test_server()->GetURL( 5855 GURL main_url(embedded_test_server()->GetURL(
5853 "a.com", "/cross_site_iframe_factory.html?a(b)")); 5856 "a.com", "/cross_site_iframe_factory.html?a(b)"));
5854 NavigateToURL(shell(), main_url); 5857 NavigateToURL(shell(), main_url);
5855 5858
5856 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 5859 FrameTreeNode* root = GetWebContents()->GetFrameTree()->root();
5857 ->GetFrameTree()
5858 ->root();
5859 FrameTreeNode* child = root->child_at(0); 5860 FrameTreeNode* child = root->child_at(0);
5860 5861
5861 const char* properties[] = {"screenX", "screenY", "outerWidth", 5862 const char* properties[] = {"screenX", "screenY", "outerWidth",
5862 "outerHeight"}; 5863 "outerHeight"};
5863 5864
5864 for (const char* property : properties) { 5865 for (const char* property : properties) {
5865 std::string script = "window.domAutomationController.send(window."; 5866 std::string script = "window.domAutomationController.send(window.";
5866 script += property; 5867 script += property;
5867 script += ");"; 5868 script += ");";
5868 int root_value = 1; 5869 int root_value = 1;
5869 int child_value = 2; 5870 int child_value = 2;
5870 EXPECT_TRUE(ExecuteScriptAndExtractInt(root->current_frame_host(), 5871 EXPECT_TRUE(ExecuteScriptAndExtractInt(root->current_frame_host(),
5871 script.c_str(), &root_value)); 5872 script.c_str(), &root_value));
5872 5873
5873 EXPECT_TRUE(ExecuteScriptAndExtractInt(child->current_frame_host(), 5874 EXPECT_TRUE(ExecuteScriptAndExtractInt(child->current_frame_host(),
5874 script.c_str(), &child_value)); 5875 script.c_str(), &child_value));
5875 5876
5876 EXPECT_EQ(root_value, child_value); 5877 EXPECT_EQ(root_value, child_value);
5877 } 5878 }
5878 } 5879 }
5879 5880
5880 } // namespace content 5881 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698