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