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 13 matching lines...) Expand all Loading... |
24 #include "content/browser/frame_host/frame_tree.h" | 24 #include "content/browser/frame_host/frame_tree.h" |
25 #include "content/browser/frame_host/navigator.h" | 25 #include "content/browser/frame_host/navigator.h" |
26 #include "content/browser/frame_host/render_frame_proxy_host.h" | 26 #include "content/browser/frame_host/render_frame_proxy_host.h" |
27 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" | 27 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" |
28 #include "content/browser/gpu/compositor_util.h" | 28 #include "content/browser/gpu/compositor_util.h" |
29 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 29 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
30 #include "content/browser/renderer_host/input/synthetic_tap_gesture.h" | 30 #include "content/browser/renderer_host/input/synthetic_tap_gesture.h" |
31 #include "content/browser/renderer_host/render_view_host_impl.h" | 31 #include "content/browser/renderer_host/render_view_host_impl.h" |
32 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" | 32 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" |
33 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 33 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
34 #include "content/browser/web_contents/web_contents_impl.h" | |
35 #include "content/common/frame_messages.h" | 34 #include "content/common/frame_messages.h" |
36 #include "content/common/input/synthetic_tap_gesture_params.h" | 35 #include "content/common/input/synthetic_tap_gesture_params.h" |
37 #include "content/common/view_messages.h" | 36 #include "content/common/view_messages.h" |
38 #include "content/public/browser/cert_store.h" | 37 #include "content/public/browser/cert_store.h" |
39 #include "content/public/browser/notification_observer.h" | 38 #include "content/public/browser/notification_observer.h" |
40 #include "content/public/browser/notification_service.h" | 39 #include "content/public/browser/notification_service.h" |
41 #include "content/public/browser/notification_types.h" | 40 #include "content/public/browser/notification_types.h" |
42 #include "content/public/browser/resource_dispatcher_host.h" | 41 #include "content/public/browser/resource_dispatcher_host.h" |
43 #include "content/public/common/browser_side_navigation_policy.h" | 42 #include "content/public/common/browser_side_navigation_policy.h" |
44 #include "content/public/common/content_switches.h" | 43 #include "content/public/common/content_switches.h" |
45 #include "content/public/common/url_constants.h" | 44 #include "content/public/common/url_constants.h" |
46 #include "content/public/test/browser_test_utils.h" | 45 #include "content/public/test/browser_test_utils.h" |
47 #include "content/public/test/content_browser_test_utils.h" | 46 #include "content/public/test/content_browser_test_utils.h" |
48 #include "content/public/test/test_navigation_observer.h" | 47 #include "content/public/test/test_navigation_observer.h" |
49 #include "content/public/test/test_utils.h" | 48 #include "content/public/test/test_utils.h" |
50 #include "content/shell/browser/shell.h" | |
51 #include "content/test/content_browser_test_utils_internal.h" | 49 #include "content/test/content_browser_test_utils_internal.h" |
52 #include "content/test/test_frame_navigation_observer.h" | 50 #include "content/test/test_frame_navigation_observer.h" |
53 #include "ipc/ipc_security_test_util.h" | 51 #include "ipc/ipc_security_test_util.h" |
54 #include "net/dns/mock_host_resolver.h" | 52 #include "net/dns/mock_host_resolver.h" |
55 #include "net/test/embedded_test_server/embedded_test_server.h" | 53 #include "net/test/embedded_test_server/embedded_test_server.h" |
56 #include "third_party/WebKit/public/web/WebInputEvent.h" | 54 #include "third_party/WebKit/public/web/WebInputEvent.h" |
57 #include "third_party/WebKit/public/web/WebSandboxFlags.h" | 55 #include "third_party/WebKit/public/web/WebSandboxFlags.h" |
58 #include "ui/events/event.h" | 56 #include "ui/events/event.h" |
59 #include "ui/events/event_utils.h" | 57 #include "ui/events/event_utils.h" |
60 #include "ui/gfx/geometry/point.h" | 58 #include "ui/gfx/geometry/point.h" |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 }; | 623 }; |
626 | 624 |
627 // Ensure that navigating subframes in --site-per-process mode works and the | 625 // Ensure that navigating subframes in --site-per-process mode works and the |
628 // correct documents are committed. | 626 // correct documents are committed. |
629 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) { | 627 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframe) { |
630 GURL main_url(embedded_test_server()->GetURL( | 628 GURL main_url(embedded_test_server()->GetURL( |
631 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))")); | 629 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))")); |
632 NavigateToURL(shell(), main_url); | 630 NavigateToURL(shell(), main_url); |
633 | 631 |
634 // It is safe to obtain the root frame tree node here, as it doesn't change. | 632 // It is safe to obtain the root frame tree node here, as it doesn't change. |
635 FrameTreeNode* root = | 633 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
636 static_cast<WebContentsImpl*>(shell()->web_contents())-> | |
637 GetFrameTree()->root(); | |
638 | 634 |
639 TestNavigationObserver observer(shell()->web_contents()); | 635 TestNavigationObserver observer(shell()->web_contents()); |
640 | 636 |
641 // Load same-site page into iframe. | 637 // Load same-site page into iframe. |
642 FrameTreeNode* child = root->child_at(0); | 638 FrameTreeNode* child = root->child_at(0); |
643 GURL http_url(embedded_test_server()->GetURL("a.com", "/title1.html")); | 639 GURL http_url(embedded_test_server()->GetURL("a.com", "/title1.html")); |
644 NavigateFrameToURL(child, http_url); | 640 NavigateFrameToURL(child, http_url); |
645 EXPECT_EQ(http_url, observer.last_navigation_url()); | 641 EXPECT_EQ(http_url, observer.last_navigation_url()); |
646 EXPECT_TRUE(observer.last_navigation_succeeded()); | 642 EXPECT_TRUE(observer.last_navigation_succeeded()); |
647 { | 643 { |
648 // There should be only one RenderWidgetHost when there are no | 644 // There should be only one RenderWidgetHost when there are no |
649 // cross-process iframes. | 645 // cross-process iframes. |
650 std::set<RenderWidgetHostView*> views_set = | 646 std::set<RenderWidgetHostView*> views_set = |
651 static_cast<WebContentsImpl*>(shell()->web_contents()) | 647 web_contents()->GetRenderWidgetHostViewsInTree(); |
652 ->GetRenderWidgetHostViewsInTree(); | |
653 EXPECT_EQ(1U, views_set.size()); | 648 EXPECT_EQ(1U, views_set.size()); |
654 } | 649 } |
655 | 650 |
656 EXPECT_EQ( | 651 EXPECT_EQ( |
657 " Site A\n" | 652 " Site A\n" |
658 " |--Site A\n" | 653 " |--Site A\n" |
659 " +--Site A\n" | 654 " +--Site A\n" |
660 " |--Site A\n" | 655 " |--Site A\n" |
661 " +--Site A\n" | 656 " +--Site A\n" |
662 " +--Site A\n" | 657 " +--Site A\n" |
(...skipping 12 matching lines...) Expand all Loading... |
675 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance(); | 670 SiteInstance* site_instance = child->current_frame_host()->GetSiteInstance(); |
676 RenderViewHost* rvh = child->current_frame_host()->render_view_host(); | 671 RenderViewHost* rvh = child->current_frame_host()->render_view_host(); |
677 RenderProcessHost* rph = child->current_frame_host()->GetProcess(); | 672 RenderProcessHost* rph = child->current_frame_host()->GetProcess(); |
678 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), rvh); | 673 EXPECT_NE(shell()->web_contents()->GetRenderViewHost(), rvh); |
679 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance); | 674 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), site_instance); |
680 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), rph); | 675 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), rph); |
681 { | 676 { |
682 // There should be now two RenderWidgetHosts, one for each process | 677 // There should be now two RenderWidgetHosts, one for each process |
683 // rendering a frame. | 678 // rendering a frame. |
684 std::set<RenderWidgetHostView*> views_set = | 679 std::set<RenderWidgetHostView*> views_set = |
685 static_cast<WebContentsImpl*>(shell()->web_contents()) | 680 web_contents()->GetRenderWidgetHostViewsInTree(); |
686 ->GetRenderWidgetHostViewsInTree(); | |
687 EXPECT_EQ(2U, views_set.size()); | 681 EXPECT_EQ(2U, views_set.size()); |
688 } | 682 } |
689 RenderFrameProxyHost* proxy_to_parent = | 683 RenderFrameProxyHost* proxy_to_parent = |
690 child->render_manager()->GetProxyToParent(); | 684 child->render_manager()->GetProxyToParent(); |
691 EXPECT_TRUE(proxy_to_parent); | 685 EXPECT_TRUE(proxy_to_parent); |
692 EXPECT_TRUE(proxy_to_parent->cross_process_frame_connector()); | 686 EXPECT_TRUE(proxy_to_parent->cross_process_frame_connector()); |
693 // The out-of-process iframe should have its own RenderWidgetHost, | 687 // The out-of-process iframe should have its own RenderWidgetHost, |
694 // independent of any RenderViewHost. | 688 // independent of any RenderViewHost. |
695 EXPECT_NE( | 689 EXPECT_NE( |
696 rvh->GetWidget()->GetView(), | 690 rvh->GetWidget()->GetView(), |
(...skipping 26 matching lines...) Expand all Loading... |
723 EXPECT_NE(rvh, child->current_frame_host()->render_view_host()); | 717 EXPECT_NE(rvh, child->current_frame_host()->render_view_host()); |
724 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 718 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
725 child->current_frame_host()->GetSiteInstance()); | 719 child->current_frame_host()->GetSiteInstance()); |
726 EXPECT_NE(site_instance, | 720 EXPECT_NE(site_instance, |
727 child->current_frame_host()->GetSiteInstance()); | 721 child->current_frame_host()->GetSiteInstance()); |
728 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), | 722 EXPECT_NE(shell()->web_contents()->GetRenderProcessHost(), |
729 child->current_frame_host()->GetProcess()); | 723 child->current_frame_host()->GetProcess()); |
730 EXPECT_NE(rph, child->current_frame_host()->GetProcess()); | 724 EXPECT_NE(rph, child->current_frame_host()->GetProcess()); |
731 { | 725 { |
732 std::set<RenderWidgetHostView*> views_set = | 726 std::set<RenderWidgetHostView*> views_set = |
733 static_cast<WebContentsImpl*>(shell()->web_contents()) | 727 web_contents()->GetRenderWidgetHostViewsInTree(); |
734 ->GetRenderWidgetHostViewsInTree(); | |
735 EXPECT_EQ(2U, views_set.size()); | 728 EXPECT_EQ(2U, views_set.size()); |
736 } | 729 } |
737 EXPECT_EQ(proxy_to_parent, child->render_manager()->GetProxyToParent()); | 730 EXPECT_EQ(proxy_to_parent, child->render_manager()->GetProxyToParent()); |
738 EXPECT_TRUE(proxy_to_parent->cross_process_frame_connector()); | 731 EXPECT_TRUE(proxy_to_parent->cross_process_frame_connector()); |
739 EXPECT_NE( | 732 EXPECT_NE( |
740 child->current_frame_host()->render_view_host()->GetWidget()->GetView(), | 733 child->current_frame_host()->render_view_host()->GetWidget()->GetView(), |
741 proxy_to_parent->cross_process_frame_connector()->get_view_for_testing()); | 734 proxy_to_parent->cross_process_frame_connector()->get_view_for_testing()); |
742 EXPECT_TRUE(child->current_frame_host()->GetRenderWidgetHost()); | 735 EXPECT_TRUE(child->current_frame_host()->GetRenderWidgetHost()); |
743 | 736 |
744 EXPECT_EQ( | 737 EXPECT_EQ( |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 #else | 784 #else |
792 #define MAYBE_NestedSurfaceHitTestTest NestedSurfaceHitTestTest | 785 #define MAYBE_NestedSurfaceHitTestTest NestedSurfaceHitTestTest |
793 #endif | 786 #endif |
794 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 787 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
795 MAYBE_NestedSurfaceHitTestTest) { | 788 MAYBE_NestedSurfaceHitTestTest) { |
796 GURL main_url(embedded_test_server()->GetURL( | 789 GURL main_url(embedded_test_server()->GetURL( |
797 "/frame_tree/page_with_positioned_nested_frames.html")); | 790 "/frame_tree/page_with_positioned_nested_frames.html")); |
798 NavigateToURL(shell(), main_url); | 791 NavigateToURL(shell(), main_url); |
799 | 792 |
800 // It is safe to obtain the root frame tree node here, as it doesn't change. | 793 // It is safe to obtain the root frame tree node here, as it doesn't change. |
801 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 794 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
802 ->GetFrameTree() | |
803 ->root(); | |
804 ASSERT_EQ(1U, root->child_count()); | 795 ASSERT_EQ(1U, root->child_count()); |
805 | 796 |
806 FrameTreeNode* parent_iframe_node = root->child_at(0); | 797 FrameTreeNode* parent_iframe_node = root->child_at(0); |
807 GURL site_url(embedded_test_server()->GetURL( | 798 GURL site_url(embedded_test_server()->GetURL( |
808 "a.com", "/frame_tree/page_with_positioned_frame.html")); | 799 "a.com", "/frame_tree/page_with_positioned_frame.html")); |
809 EXPECT_EQ(site_url, parent_iframe_node->current_url()); | 800 EXPECT_EQ(site_url, parent_iframe_node->current_url()); |
810 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 801 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
811 parent_iframe_node->current_frame_host()->GetSiteInstance()); | 802 parent_iframe_node->current_frame_host()->GetSiteInstance()); |
812 | 803 |
813 FrameTreeNode* nested_iframe_node = parent_iframe_node->child_at(0); | 804 FrameTreeNode* nested_iframe_node = parent_iframe_node->child_at(0); |
814 GURL nested_site_url( | 805 GURL nested_site_url( |
815 embedded_test_server()->GetURL("baz.com", "/title1.html")); | 806 embedded_test_server()->GetURL("baz.com", "/title1.html")); |
816 EXPECT_EQ(nested_site_url, nested_iframe_node->current_url()); | 807 EXPECT_EQ(nested_site_url, nested_iframe_node->current_url()); |
817 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 808 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
818 nested_iframe_node->current_frame_host()->GetSiteInstance()); | 809 nested_iframe_node->current_frame_host()->GetSiteInstance()); |
819 EXPECT_NE(parent_iframe_node->current_frame_host()->GetSiteInstance(), | 810 EXPECT_NE(parent_iframe_node->current_frame_host()->GetSiteInstance(), |
820 nested_iframe_node->current_frame_host()->GetSiteInstance()); | 811 nested_iframe_node->current_frame_host()->GetSiteInstance()); |
821 | 812 |
822 // Create listeners for mouse events. | 813 // Create listeners for mouse events. |
823 RenderWidgetHostMouseEventMonitor main_frame_monitor( | 814 RenderWidgetHostMouseEventMonitor main_frame_monitor( |
824 root->current_frame_host()->GetRenderWidgetHost()); | 815 root->current_frame_host()->GetRenderWidgetHost()); |
825 RenderWidgetHostMouseEventMonitor nested_frame_monitor( | 816 RenderWidgetHostMouseEventMonitor nested_frame_monitor( |
826 nested_iframe_node->current_frame_host()->GetRenderWidgetHost()); | 817 nested_iframe_node->current_frame_host()->GetRenderWidgetHost()); |
827 | 818 |
828 RenderWidgetHostInputEventRouter* router = | 819 RenderWidgetHostInputEventRouter* router = |
829 static_cast<WebContentsImpl*>(shell()->web_contents()) | 820 web_contents()->GetInputEventRouter(); |
830 ->GetInputEventRouter(); | |
831 | 821 |
832 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( | 822 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( |
833 root->current_frame_host()->GetRenderWidgetHost()->GetView()); | 823 root->current_frame_host()->GetRenderWidgetHost()->GetView()); |
834 RenderWidgetHostViewBase* rwhv_nested = | 824 RenderWidgetHostViewBase* rwhv_nested = |
835 static_cast<RenderWidgetHostViewBase*>( | 825 static_cast<RenderWidgetHostViewBase*>( |
836 nested_iframe_node->current_frame_host() | 826 nested_iframe_node->current_frame_host() |
837 ->GetRenderWidgetHost() | 827 ->GetRenderWidgetHost() |
838 ->GetView()); | 828 ->GetView()); |
839 | 829 |
840 SurfaceHitTestReadyNotifier notifier( | 830 SurfaceHitTestReadyNotifier notifier( |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 #else | 862 #else |
873 #define MAYBE_SurfaceHitTestPointerEventsNone SurfaceHitTestPointerEventsNone | 863 #define MAYBE_SurfaceHitTestPointerEventsNone SurfaceHitTestPointerEventsNone |
874 #endif | 864 #endif |
875 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 865 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
876 MAYBE_SurfaceHitTestPointerEventsNone) { | 866 MAYBE_SurfaceHitTestPointerEventsNone) { |
877 GURL main_url(embedded_test_server()->GetURL( | 867 GURL main_url(embedded_test_server()->GetURL( |
878 "/frame_tree/page_with_positioned_frame_pointer-events_none.html")); | 868 "/frame_tree/page_with_positioned_frame_pointer-events_none.html")); |
879 NavigateToURL(shell(), main_url); | 869 NavigateToURL(shell(), main_url); |
880 | 870 |
881 // It is safe to obtain the root frame tree node here, as it doesn't change. | 871 // It is safe to obtain the root frame tree node here, as it doesn't change. |
882 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 872 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
883 ->GetFrameTree() | |
884 ->root(); | |
885 ASSERT_EQ(1U, root->child_count()); | 873 ASSERT_EQ(1U, root->child_count()); |
886 | 874 |
887 FrameTreeNode* child_node = root->child_at(0); | 875 FrameTreeNode* child_node = root->child_at(0); |
888 GURL site_url(embedded_test_server()->GetURL("baz.com", "/title1.html")); | 876 GURL site_url(embedded_test_server()->GetURL("baz.com", "/title1.html")); |
889 EXPECT_EQ(site_url, child_node->current_url()); | 877 EXPECT_EQ(site_url, child_node->current_url()); |
890 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 878 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
891 child_node->current_frame_host()->GetSiteInstance()); | 879 child_node->current_frame_host()->GetSiteInstance()); |
892 | 880 |
893 // Create listeners for mouse events. | 881 // Create listeners for mouse events. |
894 RenderWidgetHostMouseEventMonitor main_frame_monitor( | 882 RenderWidgetHostMouseEventMonitor main_frame_monitor( |
895 root->current_frame_host()->GetRenderWidgetHost()); | 883 root->current_frame_host()->GetRenderWidgetHost()); |
896 RenderWidgetHostMouseEventMonitor child_frame_monitor( | 884 RenderWidgetHostMouseEventMonitor child_frame_monitor( |
897 child_node->current_frame_host()->GetRenderWidgetHost()); | 885 child_node->current_frame_host()->GetRenderWidgetHost()); |
898 | 886 |
899 RenderWidgetHostInputEventRouter* router = | 887 RenderWidgetHostInputEventRouter* router = |
900 static_cast<WebContentsImpl*>(shell()->web_contents()) | 888 web_contents()->GetInputEventRouter(); |
901 ->GetInputEventRouter(); | |
902 | 889 |
903 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( | 890 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( |
904 root->current_frame_host()->GetRenderWidgetHost()->GetView()); | 891 root->current_frame_host()->GetRenderWidgetHost()->GetView()); |
905 RenderWidgetHostViewBase* rwhv_child = static_cast<RenderWidgetHostViewBase*>( | 892 RenderWidgetHostViewBase* rwhv_child = static_cast<RenderWidgetHostViewBase*>( |
906 child_node->current_frame_host()->GetRenderWidgetHost()->GetView()); | 893 child_node->current_frame_host()->GetRenderWidgetHost()->GetView()); |
907 | 894 |
908 SurfaceHitTestReadyNotifier notifier( | 895 SurfaceHitTestReadyNotifier notifier( |
909 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_child)); | 896 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_child)); |
910 notifier.WaitForSurfaceReady(); | 897 notifier.WaitForSurfaceReady(); |
911 | 898 |
(...skipping 22 matching lines...) Expand all Loading... |
934 #else | 921 #else |
935 #define MAYBE_CompositorFrameSwapped CompositorFrameSwapped | 922 #define MAYBE_CompositorFrameSwapped CompositorFrameSwapped |
936 #endif | 923 #endif |
937 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 924 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
938 MAYBE_CompositorFrameSwapped) { | 925 MAYBE_CompositorFrameSwapped) { |
939 GURL main_url(embedded_test_server()->GetURL( | 926 GURL main_url(embedded_test_server()->GetURL( |
940 "a.com", "/cross_site_iframe_factory.html?a(baz)")); | 927 "a.com", "/cross_site_iframe_factory.html?a(baz)")); |
941 NavigateToURL(shell(), main_url); | 928 NavigateToURL(shell(), main_url); |
942 | 929 |
943 // It is safe to obtain the root frame tree node here, as it doesn't change. | 930 // It is safe to obtain the root frame tree node here, as it doesn't change. |
944 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 931 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
945 ->GetFrameTree() | |
946 ->root(); | |
947 ASSERT_EQ(1U, root->child_count()); | 932 ASSERT_EQ(1U, root->child_count()); |
948 | 933 |
949 FrameTreeNode* child_node = root->child_at(0); | 934 FrameTreeNode* child_node = root->child_at(0); |
950 GURL site_url(embedded_test_server()->GetURL( | 935 GURL site_url(embedded_test_server()->GetURL( |
951 "baz.com", "/cross_site_iframe_factory.html?baz()")); | 936 "baz.com", "/cross_site_iframe_factory.html?baz()")); |
952 EXPECT_EQ(site_url, child_node->current_url()); | 937 EXPECT_EQ(site_url, child_node->current_url()); |
953 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 938 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
954 child_node->current_frame_host()->GetSiteInstance()); | 939 child_node->current_frame_host()->GetSiteInstance()); |
955 RenderWidgetHostViewBase* rwhv_base = static_cast<RenderWidgetHostViewBase*>( | 940 RenderWidgetHostViewBase* rwhv_base = static_cast<RenderWidgetHostViewBase*>( |
956 child_node->current_frame_host()->GetRenderWidgetHost()->GetView()); | 941 child_node->current_frame_host()->GetRenderWidgetHost()->GetView()); |
(...skipping 10 matching lines...) Expand all Loading... |
967 } | 952 } |
968 } | 953 } |
969 | 954 |
970 // Ensure that OOPIFs are deleted after navigating to a new main frame. | 955 // Ensure that OOPIFs are deleted after navigating to a new main frame. |
971 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CleanupCrossSiteIframe) { | 956 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CleanupCrossSiteIframe) { |
972 GURL main_url(embedded_test_server()->GetURL( | 957 GURL main_url(embedded_test_server()->GetURL( |
973 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))")); | 958 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))")); |
974 NavigateToURL(shell(), main_url); | 959 NavigateToURL(shell(), main_url); |
975 | 960 |
976 // It is safe to obtain the root frame tree node here, as it doesn't change. | 961 // It is safe to obtain the root frame tree node here, as it doesn't change. |
977 FrameTreeNode* root = | 962 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
978 static_cast<WebContentsImpl*>(shell()->web_contents())-> | |
979 GetFrameTree()->root(); | |
980 | 963 |
981 TestNavigationObserver observer(shell()->web_contents()); | 964 TestNavigationObserver observer(shell()->web_contents()); |
982 | 965 |
983 // Load a cross-site page into both iframes. | 966 // Load a cross-site page into both iframes. |
984 GURL foo_url = embedded_test_server()->GetURL("foo.com", "/title2.html"); | 967 GURL foo_url = embedded_test_server()->GetURL("foo.com", "/title2.html"); |
985 NavigateFrameToURL(root->child_at(0), foo_url); | 968 NavigateFrameToURL(root->child_at(0), foo_url); |
986 EXPECT_TRUE(observer.last_navigation_succeeded()); | 969 EXPECT_TRUE(observer.last_navigation_succeeded()); |
987 EXPECT_EQ(foo_url, observer.last_navigation_url()); | 970 EXPECT_EQ(foo_url, observer.last_navigation_url()); |
988 NavigateFrameToURL(root->child_at(1), foo_url); | 971 NavigateFrameToURL(root->child_at(1), foo_url); |
989 EXPECT_TRUE(observer.last_navigation_succeeded()); | 972 EXPECT_TRUE(observer.last_navigation_succeeded()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1026 EXPECT_FALSE(RenderViewHost::FromID(subframe_process_id, subframe_rvh_id)); | 1009 EXPECT_FALSE(RenderViewHost::FromID(subframe_process_id, subframe_rvh_id)); |
1027 } | 1010 } |
1028 | 1011 |
1029 // Ensure that root frames cannot be detached. | 1012 // Ensure that root frames cannot be detached. |
1030 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, RestrictFrameDetach) { | 1013 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, RestrictFrameDetach) { |
1031 GURL main_url(embedded_test_server()->GetURL( | 1014 GURL main_url(embedded_test_server()->GetURL( |
1032 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))")); | 1015 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))")); |
1033 NavigateToURL(shell(), main_url); | 1016 NavigateToURL(shell(), main_url); |
1034 | 1017 |
1035 // It is safe to obtain the root frame tree node here, as it doesn't change. | 1018 // It is safe to obtain the root frame tree node here, as it doesn't change. |
1036 FrameTreeNode* root = | 1019 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
1037 static_cast<WebContentsImpl*>(shell()->web_contents())-> | |
1038 GetFrameTree()->root(); | |
1039 | 1020 |
1040 TestNavigationObserver observer(shell()->web_contents()); | 1021 TestNavigationObserver observer(shell()->web_contents()); |
1041 | 1022 |
1042 // Load cross-site pages into both iframes. | 1023 // Load cross-site pages into both iframes. |
1043 GURL foo_url = embedded_test_server()->GetURL("foo.com", "/title2.html"); | 1024 GURL foo_url = embedded_test_server()->GetURL("foo.com", "/title2.html"); |
1044 NavigateFrameToURL(root->child_at(0), foo_url); | 1025 NavigateFrameToURL(root->child_at(0), foo_url); |
1045 EXPECT_TRUE(observer.last_navigation_succeeded()); | 1026 EXPECT_TRUE(observer.last_navigation_succeeded()); |
1046 EXPECT_EQ(foo_url, observer.last_navigation_url()); | 1027 EXPECT_EQ(foo_url, observer.last_navigation_url()); |
1047 GURL bar_url = embedded_test_server()->GetURL("bar.com", "/title2.html"); | 1028 GURL bar_url = embedded_test_server()->GetURL("bar.com", "/title2.html"); |
1048 NavigateFrameToURL(root->child_at(1), bar_url); | 1029 NavigateFrameToURL(root->child_at(1), bar_url); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 " C = http://bar.com/", | 1071 " C = http://bar.com/", |
1091 DepictFrameTree(root)); | 1072 DepictFrameTree(root)); |
1092 } | 1073 } |
1093 | 1074 |
1094 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, NavigateRemoteFrame) { | 1075 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, NavigateRemoteFrame) { |
1095 GURL main_url(embedded_test_server()->GetURL( | 1076 GURL main_url(embedded_test_server()->GetURL( |
1096 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))")); | 1077 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))")); |
1097 NavigateToURL(shell(), main_url); | 1078 NavigateToURL(shell(), main_url); |
1098 | 1079 |
1099 // It is safe to obtain the root frame tree node here, as it doesn't change. | 1080 // It is safe to obtain the root frame tree node here, as it doesn't change. |
1100 FrameTreeNode* root = | 1081 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
1101 static_cast<WebContentsImpl*>(shell()->web_contents())-> | |
1102 GetFrameTree()->root(); | |
1103 | 1082 |
1104 TestNavigationObserver observer(shell()->web_contents()); | 1083 TestNavigationObserver observer(shell()->web_contents()); |
1105 | 1084 |
1106 // Load same-site page into iframe. | 1085 // Load same-site page into iframe. |
1107 FrameTreeNode* child = root->child_at(0); | 1086 FrameTreeNode* child = root->child_at(0); |
1108 GURL http_url(embedded_test_server()->GetURL("a.com", "/title1.html")); | 1087 GURL http_url(embedded_test_server()->GetURL("a.com", "/title1.html")); |
1109 NavigateFrameToURL(child, http_url); | 1088 NavigateFrameToURL(child, http_url); |
1110 EXPECT_EQ(http_url, observer.last_navigation_url()); | 1089 EXPECT_EQ(http_url, observer.last_navigation_url()); |
1111 EXPECT_TRUE(observer.last_navigation_succeeded()); | 1090 EXPECT_TRUE(observer.last_navigation_succeeded()); |
1112 | 1091 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1159 child->current_frame_host()->GetSiteInstance()); | 1138 child->current_frame_host()->GetSiteInstance()); |
1160 } | 1139 } |
1161 | 1140 |
1162 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 1141 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
1163 NavigateRemoteFrameToBlankAndDataURLs) { | 1142 NavigateRemoteFrameToBlankAndDataURLs) { |
1164 GURL main_url(embedded_test_server()->GetURL( | 1143 GURL main_url(embedded_test_server()->GetURL( |
1165 "a.com", "/cross_site_iframe_factory.html?a(a,a(a))")); | 1144 "a.com", "/cross_site_iframe_factory.html?a(a,a(a))")); |
1166 NavigateToURL(shell(), main_url); | 1145 NavigateToURL(shell(), main_url); |
1167 | 1146 |
1168 // It is safe to obtain the root frame tree node here, as it doesn't change. | 1147 // It is safe to obtain the root frame tree node here, as it doesn't change. |
1169 FrameTreeNode* root = | 1148 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
1170 static_cast<WebContentsImpl*>(shell()->web_contents())-> | |
1171 GetFrameTree()->root(); | |
1172 | 1149 |
1173 TestNavigationObserver observer(shell()->web_contents()); | 1150 TestNavigationObserver observer(shell()->web_contents()); |
1174 | 1151 |
1175 // Load same-site page into iframe. | 1152 // Load same-site page into iframe. |
1176 FrameTreeNode* child = root->child_at(0); | 1153 FrameTreeNode* child = root->child_at(0); |
1177 GURL http_url(embedded_test_server()->GetURL("a.com", "/title1.html")); | 1154 GURL http_url(embedded_test_server()->GetURL("a.com", "/title1.html")); |
1178 NavigateFrameToURL(child, http_url); | 1155 NavigateFrameToURL(child, http_url); |
1179 EXPECT_EQ(http_url, observer.last_navigation_url()); | 1156 EXPECT_EQ(http_url, observer.last_navigation_url()); |
1180 EXPECT_TRUE(observer.last_navigation_succeeded()); | 1157 EXPECT_TRUE(observer.last_navigation_succeeded()); |
1181 EXPECT_EQ( | 1158 EXPECT_EQ( |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1267 // | 1244 // |
1268 // Note that due to http://crbug.com/450681, node2 cannot be re-navigated to | 1245 // Note that due to http://crbug.com/450681, node2 cannot be re-navigated to |
1269 // site B and stays in not rendered state. | 1246 // site B and stays in not rendered state. |
1270 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 1247 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
1271 NavigateRemoteFrameToKilledProcess) { | 1248 NavigateRemoteFrameToKilledProcess) { |
1272 GURL main_url(embedded_test_server()->GetURL( | 1249 GURL main_url(embedded_test_server()->GetURL( |
1273 "foo.com", "/cross_site_iframe_factory.html?foo.com(bar.com, foo.com)")); | 1250 "foo.com", "/cross_site_iframe_factory.html?foo.com(bar.com, foo.com)")); |
1274 NavigateToURL(shell(), main_url); | 1251 NavigateToURL(shell(), main_url); |
1275 | 1252 |
1276 // It is safe to obtain the root frame tree node here, as it doesn't change. | 1253 // It is safe to obtain the root frame tree node here, as it doesn't change. |
1277 FrameTreeNode* root = | 1254 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
1278 static_cast<WebContentsImpl*>(shell()->web_contents())-> | |
1279 GetFrameTree()->root(); | |
1280 | 1255 |
1281 TestNavigationObserver observer(shell()->web_contents()); | 1256 TestNavigationObserver observer(shell()->web_contents()); |
1282 ASSERT_EQ(2U, root->child_count()); | 1257 ASSERT_EQ(2U, root->child_count()); |
1283 | 1258 |
1284 // Make sure node2 points to the correct cross-site page. | 1259 // Make sure node2 points to the correct cross-site page. |
1285 GURL site_b_url = embedded_test_server()->GetURL( | 1260 GURL site_b_url = embedded_test_server()->GetURL( |
1286 "bar.com", "/cross_site_iframe_factory.html?bar.com()"); | 1261 "bar.com", "/cross_site_iframe_factory.html?bar.com()"); |
1287 FrameTreeNode* node2 = root->child_at(0); | 1262 FrameTreeNode* node2 = root->child_at(0); |
1288 EXPECT_EQ(site_b_url, node2->current_url()); | 1263 EXPECT_EQ(site_b_url, node2->current_url()); |
1289 | 1264 |
(...skipping 28 matching lines...) Expand all Loading... |
1318 // | 1293 // |
1319 // Note that due to http://crbug.com/450681, node2 cannot be re-navigated to | 1294 // Note that due to http://crbug.com/450681, node2 cannot be re-navigated to |
1320 // site B and stays in not rendered state. | 1295 // site B and stays in not rendered state. |
1321 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 1296 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
1322 NavigateRemoteFrameToKilledProcessWithSubtree) { | 1297 NavigateRemoteFrameToKilledProcessWithSubtree) { |
1323 GURL main_url(embedded_test_server()->GetURL( | 1298 GURL main_url(embedded_test_server()->GetURL( |
1324 "a.com", "/cross_site_iframe_factory.html?a(bar(baz), a)")); | 1299 "a.com", "/cross_site_iframe_factory.html?a(bar(baz), a)")); |
1325 NavigateToURL(shell(), main_url); | 1300 NavigateToURL(shell(), main_url); |
1326 | 1301 |
1327 // It is safe to obtain the root frame tree node here, as it doesn't change. | 1302 // It is safe to obtain the root frame tree node here, as it doesn't change. |
1328 FrameTreeNode* root = | 1303 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
1329 static_cast<WebContentsImpl*>(shell()->web_contents())-> | |
1330 GetFrameTree()->root(); | |
1331 TestNavigationObserver observer(shell()->web_contents()); | 1304 TestNavigationObserver observer(shell()->web_contents()); |
1332 | 1305 |
1333 ASSERT_EQ(2U, root->child_count()); | 1306 ASSERT_EQ(2U, root->child_count()); |
1334 | 1307 |
1335 GURL site_b_url(embedded_test_server()->GetURL( | 1308 GURL site_b_url(embedded_test_server()->GetURL( |
1336 "bar.com", "/cross_site_iframe_factory.html?bar(baz())")); | 1309 "bar.com", "/cross_site_iframe_factory.html?bar(baz())")); |
1337 // We can't use a TestNavigationObserver to verify the URL here, | 1310 // We can't use a TestNavigationObserver to verify the URL here, |
1338 // since the frame has children that may have clobbered it in the observer. | 1311 // since the frame has children that may have clobbered it in the observer. |
1339 EXPECT_EQ(site_b_url, root->child_at(0)->current_url()); | 1312 EXPECT_EQ(site_b_url, root->child_at(0)->current_url()); |
1340 | 1313 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1405 | 1378 |
1406 // Ensure that the renderer process doesn't crash when the main frame navigates | 1379 // Ensure that the renderer process doesn't crash when the main frame navigates |
1407 // a remote child to a page that results in a network error. | 1380 // a remote child to a page that results in a network error. |
1408 // See https://crbug.com/558016. | 1381 // See https://crbug.com/558016. |
1409 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, NavigateRemoteAfterError) { | 1382 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, NavigateRemoteAfterError) { |
1410 GURL main_url(embedded_test_server()->GetURL( | 1383 GURL main_url(embedded_test_server()->GetURL( |
1411 "a.com", "/cross_site_iframe_factory.html?a(a)")); | 1384 "a.com", "/cross_site_iframe_factory.html?a(a)")); |
1412 NavigateToURL(shell(), main_url); | 1385 NavigateToURL(shell(), main_url); |
1413 | 1386 |
1414 // It is safe to obtain the root frame tree node here, as it doesn't change. | 1387 // It is safe to obtain the root frame tree node here, as it doesn't change. |
1415 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 1388 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
1416 ->GetFrameTree() | |
1417 ->root(); | |
1418 | 1389 |
1419 // Load same-site page into iframe. | 1390 // Load same-site page into iframe. |
1420 { | 1391 { |
1421 TestNavigationObserver observer(shell()->web_contents()); | 1392 TestNavigationObserver observer(shell()->web_contents()); |
1422 FrameTreeNode* child = root->child_at(0); | 1393 FrameTreeNode* child = root->child_at(0); |
1423 GURL http_url(embedded_test_server()->GetURL("a.com", "/title1.html")); | 1394 GURL http_url(embedded_test_server()->GetURL("a.com", "/title1.html")); |
1424 NavigateFrameToURL(child, http_url); | 1395 NavigateFrameToURL(child, http_url); |
1425 EXPECT_EQ(http_url, observer.last_navigation_url()); | 1396 EXPECT_EQ(http_url, observer.last_navigation_url()); |
1426 EXPECT_TRUE(observer.last_navigation_succeeded()); | 1397 EXPECT_TRUE(observer.last_navigation_succeeded()); |
1427 observer.Wait(); | 1398 observer.Wait(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1461 // successfully loads after earlier encountering a network error for it. | 1432 // successfully loads after earlier encountering a network error for it. |
1462 // See https://crbug.com/560511. | 1433 // See https://crbug.com/560511. |
1463 // TODO(creis): Make the net error page show in the correct process as well, | 1434 // TODO(creis): Make the net error page show in the correct process as well, |
1464 // per https://crbug.com/588314. | 1435 // per https://crbug.com/588314. |
1465 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ProcessTransferAfterError) { | 1436 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ProcessTransferAfterError) { |
1466 GURL main_url(embedded_test_server()->GetURL( | 1437 GURL main_url(embedded_test_server()->GetURL( |
1467 "a.com", "/cross_site_iframe_factory.html?a(a)")); | 1438 "a.com", "/cross_site_iframe_factory.html?a(a)")); |
1468 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 1439 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
1469 | 1440 |
1470 // It is safe to obtain the root frame tree node here, as it doesn't change. | 1441 // It is safe to obtain the root frame tree node here, as it doesn't change. |
1471 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 1442 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
1472 ->GetFrameTree() | |
1473 ->root(); | |
1474 FrameTreeNode* child = root->child_at(0); | 1443 FrameTreeNode* child = root->child_at(0); |
1475 GURL url_a = child->current_url(); | 1444 GURL url_a = child->current_url(); |
1476 | 1445 |
1477 // Disable host resolution in the test server and try to navigate the subframe | 1446 // Disable host resolution in the test server and try to navigate the subframe |
1478 // cross-site, which will lead to a committed net error (which looks like | 1447 // cross-site, which will lead to a committed net error (which looks like |
1479 // success to the TestNavigationObserver). | 1448 // success to the TestNavigationObserver). |
1480 GURL url_b = embedded_test_server()->GetURL("b.com", "/title3.html"); | 1449 GURL url_b = embedded_test_server()->GetURL("b.com", "/title3.html"); |
1481 host_resolver()->ClearRules(); | 1450 host_resolver()->ClearRules(); |
1482 TestNavigationObserver observer(shell()->web_contents()); | 1451 TestNavigationObserver observer(shell()->web_contents()); |
1483 NavigateIframeToURL(shell()->web_contents(), "child-0", url_b); | 1452 NavigateIframeToURL(shell()->web_contents(), "child-0", url_b); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1565 // verifying that a proxy for node 4 has been recreated in process B. This | 1534 // verifying that a proxy for node 4 has been recreated in process B. This |
1566 // verifies the fix for https://crbug.com/478892. | 1535 // verifies the fix for https://crbug.com/478892. |
1567 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 1536 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
1568 NavigatingToKilledProcessRestoresAllProxies) { | 1537 NavigatingToKilledProcessRestoresAllProxies) { |
1569 // Navigate to a page with three frames: one cross-site and two same-site. | 1538 // Navigate to a page with three frames: one cross-site and two same-site. |
1570 GURL main_url(embedded_test_server()->GetURL( | 1539 GURL main_url(embedded_test_server()->GetURL( |
1571 "a.com", "/frame_tree/page_with_three_frames.html")); | 1540 "a.com", "/frame_tree/page_with_three_frames.html")); |
1572 NavigateToURL(shell(), main_url); | 1541 NavigateToURL(shell(), main_url); |
1573 | 1542 |
1574 // It is safe to obtain the root frame tree node here, as it doesn't change. | 1543 // It is safe to obtain the root frame tree node here, as it doesn't change. |
1575 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 1544 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
1576 ->GetFrameTree() | |
1577 ->root(); | |
1578 TestNavigationObserver observer(shell()->web_contents()); | 1545 TestNavigationObserver observer(shell()->web_contents()); |
1579 | 1546 |
1580 EXPECT_EQ( | 1547 EXPECT_EQ( |
1581 " Site A ------------ proxies for B\n" | 1548 " Site A ------------ proxies for B\n" |
1582 " |--Site B ------- proxies for A\n" | 1549 " |--Site B ------- proxies for A\n" |
1583 " |--Site A ------- proxies for B\n" | 1550 " |--Site A ------- proxies for B\n" |
1584 " +--Site A ------- proxies for B\n" | 1551 " +--Site A ------- proxies for B\n" |
1585 "Where A = http://a.com/\n" | 1552 "Where A = http://a.com/\n" |
1586 " B = http://b.com/", | 1553 " B = http://b.com/", |
1587 DepictFrameTree(root)); | 1554 DepictFrameTree(root)); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1630 // process A, and then checks that process B isn't resurrected to create a | 1597 // process A, and then checks that process B isn't resurrected to create a |
1631 // proxy for the new child frame. See https://crbug.com/476846. | 1598 // proxy for the new child frame. See https://crbug.com/476846. |
1632 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 1599 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
1633 CreateChildFrameAfterKillingProcess) { | 1600 CreateChildFrameAfterKillingProcess) { |
1634 // Navigate to a page with three frames: one cross-site and two same-site. | 1601 // Navigate to a page with three frames: one cross-site and two same-site. |
1635 GURL main_url(embedded_test_server()->GetURL( | 1602 GURL main_url(embedded_test_server()->GetURL( |
1636 "a.com", "/frame_tree/page_with_three_frames.html")); | 1603 "a.com", "/frame_tree/page_with_three_frames.html")); |
1637 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 1604 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
1638 | 1605 |
1639 // It is safe to obtain the root frame tree node here, as it doesn't change. | 1606 // It is safe to obtain the root frame tree node here, as it doesn't change. |
1640 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 1607 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
1641 ->GetFrameTree() | |
1642 ->root(); | |
1643 | 1608 |
1644 EXPECT_EQ( | 1609 EXPECT_EQ( |
1645 " Site A ------------ proxies for B\n" | 1610 " Site A ------------ proxies for B\n" |
1646 " |--Site B ------- proxies for A\n" | 1611 " |--Site B ------- proxies for A\n" |
1647 " |--Site A ------- proxies for B\n" | 1612 " |--Site A ------- proxies for B\n" |
1648 " +--Site A ------- proxies for B\n" | 1613 " +--Site A ------- proxies for B\n" |
1649 "Where A = http://a.com/\n" | 1614 "Where A = http://a.com/\n" |
1650 " B = http://b.com/", | 1615 " B = http://b.com/", |
1651 DepictFrameTree(root)); | 1616 DepictFrameTree(root)); |
1652 SiteInstance* b_site_instance = | 1617 SiteInstance* b_site_instance = |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1707 // for which its parent has proxies. This includes A. However, even though | 1672 // for which its parent has proxies. This includes A. However, even though |
1708 // process A is live (step 4), the parent proxy in A is not live (which was | 1673 // process A is live (step 4), the parent proxy in A is not live (which was |
1709 // incorrectly assumed previously). This is because step 4 does not resurrect | 1674 // incorrectly assumed previously). This is because step 4 does not resurrect |
1710 // proxies for popups opened before the crash. | 1675 // proxies for popups opened before the crash. |
1711 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 1676 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
1712 CreateChildFrameAfterKillingOpener) { | 1677 CreateChildFrameAfterKillingOpener) { |
1713 GURL main_url(embedded_test_server()->GetURL("a.com", "/title1.html")); | 1678 GURL main_url(embedded_test_server()->GetURL("a.com", "/title1.html")); |
1714 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 1679 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
1715 | 1680 |
1716 // It is safe to obtain the root frame tree node here, as it doesn't change. | 1681 // It is safe to obtain the root frame tree node here, as it doesn't change. |
1717 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 1682 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
1718 ->GetFrameTree() | |
1719 ->root(); | |
1720 SiteInstance* site_instance_a = root->current_frame_host()->GetSiteInstance(); | 1683 SiteInstance* site_instance_a = root->current_frame_host()->GetSiteInstance(); |
1721 | 1684 |
1722 // Open a popup and navigate it cross-process to b.com. | 1685 // Open a popup and navigate it cross-process to b.com. |
1723 ShellAddedObserver new_shell_observer; | 1686 ShellAddedObserver new_shell_observer; |
1724 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), | 1687 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), |
1725 "popup = window.open('about:blank');")); | 1688 "popup = window.open('about:blank');")); |
1726 Shell* popup = new_shell_observer.GetShell(); | 1689 Shell* popup = new_shell_observer.GetShell(); |
1727 GURL popup_url(embedded_test_server()->GetURL("b.com", "/title2.html")); | 1690 GURL popup_url(embedded_test_server()->GetURL("b.com", "/title2.html")); |
1728 EXPECT_TRUE(NavigateToURL(popup, popup_url)); | 1691 EXPECT_TRUE(NavigateToURL(popup, popup_url)); |
1729 | 1692 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1795 // node1 is the root. | 1758 // node1 is the root. |
1796 // Initially, both node1.proxy_hosts_ and node3.proxy_hosts_ contain C. | 1759 // Initially, both node1.proxy_hosts_ and node3.proxy_hosts_ contain C. |
1797 // After we kill B, make sure proxies for C are cleared. | 1760 // After we kill B, make sure proxies for C are cleared. |
1798 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 1761 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
1799 KillingRendererClearsDescendantProxies) { | 1762 KillingRendererClearsDescendantProxies) { |
1800 GURL main_url(embedded_test_server()->GetURL( | 1763 GURL main_url(embedded_test_server()->GetURL( |
1801 "a.com", "/frame_tree/page_with_two_frames_nested.html")); | 1764 "a.com", "/frame_tree/page_with_two_frames_nested.html")); |
1802 NavigateToURL(shell(), main_url); | 1765 NavigateToURL(shell(), main_url); |
1803 | 1766 |
1804 // It is safe to obtain the root frame tree node here, as it doesn't change. | 1767 // It is safe to obtain the root frame tree node here, as it doesn't change. |
1805 FrameTreeNode* root = | 1768 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
1806 static_cast<WebContentsImpl*>(shell()->web_contents())-> | |
1807 GetFrameTree()->root(); | |
1808 ASSERT_EQ(2U, root->child_count()); | 1769 ASSERT_EQ(2U, root->child_count()); |
1809 | 1770 |
1810 GURL site_b_url( | 1771 GURL site_b_url( |
1811 embedded_test_server()->GetURL( | 1772 embedded_test_server()->GetURL( |
1812 "bar.com", "/frame_tree/page_with_one_frame.html")); | 1773 "bar.com", "/frame_tree/page_with_one_frame.html")); |
1813 // We can't use a TestNavigationObserver to verify the URL here, | 1774 // We can't use a TestNavigationObserver to verify the URL here, |
1814 // since the frame has children that may have clobbered it in the observer. | 1775 // since the frame has children that may have clobbered it in the observer. |
1815 EXPECT_EQ(site_b_url, root->child_at(0)->current_url()); | 1776 EXPECT_EQ(site_b_url, root->child_at(0)->current_url()); |
1816 | 1777 |
1817 // Ensure that a new process is created for node2. | 1778 // Ensure that a new process is created for node2. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1869 } | 1830 } |
1870 | 1831 |
1871 // Crash a subframe and ensures its children are cleared from the FrameTree. | 1832 // Crash a subframe and ensures its children are cleared from the FrameTree. |
1872 // See http://crbug.com/338508. | 1833 // See http://crbug.com/338508. |
1873 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrashSubframe) { | 1834 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrashSubframe) { |
1874 GURL main_url(embedded_test_server()->GetURL( | 1835 GURL main_url(embedded_test_server()->GetURL( |
1875 "a.com", "/cross_site_iframe_factory.html?a(b)")); | 1836 "a.com", "/cross_site_iframe_factory.html?a(b)")); |
1876 NavigateToURL(shell(), main_url); | 1837 NavigateToURL(shell(), main_url); |
1877 | 1838 |
1878 // Check the subframe process. | 1839 // Check the subframe process. |
1879 FrameTreeNode* root = | 1840 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
1880 static_cast<WebContentsImpl*>(shell()->web_contents())-> | |
1881 GetFrameTree()->root(); | |
1882 EXPECT_EQ( | 1841 EXPECT_EQ( |
1883 " Site A ------------ proxies for B\n" | 1842 " Site A ------------ proxies for B\n" |
1884 " +--Site B ------- proxies for A\n" | 1843 " +--Site B ------- proxies for A\n" |
1885 "Where A = http://a.com/\n" | 1844 "Where A = http://a.com/\n" |
1886 " B = http://b.com/", | 1845 " B = http://b.com/", |
1887 DepictFrameTree(root)); | 1846 DepictFrameTree(root)); |
1888 FrameTreeNode* child = root->child_at(0); | 1847 FrameTreeNode* child = root->child_at(0); |
1889 EXPECT_TRUE( | 1848 EXPECT_TRUE( |
1890 child->current_frame_host()->render_view_host()->IsRenderViewLive()); | 1849 child->current_frame_host()->render_view_host()->IsRenderViewLive()); |
1891 EXPECT_TRUE(child->current_frame_host()->IsRenderFrameLive()); | 1850 EXPECT_TRUE(child->current_frame_host()->IsRenderFrameLive()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1932 // When a new subframe is added, related SiteInstances that can reach the | 1891 // When a new subframe is added, related SiteInstances that can reach the |
1933 // subframe should create proxies for it (https://crbug.com/423587). This test | 1892 // subframe should create proxies for it (https://crbug.com/423587). This test |
1934 // checks that if A embeds B and later adds a new subframe A2, A2 gets a proxy | 1893 // checks that if A embeds B and later adds a new subframe A2, A2 gets a proxy |
1935 // in B's process. | 1894 // in B's process. |
1936 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CreateProxiesForNewFrames) { | 1895 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CreateProxiesForNewFrames) { |
1937 GURL main_url(embedded_test_server()->GetURL( | 1896 GURL main_url(embedded_test_server()->GetURL( |
1938 "b.com", "/frame_tree/page_with_one_frame.html")); | 1897 "b.com", "/frame_tree/page_with_one_frame.html")); |
1939 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 1898 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
1940 | 1899 |
1941 // It is safe to obtain the root frame tree node here, as it doesn't change. | 1900 // It is safe to obtain the root frame tree node here, as it doesn't change. |
1942 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 1901 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
1943 ->GetFrameTree() | |
1944 ->root(); | |
1945 ASSERT_EQ(1U, root->child_count()); | 1902 ASSERT_EQ(1U, root->child_count()); |
1946 | 1903 |
1947 // Make sure the frame starts out at the correct cross-site URL. | 1904 // Make sure the frame starts out at the correct cross-site URL. |
1948 EXPECT_EQ(embedded_test_server()->GetURL("baz.com", "/title1.html"), | 1905 EXPECT_EQ(embedded_test_server()->GetURL("baz.com", "/title1.html"), |
1949 root->child_at(0)->current_url()); | 1906 root->child_at(0)->current_url()); |
1950 | 1907 |
1951 EXPECT_EQ( | 1908 EXPECT_EQ( |
1952 " Site A ------------ proxies for B\n" | 1909 " Site A ------------ proxies for B\n" |
1953 " +--Site B ------- proxies for A\n" | 1910 " +--Site B ------- proxies for A\n" |
1954 "Where A = http://b.com/\n" | 1911 "Where A = http://b.com/\n" |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2177 | 2134 |
2178 // Ensure that when navigating a frame cross-process RenderFrameProxyHosts are | 2135 // Ensure that when navigating a frame cross-process RenderFrameProxyHosts are |
2179 // created in the FrameTree skipping the subtree of the navigating frame. | 2136 // created in the FrameTree skipping the subtree of the navigating frame. |
2180 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 2137 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
2181 ProxyCreationSkipsSubtree) { | 2138 ProxyCreationSkipsSubtree) { |
2182 GURL main_url(embedded_test_server()->GetURL( | 2139 GURL main_url(embedded_test_server()->GetURL( |
2183 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))")); | 2140 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))")); |
2184 NavigateToURL(shell(), main_url); | 2141 NavigateToURL(shell(), main_url); |
2185 | 2142 |
2186 // It is safe to obtain the root frame tree node here, as it doesn't change. | 2143 // It is safe to obtain the root frame tree node here, as it doesn't change. |
2187 FrameTreeNode* root = | 2144 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
2188 static_cast<WebContentsImpl*>(shell()->web_contents())-> | |
2189 GetFrameTree()->root(); | |
2190 | 2145 |
2191 EXPECT_TRUE(root->child_at(1) != NULL); | 2146 EXPECT_TRUE(root->child_at(1) != NULL); |
2192 EXPECT_EQ(2U, root->child_at(1)->child_count()); | 2147 EXPECT_EQ(2U, root->child_at(1)->child_count()); |
2193 | 2148 |
2194 { | 2149 { |
2195 // Load same-site page into iframe. | 2150 // Load same-site page into iframe. |
2196 TestNavigationObserver observer(shell()->web_contents()); | 2151 TestNavigationObserver observer(shell()->web_contents()); |
2197 GURL http_url(embedded_test_server()->GetURL("a.com", "/title1.html")); | 2152 GURL http_url(embedded_test_server()->GetURL("a.com", "/title1.html")); |
2198 NavigateFrameToURL(root->child_at(0), http_url); | 2153 NavigateFrameToURL(root->child_at(0), http_url); |
2199 EXPECT_EQ(http_url, observer.last_navigation_url()); | 2154 EXPECT_EQ(http_url, observer.last_navigation_url()); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2325 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 2280 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
2326 MAYBE_FrameOwnerPropertiesPropagationScrolling) { | 2281 MAYBE_FrameOwnerPropertiesPropagationScrolling) { |
2327 #if defined(OS_MACOSX) | 2282 #if defined(OS_MACOSX) |
2328 ui::test::ScopedPreferredScrollerStyle scroller_style_override(false); | 2283 ui::test::ScopedPreferredScrollerStyle scroller_style_override(false); |
2329 #endif | 2284 #endif |
2330 GURL main_url(embedded_test_server()->GetURL( | 2285 GURL main_url(embedded_test_server()->GetURL( |
2331 "a.com", "/frame_owner_properties_scrolling.html")); | 2286 "a.com", "/frame_owner_properties_scrolling.html")); |
2332 NavigateToURL(shell(), main_url); | 2287 NavigateToURL(shell(), main_url); |
2333 | 2288 |
2334 // It is safe to obtain the root frame tree node here, as it doesn't change. | 2289 // It is safe to obtain the root frame tree node here, as it doesn't change. |
2335 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 2290 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
2336 ->GetFrameTree() | |
2337 ->root(); | |
2338 ASSERT_EQ(1u, root->child_count()); | 2291 ASSERT_EQ(1u, root->child_count()); |
2339 | 2292 |
2340 EXPECT_EQ( | 2293 EXPECT_EQ( |
2341 " Site A ------------ proxies for B\n" | 2294 " Site A ------------ proxies for B\n" |
2342 " +--Site B ------- proxies for A\n" | 2295 " +--Site B ------- proxies for A\n" |
2343 "Where A = http://a.com/\n" | 2296 "Where A = http://a.com/\n" |
2344 " B = http://b.com/", | 2297 " B = http://b.com/", |
2345 DepictFrameTree(root)); | 2298 DepictFrameTree(root)); |
2346 | 2299 |
2347 FrameTreeNode* child = root->child_at(0); | 2300 FrameTreeNode* child = root->child_at(0); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2393 | 2346 |
2394 // Verify that "marginwidth" and "marginheight" properties on frame elements | 2347 // Verify that "marginwidth" and "marginheight" properties on frame elements |
2395 // propagate to child frames correctly. | 2348 // propagate to child frames correctly. |
2396 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 2349 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
2397 FrameOwnerPropertiesPropagationMargin) { | 2350 FrameOwnerPropertiesPropagationMargin) { |
2398 GURL main_url(embedded_test_server()->GetURL( | 2351 GURL main_url(embedded_test_server()->GetURL( |
2399 "a.com", "/frame_owner_properties_margin.html")); | 2352 "a.com", "/frame_owner_properties_margin.html")); |
2400 NavigateToURL(shell(), main_url); | 2353 NavigateToURL(shell(), main_url); |
2401 | 2354 |
2402 // It is safe to obtain the root frame tree node here, as it doesn't change. | 2355 // It is safe to obtain the root frame tree node here, as it doesn't change. |
2403 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 2356 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
2404 ->GetFrameTree() | |
2405 ->root(); | |
2406 ASSERT_EQ(1u, root->child_count()); | 2357 ASSERT_EQ(1u, root->child_count()); |
2407 | 2358 |
2408 EXPECT_EQ( | 2359 EXPECT_EQ( |
2409 " Site A ------------ proxies for B\n" | 2360 " Site A ------------ proxies for B\n" |
2410 " +--Site B ------- proxies for A\n" | 2361 " +--Site B ------- proxies for A\n" |
2411 "Where A = http://a.com/\n" | 2362 "Where A = http://a.com/\n" |
2412 " B = http://b.com/", | 2363 " B = http://b.com/", |
2413 DepictFrameTree(root)); | 2364 DepictFrameTree(root)); |
2414 | 2365 |
2415 FrameTreeNode* child = root->child_at(0); | 2366 FrameTreeNode* child = root->child_at(0); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2482 } | 2433 } |
2483 } | 2434 } |
2484 | 2435 |
2485 // Verify origin replication with an A-embed-B-embed-C-embed-A hierarchy. | 2436 // Verify origin replication with an A-embed-B-embed-C-embed-A hierarchy. |
2486 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OriginReplication) { | 2437 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OriginReplication) { |
2487 GURL main_url(embedded_test_server()->GetURL( | 2438 GURL main_url(embedded_test_server()->GetURL( |
2488 "a.com", "/cross_site_iframe_factory.html?a(b(c(a),b), a)")); | 2439 "a.com", "/cross_site_iframe_factory.html?a(b(c(a),b), a)")); |
2489 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 2440 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
2490 | 2441 |
2491 // It is safe to obtain the root frame tree node here, as it doesn't change. | 2442 // It is safe to obtain the root frame tree node here, as it doesn't change. |
2492 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 2443 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
2493 ->GetFrameTree() | |
2494 ->root(); | |
2495 | 2444 |
2496 EXPECT_EQ( | 2445 EXPECT_EQ( |
2497 " Site A ------------ proxies for B C\n" | 2446 " Site A ------------ proxies for B C\n" |
2498 " |--Site B ------- proxies for A C\n" // tiptop_child | 2447 " |--Site B ------- proxies for A C\n" // tiptop_child |
2499 " | |--Site C -- proxies for A B\n" // middle_child | 2448 " | |--Site C -- proxies for A B\n" // middle_child |
2500 " | | +--Site A -- proxies for B C\n" // lowest_child | 2449 " | | +--Site A -- proxies for B C\n" // lowest_child |
2501 " | +--Site B -- proxies for A C\n" | 2450 " | +--Site B -- proxies for A C\n" |
2502 " +--Site A ------- proxies for B C\n" | 2451 " +--Site A ------- proxies for B C\n" |
2503 "Where A = http://a.com/\n" | 2452 "Where A = http://a.com/\n" |
2504 " B = http://b.com/\n" | 2453 " B = http://b.com/\n" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2573 &result)); | 2522 &result)); |
2574 EXPECT_EQ(a_origin, result + "/"); | 2523 EXPECT_EQ(a_origin, result + "/"); |
2575 } | 2524 } |
2576 | 2525 |
2577 // Check that iframe sandbox flags are replicated correctly. | 2526 // Check that iframe sandbox flags are replicated correctly. |
2578 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, SandboxFlagsReplication) { | 2527 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, SandboxFlagsReplication) { |
2579 GURL main_url(embedded_test_server()->GetURL("/sandboxed_frames.html")); | 2528 GURL main_url(embedded_test_server()->GetURL("/sandboxed_frames.html")); |
2580 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 2529 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
2581 | 2530 |
2582 // It is safe to obtain the root frame tree node here, as it doesn't change. | 2531 // It is safe to obtain the root frame tree node here, as it doesn't change. |
2583 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 2532 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
2584 ->GetFrameTree() | |
2585 ->root(); | |
2586 | 2533 |
2587 TestNavigationObserver observer(shell()->web_contents()); | 2534 TestNavigationObserver observer(shell()->web_contents()); |
2588 | 2535 |
2589 // Navigate the second (sandboxed) subframe to a cross-site page with a | 2536 // Navigate the second (sandboxed) subframe to a cross-site page with a |
2590 // subframe. | 2537 // subframe. |
2591 GURL foo_url( | 2538 GURL foo_url( |
2592 embedded_test_server()->GetURL("foo.com", "/frame_tree/1-1.html")); | 2539 embedded_test_server()->GetURL("foo.com", "/frame_tree/1-1.html")); |
2593 NavigateFrameToURL(root->child_at(1), foo_url); | 2540 NavigateFrameToURL(root->child_at(1), foo_url); |
2594 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 2541 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
2595 | 2542 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2673 EXPECT_EQ(main_url.GetOrigin().spec(), result + "/"); | 2620 EXPECT_EQ(main_url.GetOrigin().spec(), result + "/"); |
2674 } | 2621 } |
2675 | 2622 |
2676 // Check that dynamic updates to iframe sandbox flags are propagated correctly. | 2623 // Check that dynamic updates to iframe sandbox flags are propagated correctly. |
2677 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DynamicSandboxFlags) { | 2624 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DynamicSandboxFlags) { |
2678 GURL main_url( | 2625 GURL main_url( |
2679 embedded_test_server()->GetURL("/frame_tree/page_with_two_frames.html")); | 2626 embedded_test_server()->GetURL("/frame_tree/page_with_two_frames.html")); |
2680 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 2627 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
2681 | 2628 |
2682 // It is safe to obtain the root frame tree node here, as it doesn't change. | 2629 // It is safe to obtain the root frame tree node here, as it doesn't change. |
2683 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 2630 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
2684 ->GetFrameTree() | |
2685 ->root(); | |
2686 | 2631 |
2687 TestNavigationObserver observer(shell()->web_contents()); | 2632 TestNavigationObserver observer(shell()->web_contents()); |
2688 ASSERT_EQ(2U, root->child_count()); | 2633 ASSERT_EQ(2U, root->child_count()); |
2689 | 2634 |
2690 // Make sure first frame starts out at the correct cross-site page. | 2635 // Make sure first frame starts out at the correct cross-site page. |
2691 EXPECT_EQ(embedded_test_server()->GetURL("bar.com", "/title1.html"), | 2636 EXPECT_EQ(embedded_test_server()->GetURL("bar.com", "/title1.html"), |
2692 root->child_at(0)->current_url()); | 2637 root->child_at(0)->current_url()); |
2693 | 2638 |
2694 // Navigate second frame to another cross-site page. | 2639 // Navigate second frame to another cross-site page. |
2695 GURL baz_url(embedded_test_server()->GetURL("baz.com", "/title1.html")); | 2640 GURL baz_url(embedded_test_server()->GetURL("baz.com", "/title1.html")); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2797 } | 2742 } |
2798 | 2743 |
2799 // Check that dynamic updates to iframe sandbox flags are propagated correctly. | 2744 // Check that dynamic updates to iframe sandbox flags are propagated correctly. |
2800 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 2745 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
2801 DynamicSandboxFlagsRemoteToLocal) { | 2746 DynamicSandboxFlagsRemoteToLocal) { |
2802 GURL main_url( | 2747 GURL main_url( |
2803 embedded_test_server()->GetURL("/frame_tree/page_with_two_frames.html")); | 2748 embedded_test_server()->GetURL("/frame_tree/page_with_two_frames.html")); |
2804 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 2749 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
2805 | 2750 |
2806 // It is safe to obtain the root frame tree node here, as it doesn't change. | 2751 // It is safe to obtain the root frame tree node here, as it doesn't change. |
2807 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 2752 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
2808 ->GetFrameTree() | |
2809 ->root(); | |
2810 | 2753 |
2811 TestNavigationObserver observer(shell()->web_contents()); | 2754 TestNavigationObserver observer(shell()->web_contents()); |
2812 ASSERT_EQ(2U, root->child_count()); | 2755 ASSERT_EQ(2U, root->child_count()); |
2813 | 2756 |
2814 // Make sure the two frames starts out at correct URLs. | 2757 // Make sure the two frames starts out at correct URLs. |
2815 EXPECT_EQ(embedded_test_server()->GetURL("bar.com", "/title1.html"), | 2758 EXPECT_EQ(embedded_test_server()->GetURL("bar.com", "/title1.html"), |
2816 root->child_at(0)->current_url()); | 2759 root->child_at(0)->current_url()); |
2817 EXPECT_EQ(embedded_test_server()->GetURL("/title1.html"), | 2760 EXPECT_EQ(embedded_test_server()->GetURL("/title1.html"), |
2818 root->child_at(1)->current_url()); | 2761 root->child_at(1)->current_url()); |
2819 | 2762 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2867 } | 2810 } |
2868 | 2811 |
2869 // Check that dynamic updates to iframe sandbox flags are propagated correctly. | 2812 // Check that dynamic updates to iframe sandbox flags are propagated correctly. |
2870 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 2813 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
2871 DynamicSandboxFlagsRendererInitiatedNavigation) { | 2814 DynamicSandboxFlagsRendererInitiatedNavigation) { |
2872 GURL main_url( | 2815 GURL main_url( |
2873 embedded_test_server()->GetURL("/frame_tree/page_with_one_frame.html")); | 2816 embedded_test_server()->GetURL("/frame_tree/page_with_one_frame.html")); |
2874 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 2817 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
2875 | 2818 |
2876 // It is safe to obtain the root frame tree node here, as it doesn't change. | 2819 // It is safe to obtain the root frame tree node here, as it doesn't change. |
2877 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 2820 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
2878 ->GetFrameTree() | |
2879 ->root(); | |
2880 | 2821 |
2881 TestNavigationObserver observer(shell()->web_contents()); | 2822 TestNavigationObserver observer(shell()->web_contents()); |
2882 ASSERT_EQ(1U, root->child_count()); | 2823 ASSERT_EQ(1U, root->child_count()); |
2883 | 2824 |
2884 // Make sure the frame starts out at the correct cross-site page. | 2825 // Make sure the frame starts out at the correct cross-site page. |
2885 EXPECT_EQ(embedded_test_server()->GetURL("baz.com", "/title1.html"), | 2826 EXPECT_EQ(embedded_test_server()->GetURL("baz.com", "/title1.html"), |
2886 root->child_at(0)->current_url()); | 2827 root->child_at(0)->current_url()); |
2887 | 2828 |
2888 // The frame should not be sandboxed to start with. | 2829 // The frame should not be sandboxed to start with. |
2889 EXPECT_EQ(blink::WebSandboxFlags::None, | 2830 EXPECT_EQ(blink::WebSandboxFlags::None, |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2948 // checking whether the grandchild frame added in step 3 sees proper sandbox | 2889 // checking whether the grandchild frame added in step 3 sees proper sandbox |
2949 // flags and origin for its (remote) parent. This wasn't addressed when | 2890 // flags and origin for its (remote) parent. This wasn't addressed when |
2950 // https://crbug.com/423587 was fixed. | 2891 // https://crbug.com/423587 was fixed. |
2951 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 2892 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
2952 ProxiesForNewChildFramesHaveCorrectReplicationState) { | 2893 ProxiesForNewChildFramesHaveCorrectReplicationState) { |
2953 GURL main_url( | 2894 GURL main_url( |
2954 embedded_test_server()->GetURL("/frame_tree/page_with_one_frame.html")); | 2895 embedded_test_server()->GetURL("/frame_tree/page_with_one_frame.html")); |
2955 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 2896 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
2956 | 2897 |
2957 // It is safe to obtain the root frame tree node here, as it doesn't change. | 2898 // It is safe to obtain the root frame tree node here, as it doesn't change. |
2958 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 2899 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
2959 ->GetFrameTree() | |
2960 ->root(); | |
2961 TestNavigationObserver observer(shell()->web_contents()); | 2900 TestNavigationObserver observer(shell()->web_contents()); |
2962 | 2901 |
2963 EXPECT_EQ( | 2902 EXPECT_EQ( |
2964 " Site A ------------ proxies for B\n" | 2903 " Site A ------------ proxies for B\n" |
2965 " +--Site B ------- proxies for A\n" | 2904 " +--Site B ------- proxies for A\n" |
2966 "Where A = http://127.0.0.1/\n" | 2905 "Where A = http://127.0.0.1/\n" |
2967 " B = http://baz.com/", | 2906 " B = http://baz.com/", |
2968 DepictFrameTree(root)); | 2907 DepictFrameTree(root)); |
2969 | 2908 |
2970 // In the root frame, add a new sandboxed local frame, which itself has a | 2909 // 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... |
3029 EXPECT_TRUE(success); | 2968 EXPECT_TRUE(success); |
3030 EXPECT_EQ(1u, Shell::windows().size()); | 2969 EXPECT_EQ(1u, Shell::windows().size()); |
3031 } | 2970 } |
3032 | 2971 |
3033 // Verify that a child frame can retrieve the name property set by its parent. | 2972 // Verify that a child frame can retrieve the name property set by its parent. |
3034 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, WindowNameReplication) { | 2973 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, WindowNameReplication) { |
3035 GURL main_url(embedded_test_server()->GetURL("/frame_tree/2-4.html")); | 2974 GURL main_url(embedded_test_server()->GetURL("/frame_tree/2-4.html")); |
3036 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 2975 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
3037 | 2976 |
3038 // It is safe to obtain the root frame tree node here, as it doesn't change. | 2977 // It is safe to obtain the root frame tree node here, as it doesn't change. |
3039 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 2978 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
3040 ->GetFrameTree() | |
3041 ->root(); | |
3042 | 2979 |
3043 TestNavigationObserver observer(shell()->web_contents()); | 2980 TestNavigationObserver observer(shell()->web_contents()); |
3044 | 2981 |
3045 // Load cross-site page into iframe. | 2982 // Load cross-site page into iframe. |
3046 GURL frame_url = | 2983 GURL frame_url = |
3047 embedded_test_server()->GetURL("foo.com", "/frame_tree/3-1.html"); | 2984 embedded_test_server()->GetURL("foo.com", "/frame_tree/3-1.html"); |
3048 NavigateFrameToURL(root->child_at(0), frame_url); | 2985 NavigateFrameToURL(root->child_at(0), frame_url); |
3049 EXPECT_TRUE(observer.last_navigation_succeeded()); | 2986 EXPECT_TRUE(observer.last_navigation_succeeded()); |
3050 EXPECT_EQ(frame_url, observer.last_navigation_url()); | 2987 EXPECT_EQ(frame_url, observer.last_navigation_url()); |
3051 | 2988 |
(...skipping 10 matching lines...) Expand all Loading... |
3062 EXPECT_EQ("3-1-name", result); | 2999 EXPECT_EQ("3-1-name", result); |
3063 } | 3000 } |
3064 | 3001 |
3065 // Verify that dynamic updates to a frame's window.name propagate to the | 3002 // Verify that dynamic updates to a frame's window.name propagate to the |
3066 // frame's proxies, so that the latest frame names can be used in navigations. | 3003 // frame's proxies, so that the latest frame names can be used in navigations. |
3067 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DynamicWindowName) { | 3004 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DynamicWindowName) { |
3068 GURL main_url(embedded_test_server()->GetURL("/frame_tree/2-4.html")); | 3005 GURL main_url(embedded_test_server()->GetURL("/frame_tree/2-4.html")); |
3069 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 3006 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
3070 | 3007 |
3071 // It is safe to obtain the root frame tree node here, as it doesn't change. | 3008 // It is safe to obtain the root frame tree node here, as it doesn't change. |
3072 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 3009 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
3073 ->GetFrameTree() | |
3074 ->root(); | |
3075 TestNavigationObserver observer(shell()->web_contents()); | 3010 TestNavigationObserver observer(shell()->web_contents()); |
3076 | 3011 |
3077 // Load cross-site page into iframe. | 3012 // Load cross-site page into iframe. |
3078 GURL frame_url = | 3013 GURL frame_url = |
3079 embedded_test_server()->GetURL("foo.com", "/frame_tree/3-1.html"); | 3014 embedded_test_server()->GetURL("foo.com", "/frame_tree/3-1.html"); |
3080 NavigateFrameToURL(root->child_at(0), frame_url); | 3015 NavigateFrameToURL(root->child_at(0), frame_url); |
3081 EXPECT_TRUE(observer.last_navigation_succeeded()); | 3016 EXPECT_TRUE(observer.last_navigation_succeeded()); |
3082 EXPECT_EQ(frame_url, observer.last_navigation_url()); | 3017 EXPECT_EQ(frame_url, observer.last_navigation_url()); |
3083 | 3018 |
3084 // Browser process should know the child frame's original window.name | 3019 // Browser process should know the child frame's original window.name |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3121 } | 3056 } |
3122 | 3057 |
3123 // Verify that when a frame is navigated to a new origin, the origin update | 3058 // Verify that when a frame is navigated to a new origin, the origin update |
3124 // propagates to the frame's proxies. | 3059 // propagates to the frame's proxies. |
3125 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OriginUpdatesReachProxies) { | 3060 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OriginUpdatesReachProxies) { |
3126 GURL main_url( | 3061 GURL main_url( |
3127 embedded_test_server()->GetURL("/frame_tree/page_with_two_frames.html")); | 3062 embedded_test_server()->GetURL("/frame_tree/page_with_two_frames.html")); |
3128 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 3063 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
3129 | 3064 |
3130 // It is safe to obtain the root frame tree node here, as it doesn't change. | 3065 // It is safe to obtain the root frame tree node here, as it doesn't change. |
3131 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 3066 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
3132 ->GetFrameTree() | |
3133 ->root(); | |
3134 TestNavigationObserver observer(shell()->web_contents()); | 3067 TestNavigationObserver observer(shell()->web_contents()); |
3135 | 3068 |
3136 EXPECT_EQ( | 3069 EXPECT_EQ( |
3137 " Site A ------------ proxies for B\n" | 3070 " Site A ------------ proxies for B\n" |
3138 " |--Site B ------- proxies for A\n" | 3071 " |--Site B ------- proxies for A\n" |
3139 " +--Site A ------- proxies for B\n" | 3072 " +--Site A ------- proxies for B\n" |
3140 "Where A = http://127.0.0.1/\n" | 3073 "Where A = http://127.0.0.1/\n" |
3141 " B = http://bar.com/", | 3074 " B = http://bar.com/", |
3142 DepictFrameTree(root)); | 3075 DepictFrameTree(root)); |
3143 | 3076 |
(...skipping 30 matching lines...) Expand all Loading... |
3174 << frame_origin << ")"; | 3107 << frame_origin << ")"; |
3175 } | 3108 } |
3176 | 3109 |
3177 // Ensure that navigating subframes in --site-per-process mode properly fires | 3110 // Ensure that navigating subframes in --site-per-process mode properly fires |
3178 // the DidStopLoading event on WebContentsObserver. | 3111 // the DidStopLoading event on WebContentsObserver. |
3179 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteDidStopLoading) { | 3112 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteDidStopLoading) { |
3180 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); | 3113 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
3181 NavigateToURL(shell(), main_url); | 3114 NavigateToURL(shell(), main_url); |
3182 | 3115 |
3183 // It is safe to obtain the root frame tree node here, as it doesn't change. | 3116 // It is safe to obtain the root frame tree node here, as it doesn't change. |
3184 FrameTreeNode* root = | 3117 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
3185 static_cast<WebContentsImpl*>(shell()->web_contents())-> | |
3186 GetFrameTree()->root(); | |
3187 | 3118 |
3188 TestNavigationObserver observer(shell()->web_contents()); | 3119 TestNavigationObserver observer(shell()->web_contents()); |
3189 | 3120 |
3190 // Load same-site page into iframe. | 3121 // Load same-site page into iframe. |
3191 FrameTreeNode* child = root->child_at(0); | 3122 FrameTreeNode* child = root->child_at(0); |
3192 GURL http_url(embedded_test_server()->GetURL("/title1.html")); | 3123 GURL http_url(embedded_test_server()->GetURL("/title1.html")); |
3193 NavigateFrameToURL(child, http_url); | 3124 NavigateFrameToURL(child, http_url); |
3194 EXPECT_EQ(http_url, observer.last_navigation_url()); | 3125 EXPECT_EQ(http_url, observer.last_navigation_url()); |
3195 EXPECT_TRUE(observer.last_navigation_succeeded()); | 3126 EXPECT_TRUE(observer.last_navigation_succeeded()); |
3196 | 3127 |
(...skipping 13 matching lines...) Expand all Loading... |
3210 | 3141 |
3211 // Ensure that the renderer does not crash when navigating a frame that has a | 3142 // Ensure that the renderer does not crash when navigating a frame that has a |
3212 // sibling RemoteFrame. See https://crbug.com/426953. | 3143 // sibling RemoteFrame. See https://crbug.com/426953. |
3213 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 3144 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
3214 NavigateWithSiblingRemoteFrame) { | 3145 NavigateWithSiblingRemoteFrame) { |
3215 GURL main_url( | 3146 GURL main_url( |
3216 embedded_test_server()->GetURL("/frame_tree/page_with_two_frames.html")); | 3147 embedded_test_server()->GetURL("/frame_tree/page_with_two_frames.html")); |
3217 NavigateToURL(shell(), main_url); | 3148 NavigateToURL(shell(), main_url); |
3218 | 3149 |
3219 // It is safe to obtain the root frame tree node here, as it doesn't change. | 3150 // It is safe to obtain the root frame tree node here, as it doesn't change. |
3220 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 3151 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
3221 ->GetFrameTree() | |
3222 ->root(); | |
3223 TestNavigationObserver observer(shell()->web_contents()); | 3152 TestNavigationObserver observer(shell()->web_contents()); |
3224 | 3153 |
3225 // Make sure the first frame is out of process. | 3154 // Make sure the first frame is out of process. |
3226 ASSERT_EQ(2U, root->child_count()); | 3155 ASSERT_EQ(2U, root->child_count()); |
3227 FrameTreeNode* node2 = root->child_at(0); | 3156 FrameTreeNode* node2 = root->child_at(0); |
3228 EXPECT_NE(root->current_frame_host()->GetSiteInstance(), | 3157 EXPECT_NE(root->current_frame_host()->GetSiteInstance(), |
3229 node2->current_frame_host()->GetSiteInstance()); | 3158 node2->current_frame_host()->GetSiteInstance()); |
3230 | 3159 |
3231 // Make sure the second frame is in the parent's process. | 3160 // Make sure the second frame is in the parent's process. |
3232 FrameTreeNode* node3 = root->child_at(1); | 3161 FrameTreeNode* node3 = root->child_at(1); |
(...skipping 13 matching lines...) Expand all Loading... |
3246 // Ensure that the renderer does not crash when a local frame with a remote | 3175 // Ensure that the renderer does not crash when a local frame with a remote |
3247 // parent frame is swapped from local to remote, then back to local again. | 3176 // parent frame is swapped from local to remote, then back to local again. |
3248 // See https://crbug.com/585654. | 3177 // See https://crbug.com/585654. |
3249 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 3178 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
3250 NavigateSiblingsToSameProcess) { | 3179 NavigateSiblingsToSameProcess) { |
3251 GURL main_url( | 3180 GURL main_url( |
3252 embedded_test_server()->GetURL("/frame_tree/page_with_two_frames.html")); | 3181 embedded_test_server()->GetURL("/frame_tree/page_with_two_frames.html")); |
3253 NavigateToURL(shell(), main_url); | 3182 NavigateToURL(shell(), main_url); |
3254 | 3183 |
3255 // It is safe to obtain the root frame tree node here, as it doesn't change. | 3184 // It is safe to obtain the root frame tree node here, as it doesn't change. |
3256 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 3185 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
3257 ->GetFrameTree() | |
3258 ->root(); | |
3259 | 3186 |
3260 FrameTreeNode* node2 = root->child_at(0); | 3187 FrameTreeNode* node2 = root->child_at(0); |
3261 FrameTreeNode* node3 = root->child_at(1); | 3188 FrameTreeNode* node3 = root->child_at(1); |
3262 | 3189 |
3263 // Navigate the second iframe to the same process as the first. | 3190 // Navigate the second iframe to the same process as the first. |
3264 GURL frame_url = embedded_test_server()->GetURL("bar.com", "/title1.html"); | 3191 GURL frame_url = embedded_test_server()->GetURL("bar.com", "/title1.html"); |
3265 NavigateFrameToURL(node3, frame_url); | 3192 NavigateFrameToURL(node3, frame_url); |
3266 | 3193 |
3267 // Verify that they are in the same process. | 3194 // Verify that they are in the same process. |
3268 EXPECT_EQ(node2->current_frame_host()->GetSiteInstance(), | 3195 EXPECT_EQ(node2->current_frame_host()->GetSiteInstance(), |
(...skipping 24 matching lines...) Expand all Loading... |
3293 { | 3220 { |
3294 GURL main_url( | 3221 GURL main_url( |
3295 embedded_test_server()->GetURL("/frame_with_load_event.html")); | 3222 embedded_test_server()->GetURL("/frame_with_load_event.html")); |
3296 base::string16 expected_title(base::UTF8ToUTF16("LOADED")); | 3223 base::string16 expected_title(base::UTF8ToUTF16("LOADED")); |
3297 TitleWatcher title_watcher(shell()->web_contents(), expected_title); | 3224 TitleWatcher title_watcher(shell()->web_contents(), expected_title); |
3298 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 3225 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
3299 EXPECT_EQ(title_watcher.WaitAndGetTitle(), expected_title); | 3226 EXPECT_EQ(title_watcher.WaitAndGetTitle(), expected_title); |
3300 } | 3227 } |
3301 | 3228 |
3302 // It is safe to obtain the root frame tree node here, as it doesn't change. | 3229 // It is safe to obtain the root frame tree node here, as it doesn't change. |
3303 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 3230 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
3304 ->GetFrameTree() | |
3305 ->root(); | |
3306 | 3231 |
3307 // Load another cross-site page into the iframe and check that the load event | 3232 // Load another cross-site page into the iframe and check that the load event |
3308 // is fired. | 3233 // is fired. |
3309 { | 3234 { |
3310 GURL foo_url(embedded_test_server()->GetURL("foo.com", "/title1.html")); | 3235 GURL foo_url(embedded_test_server()->GetURL("foo.com", "/title1.html")); |
3311 base::string16 expected_title(base::UTF8ToUTF16("LOADEDLOADED")); | 3236 base::string16 expected_title(base::UTF8ToUTF16("LOADEDLOADED")); |
3312 TitleWatcher title_watcher(shell()->web_contents(), expected_title); | 3237 TitleWatcher title_watcher(shell()->web_contents(), expected_title); |
3313 TestNavigationObserver observer(shell()->web_contents()); | 3238 TestNavigationObserver observer(shell()->web_contents()); |
3314 NavigateFrameToURL(root->child_at(0), foo_url); | 3239 NavigateFrameToURL(root->child_at(0), foo_url); |
3315 EXPECT_TRUE(observer.last_navigation_succeeded()); | 3240 EXPECT_TRUE(observer.last_navigation_succeeded()); |
3316 EXPECT_EQ(foo_url, observer.last_navigation_url()); | 3241 EXPECT_EQ(foo_url, observer.last_navigation_url()); |
3317 EXPECT_EQ(title_watcher.WaitAndGetTitle(), expected_title); | 3242 EXPECT_EQ(title_watcher.WaitAndGetTitle(), expected_title); |
3318 } | 3243 } |
3319 } | 3244 } |
3320 | 3245 |
3321 // Check that postMessage can be routed between cross-site iframes. | 3246 // Check that postMessage can be routed between cross-site iframes. |
3322 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, SubframePostMessage) { | 3247 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, SubframePostMessage) { |
3323 GURL main_url(embedded_test_server()->GetURL( | 3248 GURL main_url(embedded_test_server()->GetURL( |
3324 "/frame_tree/page_with_post_message_frames.html")); | 3249 "/frame_tree/page_with_post_message_frames.html")); |
3325 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 3250 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
3326 | 3251 |
3327 // It is safe to obtain the root frame tree node here, as it doesn't change. | 3252 // It is safe to obtain the root frame tree node here, as it doesn't change. |
3328 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 3253 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
3329 ->GetFrameTree() | |
3330 ->root(); | |
3331 | 3254 |
3332 ASSERT_EQ(2U, root->child_count()); | 3255 ASSERT_EQ(2U, root->child_count()); |
3333 | 3256 |
3334 // Verify the frames start at correct URLs. First frame should be | 3257 // Verify the frames start at correct URLs. First frame should be |
3335 // same-site; second frame should be cross-site. | 3258 // same-site; second frame should be cross-site. |
3336 GURL same_site_url(embedded_test_server()->GetURL("/post_message.html")); | 3259 GURL same_site_url(embedded_test_server()->GetURL("/post_message.html")); |
3337 EXPECT_EQ(same_site_url, root->child_at(0)->current_url()); | 3260 EXPECT_EQ(same_site_url, root->child_at(0)->current_url()); |
3338 GURL foo_url(embedded_test_server()->GetURL("foo.com", | 3261 GURL foo_url(embedded_test_server()->GetURL("foo.com", |
3339 "/post_message.html")); | 3262 "/post_message.html")); |
3340 EXPECT_EQ(foo_url, root->child_at(1)->current_url()); | 3263 EXPECT_EQ(foo_url, root->child_at(1)->current_url()); |
(...skipping 25 matching lines...) Expand all Loading... |
3366 | 3289 |
3367 // Check that postMessage can be sent from a subframe on a cross-process opener | 3290 // Check that postMessage can be sent from a subframe on a cross-process opener |
3368 // tab, and that its event.source points to a valid proxy. | 3291 // tab, and that its event.source points to a valid proxy. |
3369 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 3292 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
3370 PostMessageWithSubframeOnOpenerChain) { | 3293 PostMessageWithSubframeOnOpenerChain) { |
3371 GURL main_url(embedded_test_server()->GetURL( | 3294 GURL main_url(embedded_test_server()->GetURL( |
3372 "a.com", "/frame_tree/page_with_post_message_frames.html")); | 3295 "a.com", "/frame_tree/page_with_post_message_frames.html")); |
3373 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 3296 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
3374 | 3297 |
3375 // It is safe to obtain the root frame tree node here, as it doesn't change. | 3298 // It is safe to obtain the root frame tree node here, as it doesn't change. |
3376 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 3299 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
3377 ->GetFrameTree() | |
3378 ->root(); | |
3379 | 3300 |
3380 ASSERT_EQ(2U, root->child_count()); | 3301 ASSERT_EQ(2U, root->child_count()); |
3381 | 3302 |
3382 // Verify the initial state of the world. First frame should be same-site; | 3303 // Verify the initial state of the world. First frame should be same-site; |
3383 // second frame should be cross-site. | 3304 // second frame should be cross-site. |
3384 EXPECT_EQ( | 3305 EXPECT_EQ( |
3385 " Site A ------------ proxies for B\n" | 3306 " Site A ------------ proxies for B\n" |
3386 " |--Site A ------- proxies for B\n" | 3307 " |--Site A ------- proxies for B\n" |
3387 " +--Site B ------- proxies for A\n" | 3308 " +--Site B ------- proxies for A\n" |
3388 "Where A = http://a.com/\n" | 3309 "Where A = http://a.com/\n" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3477 | 3398 |
3478 // Check that parent.frames[num] references correct sibling frames when the | 3399 // Check that parent.frames[num] references correct sibling frames when the |
3479 // parent is remote. See https://crbug.com/478792. | 3400 // parent is remote. See https://crbug.com/478792. |
3480 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, IndexedFrameAccess) { | 3401 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, IndexedFrameAccess) { |
3481 // Start on a page with three same-site subframes. | 3402 // Start on a page with three same-site subframes. |
3482 GURL main_url( | 3403 GURL main_url( |
3483 embedded_test_server()->GetURL("a.com", "/frame_tree/top.html")); | 3404 embedded_test_server()->GetURL("a.com", "/frame_tree/top.html")); |
3484 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 3405 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
3485 | 3406 |
3486 // It is safe to obtain the root frame tree node here, as it doesn't change. | 3407 // It is safe to obtain the root frame tree node here, as it doesn't change. |
3487 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 3408 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
3488 ->GetFrameTree() | |
3489 ->root(); | |
3490 ASSERT_EQ(3U, root->child_count()); | 3409 ASSERT_EQ(3U, root->child_count()); |
3491 FrameTreeNode* child0 = root->child_at(0); | 3410 FrameTreeNode* child0 = root->child_at(0); |
3492 FrameTreeNode* child1 = root->child_at(1); | 3411 FrameTreeNode* child1 = root->child_at(1); |
3493 FrameTreeNode* child2 = root->child_at(2); | 3412 FrameTreeNode* child2 = root->child_at(2); |
3494 | 3413 |
3495 // Send each of the frames to a different site. Each new renderer will first | 3414 // Send each of the frames to a different site. Each new renderer will first |
3496 // create proxies for the parent and two sibling subframes and then create | 3415 // create proxies for the parent and two sibling subframes and then create |
3497 // and insert the new RenderFrame into the frame tree. | 3416 // and insert the new RenderFrame into the frame tree. |
3498 GURL b_url(embedded_test_server()->GetURL("b.com", "/post_message.html")); | 3417 GURL b_url(embedded_test_server()->GetURL("b.com", "/post_message.html")); |
3499 GURL c_url(embedded_test_server()->GetURL("c.com", "/post_message.html")); | 3418 GURL c_url(embedded_test_server()->GetURL("c.com", "/post_message.html")); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3549 EXPECT_EQ(1, GetReceivedMessages(child0)); | 3468 EXPECT_EQ(1, GetReceivedMessages(child0)); |
3550 EXPECT_EQ(2, GetReceivedMessages(child1)); | 3469 EXPECT_EQ(2, GetReceivedMessages(child1)); |
3551 EXPECT_EQ(1, GetReceivedMessages(child2)); | 3470 EXPECT_EQ(1, GetReceivedMessages(child2)); |
3552 } | 3471 } |
3553 | 3472 |
3554 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, RFPHDestruction) { | 3473 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, RFPHDestruction) { |
3555 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); | 3474 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
3556 NavigateToURL(shell(), main_url); | 3475 NavigateToURL(shell(), main_url); |
3557 | 3476 |
3558 // It is safe to obtain the root frame tree node here, as it doesn't change. | 3477 // It is safe to obtain the root frame tree node here, as it doesn't change. |
3559 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 3478 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
3560 ->GetFrameTree() | |
3561 ->root(); | |
3562 | 3479 |
3563 TestNavigationObserver observer(shell()->web_contents()); | 3480 TestNavigationObserver observer(shell()->web_contents()); |
3564 | 3481 |
3565 // Load cross-site page into iframe. | 3482 // Load cross-site page into iframe. |
3566 FrameTreeNode* child = root->child_at(0); | 3483 FrameTreeNode* child = root->child_at(0); |
3567 GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html"); | 3484 GURL url = embedded_test_server()->GetURL("foo.com", "/title2.html"); |
3568 NavigateFrameToURL(root->child_at(0), url); | 3485 NavigateFrameToURL(root->child_at(0), url); |
3569 EXPECT_TRUE(observer.last_navigation_succeeded()); | 3486 EXPECT_TRUE(observer.last_navigation_succeeded()); |
3570 EXPECT_EQ(url, observer.last_navigation_url()); | 3487 EXPECT_EQ(url, observer.last_navigation_url()); |
3571 EXPECT_EQ( | 3488 EXPECT_EQ( |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3610 "Where A = http://127.0.0.1/", | 3527 "Where A = http://127.0.0.1/", |
3611 DepictFrameTree(root)); | 3528 DepictFrameTree(root)); |
3612 } | 3529 } |
3613 | 3530 |
3614 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OpenPopupWithRemoteParent) { | 3531 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OpenPopupWithRemoteParent) { |
3615 GURL main_url( | 3532 GURL main_url( |
3616 embedded_test_server()->GetURL("a.com", "/site_per_process_main.html")); | 3533 embedded_test_server()->GetURL("a.com", "/site_per_process_main.html")); |
3617 NavigateToURL(shell(), main_url); | 3534 NavigateToURL(shell(), main_url); |
3618 | 3535 |
3619 // It is safe to obtain the root frame tree node here, as it doesn't change. | 3536 // It is safe to obtain the root frame tree node here, as it doesn't change. |
3620 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 3537 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
3621 ->GetFrameTree() | |
3622 ->root(); | |
3623 | 3538 |
3624 // Navigate first child cross-site. | 3539 // Navigate first child cross-site. |
3625 GURL frame_url(embedded_test_server()->GetURL("b.com", "/title1.html")); | 3540 GURL frame_url(embedded_test_server()->GetURL("b.com", "/title1.html")); |
3626 NavigateFrameToURL(root->child_at(0), frame_url); | 3541 NavigateFrameToURL(root->child_at(0), frame_url); |
3627 | 3542 |
3628 // Open a popup from the first child. | 3543 // Open a popup from the first child. |
3629 Shell* new_shell = OpenPopup(root->child_at(0)->current_frame_host(), | 3544 Shell* new_shell = OpenPopup(root->child_at(0)->current_frame_host(), |
3630 GURL(url::kAboutBlankURL), ""); | 3545 GURL(url::kAboutBlankURL), ""); |
3631 EXPECT_TRUE(new_shell); | 3546 EXPECT_TRUE(new_shell); |
3632 | 3547 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3714 | 3629 |
3715 // Verify that named frames are discoverable from their opener's ancestors. | 3630 // Verify that named frames are discoverable from their opener's ancestors. |
3716 // See https://crbug.com/511474. | 3631 // See https://crbug.com/511474. |
3717 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 3632 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
3718 DiscoverNamedFrameFromAncestorOfOpener) { | 3633 DiscoverNamedFrameFromAncestorOfOpener) { |
3719 GURL main_url( | 3634 GURL main_url( |
3720 embedded_test_server()->GetURL("a.com", "/site_per_process_main.html")); | 3635 embedded_test_server()->GetURL("a.com", "/site_per_process_main.html")); |
3721 NavigateToURL(shell(), main_url); | 3636 NavigateToURL(shell(), main_url); |
3722 | 3637 |
3723 // It is safe to obtain the root frame tree node here, as it doesn't change. | 3638 // It is safe to obtain the root frame tree node here, as it doesn't change. |
3724 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 3639 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
3725 ->GetFrameTree() | |
3726 ->root(); | |
3727 | 3640 |
3728 // Navigate first child cross-site. | 3641 // Navigate first child cross-site. |
3729 GURL frame_url(embedded_test_server()->GetURL("b.com", "/title1.html")); | 3642 GURL frame_url(embedded_test_server()->GetURL("b.com", "/title1.html")); |
3730 NavigateFrameToURL(root->child_at(0), frame_url); | 3643 NavigateFrameToURL(root->child_at(0), frame_url); |
3731 | 3644 |
3732 // Open a popup named "foo" from the first child. | 3645 // Open a popup named "foo" from the first child. |
3733 Shell* foo_shell = OpenPopup(root->child_at(0)->current_frame_host(), | 3646 Shell* foo_shell = OpenPopup(root->child_at(0)->current_frame_host(), |
3734 GURL(url::kAboutBlankURL), "foo"); | 3647 GURL(url::kAboutBlankURL), "foo"); |
3735 EXPECT_TRUE(foo_shell); | 3648 EXPECT_TRUE(foo_shell); |
3736 | 3649 |
(...skipping 30 matching lines...) Expand all Loading... |
3767 // still be discoverable from its opener's ancestors. Also, instead of using | 3680 // still be discoverable from its opener's ancestors. Also, instead of using |
3768 // an opener's ancestor, this test uses a popup with same origin as that | 3681 // an opener's ancestor, this test uses a popup with same origin as that |
3769 // ancestor. See https://crbug.com/511474. | 3682 // ancestor. See https://crbug.com/511474. |
3770 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 3683 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
3771 DiscoverFrameAfterSettingWindowName) { | 3684 DiscoverFrameAfterSettingWindowName) { |
3772 GURL main_url( | 3685 GURL main_url( |
3773 embedded_test_server()->GetURL("a.com", "/site_per_process_main.html")); | 3686 embedded_test_server()->GetURL("a.com", "/site_per_process_main.html")); |
3774 NavigateToURL(shell(), main_url); | 3687 NavigateToURL(shell(), main_url); |
3775 | 3688 |
3776 // It is safe to obtain the root frame tree node here, as it doesn't change. | 3689 // It is safe to obtain the root frame tree node here, as it doesn't change. |
3777 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 3690 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
3778 ->GetFrameTree() | |
3779 ->root(); | |
3780 | 3691 |
3781 // Open a same-site popup from the main frame. | 3692 // Open a same-site popup from the main frame. |
3782 GURL a_com_url(embedded_test_server()->GetURL("a.com", "/title3.html")); | 3693 GURL a_com_url(embedded_test_server()->GetURL("a.com", "/title3.html")); |
3783 Shell* a_com_shell = | 3694 Shell* a_com_shell = |
3784 OpenPopup(root->child_at(0)->current_frame_host(), a_com_url, ""); | 3695 OpenPopup(root->child_at(0)->current_frame_host(), a_com_url, ""); |
3785 EXPECT_TRUE(a_com_shell); | 3696 EXPECT_TRUE(a_com_shell); |
3786 | 3697 |
3787 // Navigate first child on main frame cross-site. | 3698 // Navigate first child on main frame cross-site. |
3788 GURL frame_url(embedded_test_server()->GetURL("b.com", "/title1.html")); | 3699 GURL frame_url(embedded_test_server()->GetURL("b.com", "/title1.html")); |
3789 NavigateFrameToURL(root->child_at(0), frame_url); | 3700 NavigateFrameToURL(root->child_at(0), frame_url); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3827 // ^ | | 3738 // ^ | |
3828 // +--------------------+ | 3739 // +--------------------+ |
3829 // | 3740 // |
3830 // The sites are carefully set up so that both opener updates are cross-process | 3741 // The sites are carefully set up so that both opener updates are cross-process |
3831 // but still allowed by Blink's navigation checks. | 3742 // but still allowed by Blink's navigation checks. |
3832 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, UpdateSubframeOpener) { | 3743 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, UpdateSubframeOpener) { |
3833 GURL main_url = embedded_test_server()->GetURL( | 3744 GURL main_url = embedded_test_server()->GetURL( |
3834 "foo.com", "/frame_tree/page_with_two_frames.html"); | 3745 "foo.com", "/frame_tree/page_with_two_frames.html"); |
3835 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 3746 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
3836 | 3747 |
3837 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 3748 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
3838 ->GetFrameTree() | |
3839 ->root(); | |
3840 EXPECT_EQ(2U, root->child_count()); | 3749 EXPECT_EQ(2U, root->child_count()); |
3841 | 3750 |
3842 // From the top frame, open a popup and navigate it to a cross-site page with | 3751 // From the top frame, open a popup and navigate it to a cross-site page with |
3843 // two subframes. | 3752 // two subframes. |
3844 Shell* popup_shell = | 3753 Shell* popup_shell = |
3845 OpenPopup(shell()->web_contents(), GURL(url::kAboutBlankURL), "popup"); | 3754 OpenPopup(shell()->web_contents(), GURL(url::kAboutBlankURL), "popup"); |
3846 EXPECT_TRUE(popup_shell); | 3755 EXPECT_TRUE(popup_shell); |
3847 GURL popup_url(embedded_test_server()->GetURL( | 3756 GURL popup_url(embedded_test_server()->GetURL( |
3848 "bar.com", "/frame_tree/page_with_post_message_frames.html")); | 3757 "bar.com", "/frame_tree/page_with_post_message_frames.html")); |
3849 NavigateToURL(popup_shell, popup_url); | 3758 NavigateToURL(popup_shell, popup_url); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3902 | 3811 |
3903 // Check that when a subframe navigates to a new SiteInstance, the new | 3812 // Check that when a subframe navigates to a new SiteInstance, the new |
3904 // SiteInstance will get a proxy for the opener of subframe's parent. I.e., | 3813 // SiteInstance will get a proxy for the opener of subframe's parent. I.e., |
3905 // accessing parent.opener from the subframe should still work after a | 3814 // accessing parent.opener from the subframe should still work after a |
3906 // cross-process navigation. | 3815 // cross-process navigation. |
3907 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 3816 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
3908 NavigatingSubframePreservesOpenerInParent) { | 3817 NavigatingSubframePreservesOpenerInParent) { |
3909 GURL main_url = embedded_test_server()->GetURL("a.com", "/post_message.html"); | 3818 GURL main_url = embedded_test_server()->GetURL("a.com", "/post_message.html"); |
3910 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 3819 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
3911 | 3820 |
3912 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 3821 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
3913 ->GetFrameTree() | |
3914 ->root(); | |
3915 | 3822 |
3916 // Open a popup with a cross-site page that has a subframe. | 3823 // Open a popup with a cross-site page that has a subframe. |
3917 GURL popup_url(embedded_test_server()->GetURL( | 3824 GURL popup_url(embedded_test_server()->GetURL( |
3918 "b.com", "/cross_site_iframe_factory.html?b(b)")); | 3825 "b.com", "/cross_site_iframe_factory.html?b(b)")); |
3919 Shell* popup_shell = OpenPopup(shell()->web_contents(), popup_url, "popup"); | 3826 Shell* popup_shell = OpenPopup(shell()->web_contents(), popup_url, "popup"); |
3920 EXPECT_TRUE(popup_shell); | 3827 EXPECT_TRUE(popup_shell); |
3921 FrameTreeNode* popup_root = | 3828 FrameTreeNode* popup_root = |
3922 static_cast<WebContentsImpl*>(popup_shell->web_contents()) | 3829 static_cast<WebContentsImpl*>(popup_shell->web_contents()) |
3923 ->GetFrameTree() | 3830 ->GetFrameTree() |
3924 ->root(); | 3831 ->root(); |
(...skipping 24 matching lines...) Expand all Loading... |
3949 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); | 3856 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); |
3950 } | 3857 } |
3951 | 3858 |
3952 // Check that if a subframe has an opener, that opener is preserved when the | 3859 // Check that if a subframe has an opener, that opener is preserved when the |
3953 // subframe navigates cross-site. | 3860 // subframe navigates cross-site. |
3954 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, NavigateSubframeWithOpener) { | 3861 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, NavigateSubframeWithOpener) { |
3955 GURL main_url(embedded_test_server()->GetURL( | 3862 GURL main_url(embedded_test_server()->GetURL( |
3956 "foo.com", "/frame_tree/page_with_two_frames.html")); | 3863 "foo.com", "/frame_tree/page_with_two_frames.html")); |
3957 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 3864 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
3958 | 3865 |
3959 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 3866 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
3960 ->GetFrameTree() | |
3961 ->root(); | |
3962 EXPECT_EQ( | 3867 EXPECT_EQ( |
3963 " Site A ------------ proxies for B\n" | 3868 " Site A ------------ proxies for B\n" |
3964 " |--Site B ------- proxies for A\n" | 3869 " |--Site B ------- proxies for A\n" |
3965 " +--Site A ------- proxies for B\n" | 3870 " +--Site A ------- proxies for B\n" |
3966 "Where A = http://foo.com/\n" | 3871 "Where A = http://foo.com/\n" |
3967 " B = http://bar.com/", | 3872 " B = http://bar.com/", |
3968 DepictFrameTree(root)); | 3873 DepictFrameTree(root)); |
3969 | 3874 |
3970 // Update the first (cross-site) subframe's opener to root frame. | 3875 // Update the first (cross-site) subframe's opener to root frame. |
3971 bool success = false; | 3876 bool success = false; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4016 // RenderFrameProxy is created for that subframe in another renderer process. | 3921 // RenderFrameProxy is created for that subframe in another renderer process. |
4017 // Similar to NavigateSubframeWithOpener, but this test verifies the subframe | 3922 // Similar to NavigateSubframeWithOpener, but this test verifies the subframe |
4018 // opener plumbing for FrameMsg_NewFrameProxy, whereas | 3923 // opener plumbing for FrameMsg_NewFrameProxy, whereas |
4019 // NavigateSubframeWithOpener targets FrameMsg_NewFrame. | 3924 // NavigateSubframeWithOpener targets FrameMsg_NewFrame. |
4020 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 3925 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
4021 NewRenderFrameProxyPreservesOpener) { | 3926 NewRenderFrameProxyPreservesOpener) { |
4022 GURL main_url( | 3927 GURL main_url( |
4023 embedded_test_server()->GetURL("foo.com", "/post_message.html")); | 3928 embedded_test_server()->GetURL("foo.com", "/post_message.html")); |
4024 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 3929 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
4025 | 3930 |
4026 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 3931 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
4027 ->GetFrameTree() | |
4028 ->root(); | |
4029 | 3932 |
4030 // Open a popup with a cross-site page that has two subframes. | 3933 // Open a popup with a cross-site page that has two subframes. |
4031 GURL popup_url(embedded_test_server()->GetURL( | 3934 GURL popup_url(embedded_test_server()->GetURL( |
4032 "bar.com", "/frame_tree/page_with_post_message_frames.html")); | 3935 "bar.com", "/frame_tree/page_with_post_message_frames.html")); |
4033 Shell* popup_shell = OpenPopup(shell()->web_contents(), popup_url, "popup"); | 3936 Shell* popup_shell = OpenPopup(shell()->web_contents(), popup_url, "popup"); |
4034 EXPECT_TRUE(popup_shell); | 3937 EXPECT_TRUE(popup_shell); |
4035 FrameTreeNode* popup_root = | 3938 FrameTreeNode* popup_root = |
4036 static_cast<WebContentsImpl*>(popup_shell->web_contents()) | 3939 static_cast<WebContentsImpl*>(popup_shell->web_contents()) |
4037 ->GetFrameTree() | 3940 ->GetFrameTree() |
4038 ->root(); | 3941 ->root(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4103 DISABLED_RenderViewHostPendingDeletionIsNotReused | 4006 DISABLED_RenderViewHostPendingDeletionIsNotReused |
4104 #else | 4007 #else |
4105 #define MAYBE_RenderViewHostPendingDeletionIsNotReused \ | 4008 #define MAYBE_RenderViewHostPendingDeletionIsNotReused \ |
4106 RenderViewHostPendingDeletionIsNotReused | 4009 RenderViewHostPendingDeletionIsNotReused |
4107 #endif | 4010 #endif |
4108 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 4011 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
4109 MAYBE_RenderViewHostPendingDeletionIsNotReused) { | 4012 MAYBE_RenderViewHostPendingDeletionIsNotReused) { |
4110 GURL a_url(embedded_test_server()->GetURL("a.com", "/title1.html")); | 4013 GURL a_url(embedded_test_server()->GetURL("a.com", "/title1.html")); |
4111 NavigateToURL(shell(), a_url); | 4014 NavigateToURL(shell(), a_url); |
4112 | 4015 |
4113 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 4016 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
4114 ->GetFrameTree() | |
4115 ->root(); | |
4116 RenderFrameHostImpl* rfh = root->current_frame_host(); | 4017 RenderFrameHostImpl* rfh = root->current_frame_host(); |
4117 RenderViewHostImpl* rvh = rfh->render_view_host(); | 4018 RenderViewHostImpl* rvh = rfh->render_view_host(); |
4118 int rvh_routing_id = rvh->GetRoutingID(); | 4019 int rvh_routing_id = rvh->GetRoutingID(); |
4119 SiteInstanceImpl* site_instance = rfh->GetSiteInstance(); | 4020 SiteInstanceImpl* site_instance = rfh->GetSiteInstance(); |
4120 RenderFrameDeletedObserver deleted_observer(rfh); | 4021 RenderFrameDeletedObserver deleted_observer(rfh); |
4121 | 4022 |
4122 // Install a BrowserMessageFilter to drop SwapOut ACK messages in A's | 4023 // Install a BrowserMessageFilter to drop SwapOut ACK messages in A's |
4123 // process. | 4024 // process. |
4124 scoped_refptr<SwapoutACKMessageFilter> filter = new SwapoutACKMessageFilter(); | 4025 scoped_refptr<SwapoutACKMessageFilter> filter = new SwapoutACKMessageFilter(); |
4125 rfh->GetProcess()->AddFilter(filter.get()); | 4026 rfh->GetProcess()->AddFilter(filter.get()); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4202 // Check that when a cross-process frame acquires focus, the old focused frame | 4103 // Check that when a cross-process frame acquires focus, the old focused frame |
4203 // loses focus and fires blur events. Starting on a page with a cross-site | 4104 // loses focus and fires blur events. Starting on a page with a cross-site |
4204 // subframe, simulate mouse clicks to switch focus from root frame to subframe | 4105 // subframe, simulate mouse clicks to switch focus from root frame to subframe |
4205 // and then back to root frame. | 4106 // and then back to root frame. |
4206 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 4107 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
4207 CrossProcessFocusChangeFiresBlurEvents) { | 4108 CrossProcessFocusChangeFiresBlurEvents) { |
4208 GURL main_url( | 4109 GURL main_url( |
4209 embedded_test_server()->GetURL("a.com", "/page_with_input_field.html")); | 4110 embedded_test_server()->GetURL("a.com", "/page_with_input_field.html")); |
4210 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 4111 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
4211 | 4112 |
4212 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 4113 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
4213 ->GetFrameTree() | |
4214 ->root(); | |
4215 | 4114 |
4216 EXPECT_EQ( | 4115 EXPECT_EQ( |
4217 " Site A ------------ proxies for B\n" | 4116 " Site A ------------ proxies for B\n" |
4218 " +--Site B ------- proxies for A\n" | 4117 " +--Site B ------- proxies for A\n" |
4219 "Where A = http://a.com/\n" | 4118 "Where A = http://a.com/\n" |
4220 " B = http://b.com/", | 4119 " B = http://b.com/", |
4221 DepictFrameTree(root)); | 4120 DepictFrameTree(root)); |
4222 | 4121 |
4223 // Focus the main frame's text field. The return value "input-focus" | 4122 // Focus the main frame's text field. The return value "input-focus" |
4224 // indicates that the focus event was fired correctly. | 4123 // indicates that the focus event was fired correctly. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4264 | 4163 |
4265 // Check that when a cross-process subframe is focused, its parent's | 4164 // Check that when a cross-process subframe is focused, its parent's |
4266 // document.activeElement correctly returns the corresponding <iframe> element. | 4165 // document.activeElement correctly returns the corresponding <iframe> element. |
4267 // The test sets up an A-embed-B-embed-C page and shifts focus A->B->A->C, | 4166 // The test sets up an A-embed-B-embed-C page and shifts focus A->B->A->C, |
4268 // checking document.activeElement after each change. | 4167 // checking document.activeElement after each change. |
4269 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DocumentActiveElement) { | 4168 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DocumentActiveElement) { |
4270 GURL main_url(embedded_test_server()->GetURL( | 4169 GURL main_url(embedded_test_server()->GetURL( |
4271 "a.com", "/cross_site_iframe_factory.html?a(b(c))")); | 4170 "a.com", "/cross_site_iframe_factory.html?a(b(c))")); |
4272 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 4171 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
4273 | 4172 |
4274 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 4173 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
4275 ->GetFrameTree() | |
4276 ->root(); | |
4277 | 4174 |
4278 EXPECT_EQ( | 4175 EXPECT_EQ( |
4279 " Site A ------------ proxies for B C\n" | 4176 " Site A ------------ proxies for B C\n" |
4280 " +--Site B ------- proxies for A C\n" | 4177 " +--Site B ------- proxies for A C\n" |
4281 " +--Site C -- proxies for A B\n" | 4178 " +--Site C -- proxies for A B\n" |
4282 "Where A = http://a.com/\n" | 4179 "Where A = http://a.com/\n" |
4283 " B = http://b.com/\n" | 4180 " B = http://b.com/\n" |
4284 " C = http://c.com/", | 4181 " C = http://c.com/", |
4285 DepictFrameTree(root)); | 4182 DepictFrameTree(root)); |
4286 | 4183 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4343 // The test builds a page with four cross-site frames and then focuses them one | 4240 // The test builds a page with four cross-site frames and then focuses them one |
4344 // by one, checking the value of document.hasFocus() in all frames. For any | 4241 // by one, checking the value of document.hasFocus() in all frames. For any |
4345 // given focused frame, document.hasFocus() should return true for that frame | 4242 // given focused frame, document.hasFocus() should return true for that frame |
4346 // and all its ancestor frames. | 4243 // and all its ancestor frames. |
4347 // Disabled due to flakes; see https://crbug.com/559273. | 4244 // Disabled due to flakes; see https://crbug.com/559273. |
4348 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DISABLED_DocumentHasFocus) { | 4245 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DISABLED_DocumentHasFocus) { |
4349 GURL main_url(embedded_test_server()->GetURL( | 4246 GURL main_url(embedded_test_server()->GetURL( |
4350 "a.com", "/cross_site_iframe_factory.html?a(b(c),d)")); | 4247 "a.com", "/cross_site_iframe_factory.html?a(b(c),d)")); |
4351 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 4248 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
4352 | 4249 |
4353 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 4250 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
4354 ->GetFrameTree() | |
4355 ->root(); | |
4356 | 4251 |
4357 EXPECT_EQ( | 4252 EXPECT_EQ( |
4358 " Site A ------------ proxies for B C D\n" | 4253 " Site A ------------ proxies for B C D\n" |
4359 " |--Site B ------- proxies for A C D\n" | 4254 " |--Site B ------- proxies for A C D\n" |
4360 " | +--Site C -- proxies for A B D\n" | 4255 " | +--Site C -- proxies for A B D\n" |
4361 " +--Site D ------- proxies for A B C\n" | 4256 " +--Site D ------- proxies for A B C\n" |
4362 "Where A = http://a.com/\n" | 4257 "Where A = http://a.com/\n" |
4363 " B = http://b.com/\n" | 4258 " B = http://b.com/\n" |
4364 " C = http://c.com/\n" | 4259 " C = http://c.com/\n" |
4365 " D = http://d.com/", | 4260 " D = http://d.com/", |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4411 EXPECT_FALSE(document_has_focus(grandchild)); | 4306 EXPECT_FALSE(document_has_focus(grandchild)); |
4412 EXPECT_TRUE(document_has_focus(child2)); | 4307 EXPECT_TRUE(document_has_focus(child2)); |
4413 } | 4308 } |
4414 | 4309 |
4415 // Check that window.focus works for cross-process subframes. | 4310 // Check that window.focus works for cross-process subframes. |
4416 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, SubframeWindowFocus) { | 4311 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, SubframeWindowFocus) { |
4417 GURL main_url(embedded_test_server()->GetURL( | 4312 GURL main_url(embedded_test_server()->GetURL( |
4418 "a.com", "/cross_site_iframe_factory.html?a(b,c)")); | 4313 "a.com", "/cross_site_iframe_factory.html?a(b,c)")); |
4419 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 4314 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
4420 | 4315 |
4421 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 4316 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
4422 ->GetFrameTree() | |
4423 ->root(); | |
4424 | 4317 |
4425 EXPECT_EQ( | 4318 EXPECT_EQ( |
4426 " Site A ------------ proxies for B C\n" | 4319 " Site A ------------ proxies for B C\n" |
4427 " |--Site B ------- proxies for A C\n" | 4320 " |--Site B ------- proxies for A C\n" |
4428 " +--Site C ------- proxies for A B\n" | 4321 " +--Site C ------- proxies for A B\n" |
4429 "Where A = http://a.com/\n" | 4322 "Where A = http://a.com/\n" |
4430 " B = http://b.com/\n" | 4323 " B = http://b.com/\n" |
4431 " C = http://c.com/", | 4324 " C = http://c.com/", |
4432 DepictFrameTree(root)); | 4325 DepictFrameTree(root)); |
4433 | 4326 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4550 | 4443 |
4551 // Verify that we receive a mouse cursor update message when we mouse over | 4444 // Verify that we receive a mouse cursor update message when we mouse over |
4552 // a text field contained in an out-of-process iframe. | 4445 // a text field contained in an out-of-process iframe. |
4553 // Fails under TSan. http://crbug.com/545237 | 4446 // Fails under TSan. http://crbug.com/545237 |
4554 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 4447 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
4555 DISABLED_CursorUpdateFromReceivedFromCrossSiteIframe) { | 4448 DISABLED_CursorUpdateFromReceivedFromCrossSiteIframe) { |
4556 GURL main_url(embedded_test_server()->GetURL( | 4449 GURL main_url(embedded_test_server()->GetURL( |
4557 "/frame_tree/page_with_positioned_frame.html")); | 4450 "/frame_tree/page_with_positioned_frame.html")); |
4558 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 4451 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
4559 | 4452 |
4560 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 4453 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
4561 ->GetFrameTree() | |
4562 ->root(); | |
4563 | 4454 |
4564 FrameTreeNode* child_node = root->child_at(0); | 4455 FrameTreeNode* child_node = root->child_at(0); |
4565 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 4456 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
4566 child_node->current_frame_host()->GetSiteInstance()); | 4457 child_node->current_frame_host()->GetSiteInstance()); |
4567 | 4458 |
4568 scoped_refptr<CursorMessageFilter> filter = new CursorMessageFilter(); | 4459 scoped_refptr<CursorMessageFilter> filter = new CursorMessageFilter(); |
4569 child_node->current_frame_host()->GetProcess()->AddFilter(filter.get()); | 4460 child_node->current_frame_host()->GetProcess()->AddFilter(filter.get()); |
4570 | 4461 |
4571 // Send a MouseMove to the subframe. The frame contains text, and moving the | 4462 // Send a MouseMove to the subframe. The frame contains text, and moving the |
4572 // mouse over it should cause the renderer to send a mouse cursor update. | 4463 // mouse over it should cause the renderer to send a mouse cursor update. |
4573 blink::WebMouseEvent mouse_event; | 4464 blink::WebMouseEvent mouse_event; |
4574 mouse_event.type = blink::WebInputEvent::MouseMove; | 4465 mouse_event.type = blink::WebInputEvent::MouseMove; |
4575 mouse_event.x = 60; | 4466 mouse_event.x = 60; |
4576 mouse_event.y = 60; | 4467 mouse_event.y = 60; |
4577 RenderWidgetHost* rwh_child = | 4468 RenderWidgetHost* rwh_child = |
4578 root->child_at(0)->current_frame_host()->GetRenderWidgetHost(); | 4469 root->child_at(0)->current_frame_host()->GetRenderWidgetHost(); |
4579 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( | 4470 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( |
4580 root->current_frame_host()->GetRenderWidgetHost()->GetView()); | 4471 root->current_frame_host()->GetRenderWidgetHost()->GetView()); |
4581 static_cast<WebContentsImpl*>(shell()->web_contents()) | 4472 web_contents()->GetInputEventRouter()->RouteMouseEvent(root_view, |
4582 ->GetInputEventRouter() | 4473 &mouse_event); |
4583 ->RouteMouseEvent(root_view, &mouse_event); | |
4584 | 4474 |
4585 // CursorMessageFilter::Wait() implicitly tests whether we receive a | 4475 // CursorMessageFilter::Wait() implicitly tests whether we receive a |
4586 // ViewHostMsg_SetCursor message from the renderer process, because it does | 4476 // ViewHostMsg_SetCursor message from the renderer process, because it does |
4587 // does not return otherwise. | 4477 // does not return otherwise. |
4588 filter->Wait(); | 4478 filter->Wait(); |
4589 EXPECT_EQ(filter->last_set_cursor_routing_id(), rwh_child->GetRoutingID()); | 4479 EXPECT_EQ(filter->last_set_cursor_routing_id(), rwh_child->GetRoutingID()); |
4590 } | 4480 } |
4591 #endif | 4481 #endif |
4592 | 4482 |
4593 // Tests that we are using the correct RenderFrameProxy when navigating an | 4483 // Tests that we are using the correct RenderFrameProxy when navigating an |
(...skipping 22 matching lines...) Expand all Loading... |
4616 #if defined(USE_AURA) | 4506 #if defined(USE_AURA) |
4617 // Browser process hit testing is not implemented on Android, and this test | 4507 // Browser process hit testing is not implemented on Android, and this test |
4618 // requires Aura for RenderWidgetHostViewAura::OnTouchEvent(). | 4508 // requires Aura for RenderWidgetHostViewAura::OnTouchEvent(). |
4619 // https://crbug.com/491334 | 4509 // https://crbug.com/491334 |
4620 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 4510 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
4621 SubframeTouchEventRouting) { | 4511 SubframeTouchEventRouting) { |
4622 GURL main_url(embedded_test_server()->GetURL( | 4512 GURL main_url(embedded_test_server()->GetURL( |
4623 "/frame_tree/page_with_positioned_nested_frames.html")); | 4513 "/frame_tree/page_with_positioned_nested_frames.html")); |
4624 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 4514 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
4625 | 4515 |
4626 WebContentsImpl* web_contents = | 4516 WebContentsImpl* contents = web_contents(); |
4627 static_cast<WebContentsImpl*>(shell()->web_contents()); | 4517 FrameTreeNode* root = contents->GetFrameTree()->root(); |
4628 FrameTreeNode* root = web_contents->GetFrameTree()->root(); | |
4629 ASSERT_EQ(1U, root->child_count()); | 4518 ASSERT_EQ(1U, root->child_count()); |
4630 | 4519 |
4631 GURL frame_url( | 4520 GURL frame_url( |
4632 embedded_test_server()->GetURL("b.com", "/page_with_touch_handler.html")); | 4521 embedded_test_server()->GetURL("b.com", "/page_with_touch_handler.html")); |
4633 NavigateFrameToURL(root->child_at(0), frame_url); | 4522 NavigateFrameToURL(root->child_at(0), frame_url); |
4634 | 4523 |
4635 // Synchronize with the child and parent renderers to guarantee that the | 4524 // Synchronize with the child and parent renderers to guarantee that the |
4636 // surface information required for event hit testing is ready. | 4525 // surface information required for event hit testing is ready. |
4637 RenderWidgetHostViewBase* child_rwhv = static_cast<RenderWidgetHostViewBase*>( | 4526 RenderWidgetHostViewBase* child_rwhv = static_cast<RenderWidgetHostViewBase*>( |
4638 root->child_at(0)->current_frame_host()->GetView()); | 4527 root->child_at(0)->current_frame_host()->GetView()); |
4639 SurfaceHitTestReadyNotifier notifier( | 4528 SurfaceHitTestReadyNotifier notifier( |
4640 static_cast<RenderWidgetHostViewChildFrame*>(child_rwhv)); | 4529 static_cast<RenderWidgetHostViewChildFrame*>(child_rwhv)); |
4641 notifier.WaitForSurfaceReady(); | 4530 notifier.WaitForSurfaceReady(); |
4642 | 4531 |
4643 // Simulate touch event to sub-frame. | 4532 // Simulate touch event to sub-frame. |
4644 gfx::Point child_center(150, 150); | 4533 gfx::Point child_center(150, 150); |
4645 auto rwhv = static_cast<RenderWidgetHostViewAura*>( | 4534 auto rwhv = static_cast<RenderWidgetHostViewAura*>( |
4646 web_contents->GetRenderWidgetHostView()); | 4535 contents->GetRenderWidgetHostView()); |
4647 ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, child_center, 0, 0, | 4536 ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, child_center, 0, 0, |
4648 ui::EventTimeForNow(), 30.f, 30.f, 0.f, 0.f); | 4537 ui::EventTimeForNow(), 30.f, 30.f, 0.f, 0.f); |
4649 rwhv->OnTouchEvent(&touch_event); | 4538 rwhv->OnTouchEvent(&touch_event); |
4650 | 4539 |
4651 // Verify touch handler in subframe was invoked | 4540 // Verify touch handler in subframe was invoked |
4652 std::string result; | 4541 std::string result; |
4653 EXPECT_TRUE(ExecuteScriptAndExtractString( | 4542 EXPECT_TRUE(ExecuteScriptAndExtractString( |
4654 root->child_at(0)->current_frame_host(), | 4543 root->child_at(0)->current_frame_host(), |
4655 "window.domAutomationController.send(getLastTouchEvent());", &result)); | 4544 "window.domAutomationController.send(getLastTouchEvent());", &result)); |
4656 EXPECT_EQ("touchstart", result); | 4545 EXPECT_EQ("touchstart", result); |
(...skipping 15 matching lines...) Expand all Loading... |
4672 #define MAYBE_SubframeGestureEventRouting DISABLED_SubframeGestureEventRouting | 4561 #define MAYBE_SubframeGestureEventRouting DISABLED_SubframeGestureEventRouting |
4673 #else | 4562 #else |
4674 #define MAYBE_SubframeGestureEventRouting SubframeGestureEventRouting | 4563 #define MAYBE_SubframeGestureEventRouting SubframeGestureEventRouting |
4675 #endif | 4564 #endif |
4676 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 4565 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
4677 MAYBE_SubframeGestureEventRouting) { | 4566 MAYBE_SubframeGestureEventRouting) { |
4678 GURL main_url(embedded_test_server()->GetURL( | 4567 GURL main_url(embedded_test_server()->GetURL( |
4679 "/frame_tree/page_with_positioned_nested_frames.html")); | 4568 "/frame_tree/page_with_positioned_nested_frames.html")); |
4680 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 4569 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
4681 | 4570 |
4682 WebContentsImpl* web_contents = | 4571 WebContentsImpl* contents = web_contents(); |
4683 static_cast<WebContentsImpl*>(shell()->web_contents()); | 4572 FrameTreeNode* root = contents->GetFrameTree()->root(); |
4684 FrameTreeNode* root = web_contents->GetFrameTree()->root(); | |
4685 ASSERT_EQ(1U, root->child_count()); | 4573 ASSERT_EQ(1U, root->child_count()); |
4686 | 4574 |
4687 GURL frame_url( | 4575 GURL frame_url( |
4688 embedded_test_server()->GetURL("b.com", "/page_with_click_handler.html")); | 4576 embedded_test_server()->GetURL("b.com", "/page_with_click_handler.html")); |
4689 NavigateFrameToURL(root->child_at(0), frame_url); | 4577 NavigateFrameToURL(root->child_at(0), frame_url); |
4690 auto child_frame_host = root->child_at(0)->current_frame_host(); | 4578 auto child_frame_host = root->child_at(0)->current_frame_host(); |
4691 | 4579 |
4692 // Synchronize with the child and parent renderers to guarantee that the | 4580 // Synchronize with the child and parent renderers to guarantee that the |
4693 // surface information required for event hit testing is ready. | 4581 // surface information required for event hit testing is ready. |
4694 RenderWidgetHostViewBase* child_rwhv = static_cast<RenderWidgetHostViewBase*>( | 4582 RenderWidgetHostViewBase* child_rwhv = static_cast<RenderWidgetHostViewBase*>( |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4807 } | 4695 } |
4808 | 4696 |
4809 } // namespace anonymous | 4697 } // namespace anonymous |
4810 | 4698 |
4811 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 4699 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
4812 InputEventRouterGestureTargetQueueTest) { | 4700 InputEventRouterGestureTargetQueueTest) { |
4813 GURL main_url(embedded_test_server()->GetURL( | 4701 GURL main_url(embedded_test_server()->GetURL( |
4814 "/frame_tree/page_with_positioned_nested_frames.html")); | 4702 "/frame_tree/page_with_positioned_nested_frames.html")); |
4815 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 4703 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
4816 | 4704 |
4817 WebContentsImpl* web_contents = | 4705 WebContentsImpl* contents = web_contents(); |
4818 static_cast<WebContentsImpl*>(shell()->web_contents()); | 4706 |
4819 FrameTreeNode* root = web_contents->GetFrameTree()->root(); | 4707 FrameTreeNode* root = contents->GetFrameTree()->root(); |
4820 ASSERT_EQ(1U, root->child_count()); | 4708 ASSERT_EQ(1U, root->child_count()); |
4821 | 4709 |
4822 GURL frame_url( | 4710 GURL frame_url( |
4823 embedded_test_server()->GetURL("b.com", "/page_with_click_handler.html")); | 4711 embedded_test_server()->GetURL("b.com", "/page_with_click_handler.html")); |
4824 NavigateFrameToURL(root->child_at(0), frame_url); | 4712 NavigateFrameToURL(root->child_at(0), frame_url); |
4825 auto child_frame_host = root->child_at(0)->current_frame_host(); | 4713 auto child_frame_host = root->child_at(0)->current_frame_host(); |
4826 | 4714 |
4827 // Synchronize with the child and parent renderers to guarantee that the | 4715 // Synchronize with the child and parent renderers to guarantee that the |
4828 // surface information required for event hit testing is ready. | 4716 // surface information required for event hit testing is ready. |
4829 auto rwhv_child = | 4717 auto rwhv_child = |
4830 static_cast<RenderWidgetHostViewBase*>(child_frame_host->GetView()); | 4718 static_cast<RenderWidgetHostViewBase*>(child_frame_host->GetView()); |
4831 SurfaceHitTestReadyNotifier notifier( | 4719 SurfaceHitTestReadyNotifier notifier( |
4832 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_child)); | 4720 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_child)); |
4833 notifier.WaitForSurfaceReady(); | 4721 notifier.WaitForSurfaceReady(); |
4834 | 4722 |
4835 // All touches & gestures are sent to the main frame's view, and should be | 4723 // All touches & gestures are sent to the main frame's view, and should be |
4836 // routed appropriately from there. | 4724 // routed appropriately from there. |
4837 auto rwhv_parent = static_cast<RenderWidgetHostViewBase*>( | 4725 auto rwhv_parent = static_cast<RenderWidgetHostViewBase*>( |
4838 web_contents->GetRenderWidgetHostView()); | 4726 contents->GetRenderWidgetHostView()); |
4839 | 4727 |
4840 RenderWidgetHostInputEventRouter* router = | 4728 RenderWidgetHostInputEventRouter* router = contents->GetInputEventRouter(); |
4841 web_contents->GetInputEventRouter(); | |
4842 EXPECT_TRUE(router->gesture_target_queue_.empty()); | 4729 EXPECT_TRUE(router->gesture_target_queue_.empty()); |
4843 EXPECT_EQ(nullptr, router->gesture_target_); | 4730 EXPECT_EQ(nullptr, router->gesture_target_); |
4844 | 4731 |
4845 // Send touch sequence to main-frame. | 4732 // Send touch sequence to main-frame. |
4846 gfx::Point main_frame_point(25, 25); | 4733 gfx::Point main_frame_point(25, 25); |
4847 SendTouchTapWithExpectedTarget(rwhv_parent, main_frame_point, | 4734 SendTouchTapWithExpectedTarget(rwhv_parent, main_frame_point, |
4848 router->touch_target_, rwhv_parent); | 4735 router->touch_target_, rwhv_parent); |
4849 EXPECT_EQ(1LU, router->gesture_target_queue_.size()); | 4736 EXPECT_EQ(1LU, router->gesture_target_queue_.size()); |
4850 EXPECT_EQ(nullptr, router->gesture_target_); | 4737 EXPECT_EQ(nullptr, router->gesture_target_); |
4851 | 4738 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4895 #endif // defined(USE_AURA) | 4782 #endif // defined(USE_AURA) |
4896 | 4783 |
4897 // Ensure that a cross-process subframe can receive keyboard events when in | 4784 // Ensure that a cross-process subframe can receive keyboard events when in |
4898 // focus. Flaky: https://crbug.com/596508. | 4785 // focus. Flaky: https://crbug.com/596508. |
4899 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 4786 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
4900 DISABLED_SubframeKeyboardEventRouting) { | 4787 DISABLED_SubframeKeyboardEventRouting) { |
4901 GURL main_url(embedded_test_server()->GetURL( | 4788 GURL main_url(embedded_test_server()->GetURL( |
4902 "a.com", "/frame_tree/page_with_one_frame.html")); | 4789 "a.com", "/frame_tree/page_with_one_frame.html")); |
4903 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 4790 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
4904 | 4791 |
4905 WebContentsImpl* web_contents = | 4792 WebContentsImpl* contents = web_contents(); |
4906 static_cast<WebContentsImpl*>(shell()->web_contents()); | 4793 FrameTreeNode* root = contents->GetFrameTree()->root(); |
4907 FrameTreeNode* root = web_contents->GetFrameTree()->root(); | |
4908 | 4794 |
4909 GURL frame_url( | 4795 GURL frame_url( |
4910 embedded_test_server()->GetURL("b.com", "/page_with_input_field.html")); | 4796 embedded_test_server()->GetURL("b.com", "/page_with_input_field.html")); |
4911 NavigateFrameToURL(root->child_at(0), frame_url); | 4797 NavigateFrameToURL(root->child_at(0), frame_url); |
4912 | 4798 |
4913 // Focus the subframe and then its input field. The return value | 4799 // Focus the subframe and then its input field. The return value |
4914 // "input-focus" will be sent once the input field's focus event fires. | 4800 // "input-focus" will be sent once the input field's focus event fires. |
4915 FocusFrame(root->child_at(0)); | 4801 FocusFrame(root->child_at(0)); |
4916 std::string result; | 4802 std::string result; |
4917 EXPECT_TRUE(ExecuteScriptAndExtractString( | 4803 EXPECT_TRUE(ExecuteScriptAndExtractString( |
4918 root->child_at(0)->current_frame_host(), "focusInputField()", &result)); | 4804 root->child_at(0)->current_frame_host(), "focusInputField()", &result)); |
4919 EXPECT_EQ(result, "input-focus"); | 4805 EXPECT_EQ(result, "input-focus"); |
4920 | 4806 |
4921 // The subframe should now be focused. | 4807 // The subframe should now be focused. |
4922 EXPECT_EQ(root->child_at(0), root->frame_tree()->GetFocusedFrame()); | 4808 EXPECT_EQ(root->child_at(0), root->frame_tree()->GetFocusedFrame()); |
4923 | 4809 |
4924 // Generate a few keyboard events and route them to currently focused frame. | 4810 // Generate a few keyboard events and route them to currently focused frame. |
4925 SimulateKeyPress(web_contents, ui::VKEY_F, false, false, false, false); | 4811 SimulateKeyPress(contents, ui::VKEY_F, false, false, false, false); |
4926 SimulateKeyPress(web_contents, ui::VKEY_O, false, false, false, false); | 4812 SimulateKeyPress(contents, ui::VKEY_O, false, false, false, false); |
4927 SimulateKeyPress(web_contents, ui::VKEY_O, false, false, false, false); | 4813 SimulateKeyPress(contents, ui::VKEY_O, false, false, false, false); |
4928 | 4814 |
4929 // Verify that the input field in the subframe received the keystrokes. | 4815 // Verify that the input field in the subframe received the keystrokes. |
4930 EXPECT_TRUE(ExecuteScriptAndExtractString( | 4816 EXPECT_TRUE(ExecuteScriptAndExtractString( |
4931 root->child_at(0)->current_frame_host(), | 4817 root->child_at(0)->current_frame_host(), |
4932 "window.domAutomationController.send(getInputFieldText());", &result)); | 4818 "window.domAutomationController.send(getInputFieldText());", &result)); |
4933 EXPECT_EQ("FOO", result); | 4819 EXPECT_EQ("FOO", result); |
4934 } | 4820 } |
4935 | 4821 |
4936 // Ensure that sequential focus navigation (advancing focused elements with | 4822 // Ensure that sequential focus navigation (advancing focused elements with |
4937 // <tab> and <shift-tab>) works across cross-process subframes. | 4823 // <tab> and <shift-tab>) works across cross-process subframes. |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5060 #define MAYBE_CreateContextMenuTest DISABLED_CreateContextMenuTest | 4946 #define MAYBE_CreateContextMenuTest DISABLED_CreateContextMenuTest |
5061 #else | 4947 #else |
5062 #define MAYBE_CreateContextMenuTest CreateContextMenuTest | 4948 #define MAYBE_CreateContextMenuTest CreateContextMenuTest |
5063 #endif | 4949 #endif |
5064 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_CreateContextMenuTest) { | 4950 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_CreateContextMenuTest) { |
5065 GURL main_url(embedded_test_server()->GetURL( | 4951 GURL main_url(embedded_test_server()->GetURL( |
5066 "/frame_tree/page_with_positioned_frame.html")); | 4952 "/frame_tree/page_with_positioned_frame.html")); |
5067 NavigateToURL(shell(), main_url); | 4953 NavigateToURL(shell(), main_url); |
5068 | 4954 |
5069 // It is safe to obtain the root frame tree node here, as it doesn't change. | 4955 // It is safe to obtain the root frame tree node here, as it doesn't change. |
5070 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 4956 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
5071 ->GetFrameTree() | |
5072 ->root(); | |
5073 ASSERT_EQ(1U, root->child_count()); | 4957 ASSERT_EQ(1U, root->child_count()); |
5074 | 4958 |
5075 FrameTreeNode* child_node = root->child_at(0); | 4959 FrameTreeNode* child_node = root->child_at(0); |
5076 GURL site_url(embedded_test_server()->GetURL("baz.com", "/title1.html")); | 4960 GURL site_url(embedded_test_server()->GetURL("baz.com", "/title1.html")); |
5077 EXPECT_EQ(site_url, child_node->current_url()); | 4961 EXPECT_EQ(site_url, child_node->current_url()); |
5078 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 4962 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
5079 child_node->current_frame_host()->GetSiteInstance()); | 4963 child_node->current_frame_host()->GetSiteInstance()); |
5080 | 4964 |
5081 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( | 4965 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( |
5082 root->current_frame_host()->GetRenderWidgetHost()->GetView()); | 4966 root->current_frame_host()->GetRenderWidgetHost()->GetView()); |
(...skipping 12 matching lines...) Expand all Loading... |
5095 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 4979 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
5096 FROM_HERE, run_loop.QuitClosure(), TestTimeouts::tiny_timeout()); | 4980 FROM_HERE, run_loop.QuitClosure(), TestTimeouts::tiny_timeout()); |
5097 run_loop.Run(); | 4981 run_loop.Run(); |
5098 } | 4982 } |
5099 | 4983 |
5100 // A WebContentsDelegate to listen for the ShowContextMenu message. | 4984 // A WebContentsDelegate to listen for the ShowContextMenu message. |
5101 ContextMenuObserverDelegate context_menu_delegate; | 4985 ContextMenuObserverDelegate context_menu_delegate; |
5102 shell()->web_contents()->SetDelegate(&context_menu_delegate); | 4986 shell()->web_contents()->SetDelegate(&context_menu_delegate); |
5103 | 4987 |
5104 RenderWidgetHostInputEventRouter* router = | 4988 RenderWidgetHostInputEventRouter* router = |
5105 static_cast<WebContentsImpl*>(shell()->web_contents()) | 4989 web_contents()->GetInputEventRouter(); |
5106 ->GetInputEventRouter(); | |
5107 | 4990 |
5108 // Target right-click event to child frame. | 4991 // Target right-click event to child frame. |
5109 blink::WebMouseEvent click_event; | 4992 blink::WebMouseEvent click_event; |
5110 click_event.type = blink::WebInputEvent::MouseDown; | 4993 click_event.type = blink::WebInputEvent::MouseDown; |
5111 click_event.button = blink::WebPointerProperties::ButtonRight; | 4994 click_event.button = blink::WebPointerProperties::ButtonRight; |
5112 click_event.x = 75; | 4995 click_event.x = 75; |
5113 click_event.y = 75; | 4996 click_event.y = 75; |
5114 click_event.clickCount = 1; | 4997 click_event.clickCount = 1; |
5115 router->RouteMouseEvent(root_view, &click_event); | 4998 router->RouteMouseEvent(root_view, &click_event); |
5116 | 4999 |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5555 // if a pending cross-process navigation is cancelled. The test works by trying | 5438 // if a pending cross-process navigation is cancelled. The test works by trying |
5556 // to create a new RenderFrame with the same routing id. If there is an | 5439 // to create a new RenderFrame with the same routing id. If there is an |
5557 // entry with the same routing ID, a CHECK is hit and the process crashes. | 5440 // entry with the same routing ID, a CHECK is hit and the process crashes. |
5558 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 5441 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
5559 SubframePendingAndBackToSameSiteInstance) { | 5442 SubframePendingAndBackToSameSiteInstance) { |
5560 GURL main_url(embedded_test_server()->GetURL( | 5443 GURL main_url(embedded_test_server()->GetURL( |
5561 "a.com", "/cross_site_iframe_factory.html?a(b)")); | 5444 "a.com", "/cross_site_iframe_factory.html?a(b)")); |
5562 NavigateToURL(shell(), main_url); | 5445 NavigateToURL(shell(), main_url); |
5563 | 5446 |
5564 // Capture the FrameTreeNode this test will be navigating. | 5447 // Capture the FrameTreeNode this test will be navigating. |
5565 FrameTreeNode* node = static_cast<WebContentsImpl*>(shell()->web_contents()) | 5448 FrameTreeNode* node = web_contents()->GetFrameTree()->root()->child_at(0); |
5566 ->GetFrameTree() | |
5567 ->root() | |
5568 ->child_at(0); | |
5569 EXPECT_TRUE(node); | 5449 EXPECT_TRUE(node); |
5570 EXPECT_NE(node->current_frame_host()->GetSiteInstance(), | 5450 EXPECT_NE(node->current_frame_host()->GetSiteInstance(), |
5571 node->parent()->current_frame_host()->GetSiteInstance()); | 5451 node->parent()->current_frame_host()->GetSiteInstance()); |
5572 | 5452 |
5573 // Navigate to the site of the parent, but to a page that will not commit. | 5453 // Navigate to the site of the parent, but to a page that will not commit. |
5574 GURL same_site_url(embedded_test_server()->GetURL("a.com", "/title1.html")); | 5454 GURL same_site_url(embedded_test_server()->GetURL("a.com", "/title1.html")); |
5575 NavigationStallDelegate stall_delegate(same_site_url); | 5455 NavigationStallDelegate stall_delegate(same_site_url); |
5576 ResourceDispatcherHost::Get()->SetDelegate(&stall_delegate); | 5456 ResourceDispatcherHost::Get()->SetDelegate(&stall_delegate); |
5577 { | 5457 { |
5578 NavigationController::LoadURLParams params(same_site_url); | 5458 NavigationController::LoadURLParams params(same_site_url); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5632 | 5512 |
5633 // This test ensures that the RenderFrame isn't leaked in the renderer process | 5513 // This test ensures that the RenderFrame isn't leaked in the renderer process |
5634 // when a remote parent detaches a child frame. The test works by trying | 5514 // when a remote parent detaches a child frame. The test works by trying |
5635 // to create a new RenderFrame with the same routing id. If there is an | 5515 // to create a new RenderFrame with the same routing id. If there is an |
5636 // entry with the same routing ID, a CHECK is hit and the process crashes. | 5516 // entry with the same routing ID, a CHECK is hit and the process crashes. |
5637 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ParentDetachRemoteChild) { | 5517 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ParentDetachRemoteChild) { |
5638 GURL main_url(embedded_test_server()->GetURL( | 5518 GURL main_url(embedded_test_server()->GetURL( |
5639 "a.com", "/cross_site_iframe_factory.html?a(b,b)")); | 5519 "a.com", "/cross_site_iframe_factory.html?a(b,b)")); |
5640 NavigateToURL(shell(), main_url); | 5520 NavigateToURL(shell(), main_url); |
5641 | 5521 |
5642 WebContentsImpl* web_contents = | 5522 WebContentsImpl* contents = web_contents(); |
5643 static_cast<WebContentsImpl*>(shell()->web_contents()); | 5523 EXPECT_EQ(2U, contents->GetFrameTree()->root()->child_count()); |
5644 EXPECT_EQ(2U, web_contents->GetFrameTree()->root()->child_count()); | |
5645 | 5524 |
5646 // Capture the FrameTreeNode this test will be navigating. | 5525 // Capture the FrameTreeNode this test will be navigating. |
5647 FrameTreeNode* node = web_contents->GetFrameTree()->root()->child_at(0); | 5526 FrameTreeNode* node = contents->GetFrameTree()->root()->child_at(0); |
5648 EXPECT_TRUE(node); | 5527 EXPECT_TRUE(node); |
5649 EXPECT_NE(node->current_frame_host()->GetSiteInstance(), | 5528 EXPECT_NE(node->current_frame_host()->GetSiteInstance(), |
5650 node->parent()->current_frame_host()->GetSiteInstance()); | 5529 node->parent()->current_frame_host()->GetSiteInstance()); |
5651 | 5530 |
5652 // Grab the routing id of the first child RenderFrameHost and set up a process | 5531 // Grab the routing id of the first child RenderFrameHost and set up a process |
5653 // observer to ensure there is no crash when a new RenderFrame creation is | 5532 // observer to ensure there is no crash when a new RenderFrame creation is |
5654 // attempted. | 5533 // attempted. |
5655 RenderProcessHost* process = node->current_frame_host()->GetProcess(); | 5534 RenderProcessHost* process = node->current_frame_host()->GetProcess(); |
5656 RenderProcessHostWatcher watcher( | 5535 RenderProcessHostWatcher watcher( |
5657 process, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); | 5536 process, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); |
5658 int frame_routing_id = node->current_frame_host()->GetRoutingID(); | 5537 int frame_routing_id = node->current_frame_host()->GetRoutingID(); |
5659 int widget_routing_id = | 5538 int widget_routing_id = |
5660 node->current_frame_host()->GetRenderWidgetHost()->GetRoutingID(); | 5539 node->current_frame_host()->GetRenderWidgetHost()->GetRoutingID(); |
5661 int parent_routing_id = | 5540 int parent_routing_id = |
5662 node->parent()->render_manager()->GetRoutingIdForSiteInstance( | 5541 node->parent()->render_manager()->GetRoutingIdForSiteInstance( |
5663 node->current_frame_host()->GetSiteInstance()); | 5542 node->current_frame_host()->GetSiteInstance()); |
5664 | 5543 |
5665 // Have the parent frame remove the child frame from its DOM. This should | 5544 // Have the parent frame remove the child frame from its DOM. This should |
5666 // result in the child RenderFrame being deleted in the remote process. | 5545 // result in the child RenderFrame being deleted in the remote process. |
5667 EXPECT_TRUE(ExecuteScript(web_contents, | 5546 EXPECT_TRUE(ExecuteScript(contents, |
5668 "document.body.removeChild(" | 5547 "document.body.removeChild(" |
5669 "document.querySelectorAll('iframe')[0])")); | 5548 "document.querySelectorAll('iframe')[0])")); |
5670 EXPECT_EQ(1U, web_contents->GetFrameTree()->root()->child_count()); | 5549 EXPECT_EQ(1U, contents->GetFrameTree()->root()->child_count()); |
5671 | 5550 |
5672 { | 5551 { |
5673 FrameMsg_NewFrame_Params params; | 5552 FrameMsg_NewFrame_Params params; |
5674 params.routing_id = frame_routing_id; | 5553 params.routing_id = frame_routing_id; |
5675 params.proxy_routing_id = MSG_ROUTING_NONE; | 5554 params.proxy_routing_id = MSG_ROUTING_NONE; |
5676 params.opener_routing_id = MSG_ROUTING_NONE; | 5555 params.opener_routing_id = MSG_ROUTING_NONE; |
5677 params.parent_routing_id = parent_routing_id; | 5556 params.parent_routing_id = parent_routing_id; |
5678 params.previous_sibling_routing_id = MSG_ROUTING_NONE; | 5557 params.previous_sibling_routing_id = MSG_ROUTING_NONE; |
5679 params.widget_params.routing_id = widget_routing_id; | 5558 params.widget_params.routing_id = widget_routing_id; |
5680 params.widget_params.hidden = true; | 5559 params.widget_params.hidden = true; |
5681 params.replication_state.name = "name"; | 5560 params.replication_state.name = "name"; |
5682 params.replication_state.unique_name = "name"; | 5561 params.replication_state.unique_name = "name"; |
5683 | 5562 |
5684 process->Send(new FrameMsg_NewFrame(params)); | 5563 process->Send(new FrameMsg_NewFrame(params)); |
5685 } | 5564 } |
5686 | 5565 |
5687 // The test must wait for the process to exit, but if there is no leak, the | 5566 // The test must wait for the process to exit, but if there is no leak, the |
5688 // RenderFrame will be properly created and there will be no crash. | 5567 // RenderFrame will be properly created and there will be no crash. |
5689 // Therefore, navigate the remaining subframe to completely different site, | 5568 // Therefore, navigate the remaining subframe to completely different site, |
5690 // which will cause the original process to exit cleanly. | 5569 // which will cause the original process to exit cleanly. |
5691 NavigateFrameToURL( | 5570 NavigateFrameToURL(contents->GetFrameTree()->root()->child_at(0), |
5692 web_contents->GetFrameTree()->root()->child_at(0), | 5571 embedded_test_server()->GetURL("d.com", "/title3.html")); |
5693 embedded_test_server()->GetURL("d.com", "/title3.html")); | |
5694 watcher.Wait(); | 5572 watcher.Wait(); |
5695 EXPECT_TRUE(watcher.did_exit_normally()); | 5573 EXPECT_TRUE(watcher.did_exit_normally()); |
5696 } | 5574 } |
5697 | 5575 |
5698 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, VisibilityChanged) { | 5576 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, VisibilityChanged) { |
5699 GURL main_url( | 5577 GURL main_url( |
5700 embedded_test_server()->GetURL("a.com", "/page_with_iframe.html")); | 5578 embedded_test_server()->GetURL("a.com", "/page_with_iframe.html")); |
5701 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 5579 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
5702 EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), main_url); | 5580 EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), main_url); |
5703 | 5581 |
5704 GURL cross_site_url = | 5582 GURL cross_site_url = |
5705 embedded_test_server()->GetURL("oopif.com", "/title1.html"); | 5583 embedded_test_server()->GetURL("oopif.com", "/title1.html"); |
5706 | 5584 |
5707 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 5585 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
5708 ->GetFrameTree() | |
5709 ->root(); | |
5710 | 5586 |
5711 TestNavigationObserver observer(shell()->web_contents()); | 5587 TestNavigationObserver observer(shell()->web_contents()); |
5712 | 5588 |
5713 NavigateFrameToURL(root->child_at(0), cross_site_url); | 5589 NavigateFrameToURL(root->child_at(0), cross_site_url); |
5714 EXPECT_EQ(cross_site_url, observer.last_navigation_url()); | 5590 EXPECT_EQ(cross_site_url, observer.last_navigation_url()); |
5715 EXPECT_TRUE(observer.last_navigation_succeeded()); | 5591 EXPECT_TRUE(observer.last_navigation_succeeded()); |
5716 | 5592 |
5717 RenderWidgetHostImpl* render_widget_host = | 5593 RenderWidgetHostImpl* render_widget_host = |
5718 root->child_at(0)->current_frame_host()->GetRenderWidgetHost(); | 5594 root->child_at(0)->current_frame_host()->GetRenderWidgetHost(); |
5719 EXPECT_FALSE(render_widget_host->is_hidden()); | 5595 EXPECT_FALSE(render_widget_host->is_hidden()); |
(...skipping 17 matching lines...) Expand all Loading... |
5737 } | 5613 } |
5738 | 5614 |
5739 // Verify that sandbox flags inheritance works across multiple levels of | 5615 // Verify that sandbox flags inheritance works across multiple levels of |
5740 // frames. See https://crbug.com/576845. | 5616 // frames. See https://crbug.com/576845. |
5741 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, SandboxFlagsInheritance) { | 5617 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, SandboxFlagsInheritance) { |
5742 GURL main_url(embedded_test_server()->GetURL( | 5618 GURL main_url(embedded_test_server()->GetURL( |
5743 "a.com", "/cross_site_iframe_factory.html?a(a)")); | 5619 "a.com", "/cross_site_iframe_factory.html?a(a)")); |
5744 NavigateToURL(shell(), main_url); | 5620 NavigateToURL(shell(), main_url); |
5745 | 5621 |
5746 // It is safe to obtain the root frame tree node here, as it doesn't change. | 5622 // It is safe to obtain the root frame tree node here, as it doesn't change. |
5747 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 5623 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
5748 ->GetFrameTree() | |
5749 ->root(); | |
5750 | 5624 |
5751 // Set sandbox flags for child frame. | 5625 // Set sandbox flags for child frame. |
5752 EXPECT_TRUE(ExecuteScript( | 5626 EXPECT_TRUE(ExecuteScript( |
5753 root->current_frame_host(), | 5627 root->current_frame_host(), |
5754 "document.querySelector('iframe').sandbox = 'allow-scripts';")); | 5628 "document.querySelector('iframe').sandbox = 'allow-scripts';")); |
5755 | 5629 |
5756 // Calculate expected flags. Note that "allow-scripts" resets both | 5630 // Calculate expected flags. Note that "allow-scripts" resets both |
5757 // WebSandboxFlags::Scripts and WebSandboxFlags::AutomaticFeatures bits per | 5631 // WebSandboxFlags::Scripts and WebSandboxFlags::AutomaticFeatures bits per |
5758 // blink::parseSandboxPolicy(). | 5632 // blink::parseSandboxPolicy(). |
5759 blink::WebSandboxFlags expected_flags = | 5633 blink::WebSandboxFlags expected_flags = |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5792 // a child frame, update its sandbox flags but don't navigate the frame, and | 5666 // a child frame, update its sandbox flags but don't navigate the frame, and |
5793 // ensure that a new cross-site grandchild frame doesn't inherit the new flags | 5667 // ensure that a new cross-site grandchild frame doesn't inherit the new flags |
5794 // (which shouldn't have taken effect). | 5668 // (which shouldn't have taken effect). |
5795 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 5669 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
5796 SandboxFlagsNotInheritedBeforeNavigation) { | 5670 SandboxFlagsNotInheritedBeforeNavigation) { |
5797 GURL main_url(embedded_test_server()->GetURL( | 5671 GURL main_url(embedded_test_server()->GetURL( |
5798 "a.com", "/cross_site_iframe_factory.html?a(a)")); | 5672 "a.com", "/cross_site_iframe_factory.html?a(a)")); |
5799 NavigateToURL(shell(), main_url); | 5673 NavigateToURL(shell(), main_url); |
5800 | 5674 |
5801 // It is safe to obtain the root frame tree node here, as it doesn't change. | 5675 // It is safe to obtain the root frame tree node here, as it doesn't change. |
5802 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 5676 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
5803 ->GetFrameTree() | |
5804 ->root(); | |
5805 | 5677 |
5806 // Set sandbox flags for child frame. | 5678 // Set sandbox flags for child frame. |
5807 EXPECT_TRUE(ExecuteScript( | 5679 EXPECT_TRUE(ExecuteScript( |
5808 root->current_frame_host(), | 5680 root->current_frame_host(), |
5809 "document.querySelector('iframe').sandbox = 'allow-scripts';")); | 5681 "document.querySelector('iframe').sandbox = 'allow-scripts';")); |
5810 | 5682 |
5811 // These flags should be pending but not take effect, since there's been no | 5683 // These flags should be pending but not take effect, since there's been no |
5812 // navigation. | 5684 // navigation. |
5813 blink::WebSandboxFlags expected_flags = | 5685 blink::WebSandboxFlags expected_flags = |
5814 blink::WebSandboxFlags::All & ~blink::WebSandboxFlags::Scripts & | 5686 blink::WebSandboxFlags::All & ~blink::WebSandboxFlags::Scripts & |
(...skipping 29 matching lines...) Expand all Loading... |
5844 // Verify that popups opened from sandboxed frames inherit sandbox flags from | 5716 // Verify that popups opened from sandboxed frames inherit sandbox flags from |
5845 // their opener, and that they keep these inherited flags after being navigated | 5717 // their opener, and that they keep these inherited flags after being navigated |
5846 // cross-site. See https://crbug.com/483584. | 5718 // cross-site. See https://crbug.com/483584. |
5847 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 5719 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
5848 NewPopupInheritsSandboxFlagsFromOpener) { | 5720 NewPopupInheritsSandboxFlagsFromOpener) { |
5849 GURL main_url(embedded_test_server()->GetURL( | 5721 GURL main_url(embedded_test_server()->GetURL( |
5850 "a.com", "/cross_site_iframe_factory.html?a(a)")); | 5722 "a.com", "/cross_site_iframe_factory.html?a(a)")); |
5851 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 5723 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
5852 | 5724 |
5853 // It is safe to obtain the root frame tree node here, as it doesn't change. | 5725 // It is safe to obtain the root frame tree node here, as it doesn't change. |
5854 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 5726 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
5855 ->GetFrameTree() | |
5856 ->root(); | |
5857 | 5727 |
5858 // Set sandbox flags for child frame. | 5728 // Set sandbox flags for child frame. |
5859 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), | 5729 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), |
5860 "document.querySelector('iframe').sandbox = " | 5730 "document.querySelector('iframe').sandbox = " |
5861 " 'allow-scripts allow-popups';")); | 5731 " 'allow-scripts allow-popups';")); |
5862 | 5732 |
5863 // Calculate expected flags. Note that "allow-scripts" resets both | 5733 // Calculate expected flags. Note that "allow-scripts" resets both |
5864 // WebSandboxFlags::Scripts and WebSandboxFlags::AutomaticFeatures bits per | 5734 // WebSandboxFlags::Scripts and WebSandboxFlags::AutomaticFeatures bits per |
5865 // blink::parseSandboxPolicy(). | 5735 // blink::parseSandboxPolicy(). |
5866 blink::WebSandboxFlags expected_flags = | 5736 blink::WebSandboxFlags expected_flags = |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5915 // Verify that popups opened from frames sandboxed with the | 5785 // Verify that popups opened from frames sandboxed with the |
5916 // "allow-popups-to-escape-sandbox" directive do *not* inherit sandbox flags | 5786 // "allow-popups-to-escape-sandbox" directive do *not* inherit sandbox flags |
5917 // from their opener. | 5787 // from their opener. |
5918 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 5788 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
5919 OpenUnsandboxedPopupFromSandboxedFrame) { | 5789 OpenUnsandboxedPopupFromSandboxedFrame) { |
5920 GURL main_url(embedded_test_server()->GetURL( | 5790 GURL main_url(embedded_test_server()->GetURL( |
5921 "a.com", "/cross_site_iframe_factory.html?a(a)")); | 5791 "a.com", "/cross_site_iframe_factory.html?a(a)")); |
5922 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 5792 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
5923 | 5793 |
5924 // It is safe to obtain the root frame tree node here, as it doesn't change. | 5794 // It is safe to obtain the root frame tree node here, as it doesn't change. |
5925 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 5795 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
5926 ->GetFrameTree() | |
5927 ->root(); | |
5928 | 5796 |
5929 // Set sandbox flags for child frame, specifying that popups opened from it | 5797 // Set sandbox flags for child frame, specifying that popups opened from it |
5930 // should not be sandboxed. | 5798 // should not be sandboxed. |
5931 EXPECT_TRUE(ExecuteScript( | 5799 EXPECT_TRUE(ExecuteScript( |
5932 root->current_frame_host(), | 5800 root->current_frame_host(), |
5933 "document.querySelector('iframe').sandbox = " | 5801 "document.querySelector('iframe').sandbox = " |
5934 " 'allow-scripts allow-popups allow-popups-to-escape-sandbox';")); | 5802 " 'allow-scripts allow-popups allow-popups-to-escape-sandbox';")); |
5935 | 5803 |
5936 // Set expected flags for the child frame. Note that "allow-scripts" resets | 5804 // Set expected flags for the child frame. Note that "allow-scripts" resets |
5937 // both WebSandboxFlags::Scripts and WebSandboxFlags::AutomaticFeatures bits | 5805 // both WebSandboxFlags::Scripts and WebSandboxFlags::AutomaticFeatures bits |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5986 SetupCrossSiteRedirector(&https_server); | 5854 SetupCrossSiteRedirector(&https_server); |
5987 | 5855 |
5988 GURL iframe_url( | 5856 GURL iframe_url( |
5989 https_server.GetURL("/mixed-content/basic-passive-in-iframe.html")); | 5857 https_server.GetURL("/mixed-content/basic-passive-in-iframe.html")); |
5990 EXPECT_TRUE(NavigateToURL(shell(), iframe_url)); | 5858 EXPECT_TRUE(NavigateToURL(shell(), iframe_url)); |
5991 EXPECT_TRUE(shell()->web_contents()->DisplayedInsecureContent()); | 5859 EXPECT_TRUE(shell()->web_contents()->DisplayedInsecureContent()); |
5992 | 5860 |
5993 // When the subframe navigates, the WebContents should still be marked | 5861 // When the subframe navigates, the WebContents should still be marked |
5994 // as having displayed insecure content. | 5862 // as having displayed insecure content. |
5995 GURL navigate_url(https_server.GetURL("/title1.html")); | 5863 GURL navigate_url(https_server.GetURL("/title1.html")); |
5996 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 5864 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
5997 ->GetFrameTree() | |
5998 ->root(); | |
5999 NavigateFrameToURL(root->child_at(0), navigate_url); | 5865 NavigateFrameToURL(root->child_at(0), navigate_url); |
6000 EXPECT_TRUE(shell()->web_contents()->DisplayedInsecureContent()); | 5866 EXPECT_TRUE(shell()->web_contents()->DisplayedInsecureContent()); |
6001 | 5867 |
6002 // When the main frame navigates, it should no longer be marked as | 5868 // When the main frame navigates, it should no longer be marked as |
6003 // displaying insecure content. | 5869 // displaying insecure content. |
6004 EXPECT_TRUE( | 5870 EXPECT_TRUE( |
6005 NavigateToURL(shell(), https_server.GetURL("b.com", "/title1.html"))); | 5871 NavigateToURL(shell(), https_server.GetURL("b.com", "/title1.html"))); |
6006 EXPECT_FALSE(shell()->web_contents()->DisplayedInsecureContent()); | 5872 EXPECT_FALSE(shell()->web_contents()->DisplayedInsecureContent()); |
6007 } | 5873 } |
6008 | 5874 |
6009 // Tests that, when a parent frame is set to strictly block mixed | 5875 // Tests that, when a parent frame is set to strictly block mixed |
6010 // content via Content Security Policy, child OOPIFs cannot display | 5876 // content via Content Security Policy, child OOPIFs cannot display |
6011 // mixed content. | 5877 // mixed content. |
6012 IN_PROC_BROWSER_TEST_F(SitePerProcessIgnoreCertErrorsBrowserTest, | 5878 IN_PROC_BROWSER_TEST_F(SitePerProcessIgnoreCertErrorsBrowserTest, |
6013 PassiveMixedContentInIframeWithStrictBlocking) { | 5879 PassiveMixedContentInIframeWithStrictBlocking) { |
6014 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); | 5880 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); |
6015 https_server.ServeFilesFromSourceDirectory("content/test/data"); | 5881 https_server.ServeFilesFromSourceDirectory("content/test/data"); |
6016 ASSERT_TRUE(https_server.Start()); | 5882 ASSERT_TRUE(https_server.Start()); |
6017 SetupCrossSiteRedirector(&https_server); | 5883 SetupCrossSiteRedirector(&https_server); |
6018 | 5884 |
6019 GURL iframe_url_with_strict_blocking(https_server.GetURL( | 5885 GURL iframe_url_with_strict_blocking(https_server.GetURL( |
6020 "/mixed-content/basic-passive-in-iframe-with-strict-blocking.html")); | 5886 "/mixed-content/basic-passive-in-iframe-with-strict-blocking.html")); |
6021 EXPECT_TRUE(NavigateToURL(shell(), iframe_url_with_strict_blocking)); | 5887 EXPECT_TRUE(NavigateToURL(shell(), iframe_url_with_strict_blocking)); |
6022 EXPECT_FALSE(shell()->web_contents()->DisplayedInsecureContent()); | 5888 EXPECT_FALSE(shell()->web_contents()->DisplayedInsecureContent()); |
6023 | 5889 |
6024 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 5890 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
6025 ->GetFrameTree() | |
6026 ->root(); | |
6027 EXPECT_TRUE(root->current_replication_state() | 5891 EXPECT_TRUE(root->current_replication_state() |
6028 .should_enforce_strict_mixed_content_checking); | 5892 .should_enforce_strict_mixed_content_checking); |
6029 EXPECT_TRUE(root->child_at(0) | 5893 EXPECT_TRUE(root->child_at(0) |
6030 ->current_replication_state() | 5894 ->current_replication_state() |
6031 .should_enforce_strict_mixed_content_checking); | 5895 .should_enforce_strict_mixed_content_checking); |
6032 | 5896 |
6033 // When the subframe navigates, it should still be marked as enforcing | 5897 // When the subframe navigates, it should still be marked as enforcing |
6034 // strict mixed content. | 5898 // strict mixed content. |
6035 GURL navigate_url(https_server.GetURL("/title1.html")); | 5899 GURL navigate_url(https_server.GetURL("/title1.html")); |
6036 NavigateFrameToURL(root->child_at(0), navigate_url); | 5900 NavigateFrameToURL(root->child_at(0), navigate_url); |
(...skipping 18 matching lines...) Expand all Loading... |
6055 IN_PROC_BROWSER_TEST_F(SitePerProcessIgnoreCertErrorsBrowserTest, | 5919 IN_PROC_BROWSER_TEST_F(SitePerProcessIgnoreCertErrorsBrowserTest, |
6056 ActiveMixedContentInIframe) { | 5920 ActiveMixedContentInIframe) { |
6057 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); | 5921 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); |
6058 https_server.ServeFilesFromSourceDirectory("content/test/data"); | 5922 https_server.ServeFilesFromSourceDirectory("content/test/data"); |
6059 ASSERT_TRUE(https_server.Start()); | 5923 ASSERT_TRUE(https_server.Start()); |
6060 SetupCrossSiteRedirector(&https_server); | 5924 SetupCrossSiteRedirector(&https_server); |
6061 | 5925 |
6062 GURL iframe_url( | 5926 GURL iframe_url( |
6063 https_server.GetURL("/mixed-content/basic-active-in-iframe.html")); | 5927 https_server.GetURL("/mixed-content/basic-active-in-iframe.html")); |
6064 EXPECT_TRUE(NavigateToURL(shell(), iframe_url)); | 5928 EXPECT_TRUE(NavigateToURL(shell(), iframe_url)); |
6065 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 5929 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
6066 ->GetFrameTree() | |
6067 ->root(); | |
6068 ASSERT_EQ(1U, root->child_count()); | 5930 ASSERT_EQ(1U, root->child_count()); |
6069 FrameTreeNode* mixed_child = root->child_at(0)->child_at(0); | 5931 FrameTreeNode* mixed_child = root->child_at(0)->child_at(0); |
6070 ASSERT_TRUE(mixed_child); | 5932 ASSERT_TRUE(mixed_child); |
6071 // The child iframe attempted to create a mixed iframe; this should | 5933 // The child iframe attempted to create a mixed iframe; this should |
6072 // have been blocked, so the mixed iframe should not have committed a | 5934 // have been blocked, so the mixed iframe should not have committed a |
6073 // load. | 5935 // load. |
6074 EXPECT_FALSE(mixed_child->has_committed_real_load()); | 5936 EXPECT_FALSE(mixed_child->has_committed_real_load()); |
6075 } | 5937 } |
6076 | 5938 |
6077 // Test setting a cross-origin iframe to display: none. | 5939 // Test setting a cross-origin iframe to display: none. |
6078 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframeDisplayNone) { | 5940 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframeDisplayNone) { |
6079 GURL main_url(embedded_test_server()->GetURL( | 5941 GURL main_url(embedded_test_server()->GetURL( |
6080 "a.com", "/cross_site_iframe_factory.html?a(b)")); | 5942 "a.com", "/cross_site_iframe_factory.html?a(b)")); |
6081 NavigateToURL(shell(), main_url); | 5943 NavigateToURL(shell(), main_url); |
6082 | 5944 |
6083 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 5945 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
6084 ->GetFrameTree() | |
6085 ->root(); | |
6086 RenderWidgetHost* root_render_widget_host = | 5946 RenderWidgetHost* root_render_widget_host = |
6087 root->current_frame_host()->GetRenderWidgetHost(); | 5947 root->current_frame_host()->GetRenderWidgetHost(); |
6088 | 5948 |
6089 // Set the iframe to display: none. | 5949 // Set the iframe to display: none. |
6090 EXPECT_TRUE( | 5950 EXPECT_TRUE( |
6091 ExecuteScript(shell()->web_contents(), | 5951 ExecuteScript(shell()->web_contents(), |
6092 "document.querySelector('iframe').style.display = 'none'")); | 5952 "document.querySelector('iframe').style.display = 'none'")); |
6093 | 5953 |
6094 // Waits until pending frames are done. | 5954 // Waits until pending frames are done. |
6095 scoped_ptr<MainThreadFrameObserver> observer( | 5955 scoped_ptr<MainThreadFrameObserver> observer( |
6096 new MainThreadFrameObserver(root_render_widget_host)); | 5956 new MainThreadFrameObserver(root_render_widget_host)); |
6097 observer->Wait(); | 5957 observer->Wait(); |
6098 | 5958 |
6099 // Force the renderer to generate a new frame. | 5959 // Force the renderer to generate a new frame. |
6100 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), | 5960 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), |
6101 "document.body.style.background = 'black'")); | 5961 "document.body.style.background = 'black'")); |
6102 | 5962 |
6103 // Waits for the next frame. | 5963 // Waits for the next frame. |
6104 observer->Wait(); | 5964 observer->Wait(); |
6105 } | 5965 } |
6106 | 5966 |
| 5967 // This class will sniff incoming IPC for ViewHostMsg_TextInputStateChanged. |
| 5968 class TextInputStateChangedMessageFilter : public BrowserMessageFilter { |
| 5969 public: |
| 5970 explicit TextInputStateChangedMessageFilter( |
| 5971 RenderWidgetHostImpl* render_widget_host) |
| 5972 : BrowserMessageFilter(ViewMsgStart), text_input_state_changed_(false) { |
| 5973 if (!render_widget_host || !render_widget_host->GetProcess()) |
| 5974 text_input_state_changed_ = true; |
| 5975 old_state = *render_widget_host->GetView()->text_input_state(); |
| 5976 render_widget_host->GetProcess()->AddFilter(this); |
| 5977 } |
| 5978 |
| 5979 void WaitUntilTextInputStateChanges() { |
| 5980 if (!text_input_state_changed_) { |
| 5981 message_loop_runner_ = new MessageLoopRunner; |
| 5982 message_loop_runner_->Run(); |
| 5983 } |
| 5984 } |
| 5985 |
| 5986 private: |
| 5987 ~TextInputStateChangedMessageFilter() override {} |
| 5988 |
| 5989 bool OnMessageReceived(const IPC::Message& msg) override { |
| 5990 IPC_BEGIN_MESSAGE_MAP(TextInputStateChangedMessageFilter, msg) |
| 5991 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged, |
| 5992 OnTextInputStateChangedMessageReceived) |
| 5993 IPC_END_MESSAGE_MAP() |
| 5994 return false; |
| 5995 } |
| 5996 |
| 5997 void OnTextInputStateChangedMessageReceived(const TextInputState& new_state) { |
| 5998 if (new_state.type != old_state.type || new_state.mode != old_state.mode || |
| 5999 new_state.value != old_state.value) { |
| 6000 text_input_state_changed_ = true; |
| 6001 if (message_loop_runner_) |
| 6002 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 6003 message_loop_runner_->QuitClosure()); |
| 6004 } |
| 6005 } |
| 6006 |
| 6007 bool text_input_state_changed_; |
| 6008 scoped_refptr<MessageLoopRunner> message_loop_runner_; |
| 6009 TextInputState old_state; |
| 6010 |
| 6011 DISALLOW_COPY_AND_ASSIGN(TextInputStateChangedMessageFilter); |
| 6012 }; |
| 6013 |
| 6014 // Verify that when moving the focus between different frames, the WebContents |
| 6015 // properly keeps track of the text input state. |
| 6016 // The test loads a page with one input field, two out of process frames, and a |
| 6017 // second input field positioned after the last <iframe>. Then a sequence of TAB |
| 6018 // inputs are faked to navigate focus in between the different <input> elements. |
| 6019 // After each change, we check with the RWHV of the frame as well as the |
| 6020 // WebContents to make sure the text input state is as expected. |
| 6021 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, TextInputStateChanged) { |
| 6022 GURL main_page_url(embedded_test_server()->GetURL( |
| 6023 "a.com", "/textinput/page_with_input_iframeX2_input.html")); |
| 6024 NavigateToURL(shell(), main_page_url); |
| 6025 |
| 6026 WebContents* contents = shell()->web_contents(); |
| 6027 |
| 6028 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| 6029 |
| 6030 FrameTreeNode* child_b = root->child_at(0); |
| 6031 GURL child_b_url(embedded_test_server()->GetURL( |
| 6032 "b.com", "/textinput/page_with_input.html")); |
| 6033 NavigateFrameToURL(child_b, child_b_url); |
| 6034 EXPECT_TRUE(WaitForRenderFrameReady(child_b->current_frame_host())); |
| 6035 |
| 6036 FrameTreeNode* child_c = root->child_at(1); |
| 6037 GURL child_c_url(embedded_test_server()->GetURL( |
| 6038 "c.com", "/textinput/page_with_input.html")); |
| 6039 NavigateFrameToURL(child_c, child_c_url); |
| 6040 EXPECT_TRUE(WaitForRenderFrameReady(child_c->current_frame_host())); |
| 6041 |
| 6042 RenderWidgetHostImpl* root_rwh = |
| 6043 root->current_frame_host()->GetRenderWidgetHost(); |
| 6044 RenderWidgetHostViewBase* root_rwhv = root_rwh->GetView(); |
| 6045 |
| 6046 RenderWidgetHostImpl* child_b_rwh = |
| 6047 child_b->current_frame_host()->GetRenderWidgetHost(); |
| 6048 RenderWidgetHostViewBase* child_b_rwhv = child_b_rwh->GetView(); |
| 6049 |
| 6050 RenderWidgetHostImpl* child_c_rwh = |
| 6051 child_c->current_frame_host()->GetRenderWidgetHost(); |
| 6052 RenderWidgetHostViewBase* child_c_rwhv = child_c_rwh->GetView(); |
| 6053 |
| 6054 // Change the text value in <input> field of either frame so that we can |
| 6055 // later track the changes. |
| 6056 EXPECT_TRUE( |
| 6057 ExecuteScript(child_b->current_frame_host(), |
| 6058 "document.querySelector('input').value = 'second';")); |
| 6059 EXPECT_TRUE( |
| 6060 ExecuteScript(child_c->current_frame_host(), |
| 6061 "document.querySelector('input').value = 'third';")); |
| 6062 |
| 6063 // Verfy the input type is none in the begning. |
| 6064 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, root_rwhv->text_input_state()->type); |
| 6065 |
| 6066 // A helper function to send a tab key to the frame and wait for a state |
| 6067 // changed message. |
| 6068 auto press_tab_and_wait_for_text_input_state_change = |
| 6069 [contents](RenderWidgetHostImpl* rwh) { |
| 6070 scoped_refptr<TextInputStateChangedMessageFilter> filter = |
| 6071 new TextInputStateChangedMessageFilter(rwh); |
| 6072 SimulateKeyPress(contents, ui::VKEY_TAB, false, false, false, false); |
| 6073 filter->WaitUntilTextInputStateChanges(); |
| 6074 }; |
| 6075 |
| 6076 // Send focus to the first input field |
| 6077 press_tab_and_wait_for_text_input_state_change(root_rwh); |
| 6078 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, root_rwhv->text_input_state()->type); |
| 6079 EXPECT_EQ("first", root_rwhv->text_input_state()->value); |
| 6080 |
| 6081 // Verify the top-level state is changed. |
| 6082 EXPECT_EQ("first", web_contents()->GetTextInputState().value); |
| 6083 |
| 6084 // Send focus to the input field in frame b. |
| 6085 press_tab_and_wait_for_text_input_state_change(child_b_rwh); |
| 6086 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, child_b_rwhv->text_input_state()->type); |
| 6087 EXPECT_EQ("second", child_b_rwhv->text_input_state()->value); |
| 6088 |
| 6089 EXPECT_EQ("second", web_contents()->GetTextInputState().value); |
| 6090 |
| 6091 // Send focus to the input field in frame c. |
| 6092 press_tab_and_wait_for_text_input_state_change(child_c_rwh); |
| 6093 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, child_c_rwhv->text_input_state()->type); |
| 6094 EXPECT_EQ("third", child_c_rwhv->text_input_state()->value); |
| 6095 |
| 6096 EXPECT_EQ("third", web_contents()->GetTextInputState().value); |
| 6097 |
| 6098 // Send focus to the last input field in top frame. |
| 6099 press_tab_and_wait_for_text_input_state_change(root_rwh); |
| 6100 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, root_rwhv->text_input_state()->type); |
| 6101 EXPECT_EQ("fourth", root_rwhv->text_input_state()->value); |
| 6102 |
| 6103 EXPECT_EQ("fourth", web_contents()->GetTextInputState().value); |
| 6104 } |
| 6105 |
| 6106 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| 6107 TextInputStateChangesAfterRendererCrashes) { |
| 6108 GURL main_url( |
| 6109 embedded_test_server()->GetURL("a.com", "/page_with_iframe.html")); |
| 6110 NavigateToURL(shell(), main_url); |
| 6111 WebContentsImpl* contents = web_contents(); |
| 6112 |
| 6113 FrameTreeNode* root = contents->GetFrameTree()->root(); |
| 6114 |
| 6115 FrameTreeNode* child = root->child_at(0); |
| 6116 GURL child_url(embedded_test_server()->GetURL( |
| 6117 "b.com", "/textinput/page_with_input.html")); |
| 6118 NavigateFrameToURL(child, child_url); |
| 6119 EXPECT_TRUE(WaitForRenderFrameReady(child->current_frame_host())); |
| 6120 |
| 6121 // Verify that the text input state is initially none. |
| 6122 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, contents->GetTextInputState().type); |
| 6123 |
| 6124 auto press_tab_and_wait_for_state_change = |
| 6125 [contents](RenderWidgetHostImpl* rwh) { |
| 6126 scoped_refptr<TextInputStateChangedMessageFilter> filter = |
| 6127 new TextInputStateChangedMessageFilter(rwh); |
| 6128 SimulateKeyPress(contents, ui::VKEY_TAB, false, false, false, false); |
| 6129 filter->WaitUntilTextInputStateChanges(); |
| 6130 }; |
| 6131 |
| 6132 auto crash_renderer_and_wait_for_input_state_none = [contents]( |
| 6133 RenderProcessHost* host) { |
| 6134 RenderProcessHostWatcher crash_observer( |
| 6135 host, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); |
| 6136 host->Shutdown(0, false); |
| 6137 crash_observer.Wait(); |
| 6138 |
| 6139 // We need to wait until the actual text input state update occurs. |
| 6140 while (contents->GetTextInputState().type != ui::TEXT_INPUT_TYPE_NONE) { |
| 6141 scoped_refptr<MessageLoopRunner> loop_runner_ = new MessageLoopRunner(); |
| 6142 BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE, |
| 6143 loop_runner_->QuitClosure(), |
| 6144 base::TimeDelta::FromMilliseconds(0LL)); |
| 6145 loop_runner_->Run(); |
| 6146 } |
| 6147 }; |
| 6148 |
| 6149 // Press a tab key to focus the <input> and verify that the top level |
| 6150 // WebContents sees it. |
| 6151 RenderWidgetHostImpl* child_rwh = |
| 6152 child->current_frame_host()->GetRenderWidgetHost(); |
| 6153 press_tab_and_wait_for_state_change(child_rwh); |
| 6154 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, contents->GetTextInputState().type); |
| 6155 |
| 6156 // Crash the renderer and wait until WebContentsImpl has updates the |
| 6157 // state. |
| 6158 RenderProcessHost* child_process = child_rwh->GetProcess(); |
| 6159 crash_renderer_and_wait_for_input_state_none(child_process); |
| 6160 |
| 6161 // Now repeat the same test for the top level RWHV. |
| 6162 // First remove the <iframe> and append an <input> |
| 6163 EXPECT_TRUE(ExecuteScript(contents, |
| 6164 "var f = document.querySelector('iframe'); " |
| 6165 "f.parentNode.removeChild(f);")); |
| 6166 EXPECT_TRUE(ExecuteScript( |
| 6167 contents, "document.body.appendChild(document.createElement('input'));")); |
| 6168 |
| 6169 // Press tab to focus the <input> and observe the state change. |
| 6170 RenderWidgetHostImpl* root_rwh = |
| 6171 root->current_frame_host()->GetRenderWidgetHost(); |
| 6172 press_tab_and_wait_for_state_change(root_rwh); |
| 6173 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, contents->GetTextInputState().type); |
| 6174 |
| 6175 // Crash the tab renderer and observer the input state going back to none. |
| 6176 RenderProcessHost* host_process = root_rwh->GetProcess(); |
| 6177 crash_renderer_and_wait_for_input_state_none(host_process); |
| 6178 } |
| 6179 |
6107 // Test that a cross-origin iframe can be blocked by X-Frame-Options and CSP | 6180 // Test that a cross-origin iframe can be blocked by X-Frame-Options and CSP |
6108 // frame-ancestors. | 6181 // frame-ancestors. |
6109 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 6182 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
6110 CrossSiteIframeBlockedByXFrameOptionsOrCSP) { | 6183 CrossSiteIframeBlockedByXFrameOptionsOrCSP) { |
6111 GURL main_url(embedded_test_server()->GetURL( | 6184 GURL main_url(embedded_test_server()->GetURL( |
6112 "a.com", "/cross_site_iframe_factory.html?a(a)")); | 6185 "a.com", "/cross_site_iframe_factory.html?a(a)")); |
6113 NavigateToURL(shell(), main_url); | 6186 NavigateToURL(shell(), main_url); |
6114 | 6187 |
6115 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 6188 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
6116 ->GetFrameTree() | |
6117 ->root(); | |
6118 | 6189 |
6119 // Add a load event handler for the iframe element. | 6190 // Add a load event handler for the iframe element. |
6120 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), | 6191 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), |
6121 "document.querySelector('iframe').onload = " | 6192 "document.querySelector('iframe').onload = " |
6122 " function() { document.title = 'loaded'; };")); | 6193 " function() { document.title = 'loaded'; };")); |
6123 | 6194 |
6124 GURL blocked_urls[] = { | 6195 GURL blocked_urls[] = { |
6125 embedded_test_server()->GetURL("b.com", "/frame-ancestors-none.html"), | 6196 embedded_test_server()->GetURL("b.com", "/frame-ancestors-none.html"), |
6126 embedded_test_server()->GetURL("b.com", "/x-frame-options-deny.html") | 6197 embedded_test_server()->GetURL("b.com", "/x-frame-options-deny.html") |
6127 }; | 6198 }; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6175 EXPECT_EQ(blink::WebSandboxFlags::None, | 6246 EXPECT_EQ(blink::WebSandboxFlags::None, |
6176 root->child_at(0)->effective_sandbox_flags()); | 6247 root->child_at(0)->effective_sandbox_flags()); |
6177 } | 6248 } |
6178 } | 6249 } |
6179 | 6250 |
6180 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ScreenCoordinates) { | 6251 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ScreenCoordinates) { |
6181 GURL main_url(embedded_test_server()->GetURL( | 6252 GURL main_url(embedded_test_server()->GetURL( |
6182 "a.com", "/cross_site_iframe_factory.html?a(b)")); | 6253 "a.com", "/cross_site_iframe_factory.html?a(b)")); |
6183 NavigateToURL(shell(), main_url); | 6254 NavigateToURL(shell(), main_url); |
6184 | 6255 |
6185 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 6256 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
6186 ->GetFrameTree() | |
6187 ->root(); | |
6188 FrameTreeNode* child = root->child_at(0); | 6257 FrameTreeNode* child = root->child_at(0); |
6189 | 6258 |
6190 const char* properties[] = {"screenX", "screenY", "outerWidth", | 6259 const char* properties[] = {"screenX", "screenY", "outerWidth", |
6191 "outerHeight"}; | 6260 "outerHeight"}; |
6192 | 6261 |
6193 for (const char* property : properties) { | 6262 for (const char* property : properties) { |
6194 std::string script = "window.domAutomationController.send(window."; | 6263 std::string script = "window.domAutomationController.send(window."; |
6195 script += property; | 6264 script += property; |
6196 script += ");"; | 6265 script += ");"; |
6197 int root_value = 1; | 6266 int root_value = 1; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6292 EXPECT_EQ(b_url, root->current_url()); | 6361 EXPECT_EQ(b_url, root->current_url()); |
6293 | 6362 |
6294 // Verify that the same RenderViewHost is preserved and that it is no longer | 6363 // Verify that the same RenderViewHost is preserved and that it is no longer |
6295 // in swapped out state. | 6364 // in swapped out state. |
6296 EXPECT_EQ(rvh, contents->GetFrameTree()->GetRenderViewHost( | 6365 EXPECT_EQ(rvh, contents->GetFrameTree()->GetRenderViewHost( |
6297 root->current_frame_host()->GetSiteInstance())); | 6366 root->current_frame_host()->GetSiteInstance())); |
6298 EXPECT_FALSE(rvh->is_swapped_out_); | 6367 EXPECT_FALSE(rvh->is_swapped_out_); |
6299 } | 6368 } |
6300 | 6369 |
6301 } // namespace content | 6370 } // namespace content |
OLD | NEW |