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

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

Issue 1652483002: Browser Side Text Input State Tracking for OOPIF. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/site_per_process_browsertest.h" 5 #include "content/browser/site_per_process_browsertest.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 13 matching lines...) Expand all
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
4169 } 4070 }
4170 4071
4171 // Test for https://crbug.com/591478, where navigating to a cross-site page with 4072 // Test for https://crbug.com/591478, where navigating to a cross-site page with
4172 // a subframe on the old site could cause the old RenderViewHost (now pending 4073 // a subframe on the old site could cause the old RenderViewHost (now pending
4173 // deletion) to be reused. 4074 // deletion) to be reused.
4174 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 4075 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
4175 DontReusePendingDeleteRenderViewHostForSubframe) { 4076 DontReusePendingDeleteRenderViewHostForSubframe) {
4176 GURL main_url(embedded_test_server()->GetURL("a.com", "/title1.html")); 4077 GURL main_url(embedded_test_server()->GetURL("a.com", "/title1.html"));
4177 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 4078 EXPECT_TRUE(NavigateToURL(shell(), main_url));
4178 4079
4179 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 4080 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
4180 ->GetFrameTree()
4181 ->root();
4182 RenderViewHostImpl* rvh_a = root->current_frame_host()->render_view_host(); 4081 RenderViewHostImpl* rvh_a = root->current_frame_host()->render_view_host();
4183 int rvh_a_routing_id = rvh_a->GetRoutingID(); 4082 int rvh_a_routing_id = rvh_a->GetRoutingID();
4184 4083
4185 std::string script = 4084 std::string script =
4186 "window.onunload = function() { " 4085 "window.onunload = function() { "
4187 " var start = Date.now();" 4086 " var start = Date.now();"
4188 " while (Date.now() - start < 1000);" 4087 " while (Date.now() - start < 1000);"
4189 "}"; 4088 "}";
4190 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script)); 4089 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script));
4191 4090
(...skipping 10 matching lines...) Expand all
4202 // Check that when a cross-process frame acquires focus, the old focused frame 4101 // 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 4102 // 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 4103 // subframe, simulate mouse clicks to switch focus from root frame to subframe
4205 // and then back to root frame. 4104 // and then back to root frame.
4206 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 4105 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
4207 CrossProcessFocusChangeFiresBlurEvents) { 4106 CrossProcessFocusChangeFiresBlurEvents) {
4208 GURL main_url( 4107 GURL main_url(
4209 embedded_test_server()->GetURL("a.com", "/page_with_input_field.html")); 4108 embedded_test_server()->GetURL("a.com", "/page_with_input_field.html"));
4210 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 4109 EXPECT_TRUE(NavigateToURL(shell(), main_url));
4211 4110
4212 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 4111 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
4213 ->GetFrameTree()
4214 ->root();
4215 4112
4216 EXPECT_EQ( 4113 EXPECT_EQ(
4217 " Site A ------------ proxies for B\n" 4114 " Site A ------------ proxies for B\n"
4218 " +--Site B ------- proxies for A\n" 4115 " +--Site B ------- proxies for A\n"
4219 "Where A = http://a.com/\n" 4116 "Where A = http://a.com/\n"
4220 " B = http://b.com/", 4117 " B = http://b.com/",
4221 DepictFrameTree(root)); 4118 DepictFrameTree(root));
4222 4119
4223 // Focus the main frame's text field. The return value "input-focus" 4120 // Focus the main frame's text field. The return value "input-focus"
4224 // indicates that the focus event was fired correctly. 4121 // indicates that the focus event was fired correctly.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
4264 4161
4265 // Check that when a cross-process subframe is focused, its parent's 4162 // Check that when a cross-process subframe is focused, its parent's
4266 // document.activeElement correctly returns the corresponding <iframe> element. 4163 // 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, 4164 // 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. 4165 // checking document.activeElement after each change.
4269 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DocumentActiveElement) { 4166 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DocumentActiveElement) {
4270 GURL main_url(embedded_test_server()->GetURL( 4167 GURL main_url(embedded_test_server()->GetURL(
4271 "a.com", "/cross_site_iframe_factory.html?a(b(c))")); 4168 "a.com", "/cross_site_iframe_factory.html?a(b(c))"));
4272 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 4169 EXPECT_TRUE(NavigateToURL(shell(), main_url));
4273 4170
4274 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 4171 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
4275 ->GetFrameTree()
4276 ->root();
4277 4172
4278 EXPECT_EQ( 4173 EXPECT_EQ(
4279 " Site A ------------ proxies for B C\n" 4174 " Site A ------------ proxies for B C\n"
4280 " +--Site B ------- proxies for A C\n" 4175 " +--Site B ------- proxies for A C\n"
4281 " +--Site C -- proxies for A B\n" 4176 " +--Site C -- proxies for A B\n"
4282 "Where A = http://a.com/\n" 4177 "Where A = http://a.com/\n"
4283 " B = http://b.com/\n" 4178 " B = http://b.com/\n"
4284 " C = http://c.com/", 4179 " C = http://c.com/",
4285 DepictFrameTree(root)); 4180 DepictFrameTree(root));
4286 4181
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
4343 // The test builds a page with four cross-site frames and then focuses them one 4238 // 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 4239 // 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 4240 // given focused frame, document.hasFocus() should return true for that frame
4346 // and all its ancestor frames. 4241 // and all its ancestor frames.
4347 // Disabled due to flakes; see https://crbug.com/559273. 4242 // Disabled due to flakes; see https://crbug.com/559273.
4348 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DISABLED_DocumentHasFocus) { 4243 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, DISABLED_DocumentHasFocus) {
4349 GURL main_url(embedded_test_server()->GetURL( 4244 GURL main_url(embedded_test_server()->GetURL(
4350 "a.com", "/cross_site_iframe_factory.html?a(b(c),d)")); 4245 "a.com", "/cross_site_iframe_factory.html?a(b(c),d)"));
4351 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 4246 EXPECT_TRUE(NavigateToURL(shell(), main_url));
4352 4247
4353 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 4248 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
4354 ->GetFrameTree()
4355 ->root();
4356 4249
4357 EXPECT_EQ( 4250 EXPECT_EQ(
4358 " Site A ------------ proxies for B C D\n" 4251 " Site A ------------ proxies for B C D\n"
4359 " |--Site B ------- proxies for A C D\n" 4252 " |--Site B ------- proxies for A C D\n"
4360 " | +--Site C -- proxies for A B D\n" 4253 " | +--Site C -- proxies for A B D\n"
4361 " +--Site D ------- proxies for A B C\n" 4254 " +--Site D ------- proxies for A B C\n"
4362 "Where A = http://a.com/\n" 4255 "Where A = http://a.com/\n"
4363 " B = http://b.com/\n" 4256 " B = http://b.com/\n"
4364 " C = http://c.com/\n" 4257 " C = http://c.com/\n"
4365 " D = http://d.com/", 4258 " D = http://d.com/",
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
4411 EXPECT_FALSE(document_has_focus(grandchild)); 4304 EXPECT_FALSE(document_has_focus(grandchild));
4412 EXPECT_TRUE(document_has_focus(child2)); 4305 EXPECT_TRUE(document_has_focus(child2));
4413 } 4306 }
4414 4307
4415 // Check that window.focus works for cross-process subframes. 4308 // Check that window.focus works for cross-process subframes.
4416 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, SubframeWindowFocus) { 4309 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, SubframeWindowFocus) {
4417 GURL main_url(embedded_test_server()->GetURL( 4310 GURL main_url(embedded_test_server()->GetURL(
4418 "a.com", "/cross_site_iframe_factory.html?a(b,c)")); 4311 "a.com", "/cross_site_iframe_factory.html?a(b,c)"));
4419 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 4312 EXPECT_TRUE(NavigateToURL(shell(), main_url));
4420 4313
4421 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 4314 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
4422 ->GetFrameTree()
4423 ->root();
4424 4315
4425 EXPECT_EQ( 4316 EXPECT_EQ(
4426 " Site A ------------ proxies for B C\n" 4317 " Site A ------------ proxies for B C\n"
4427 " |--Site B ------- proxies for A C\n" 4318 " |--Site B ------- proxies for A C\n"
4428 " +--Site C ------- proxies for A B\n" 4319 " +--Site C ------- proxies for A B\n"
4429 "Where A = http://a.com/\n" 4320 "Where A = http://a.com/\n"
4430 " B = http://b.com/\n" 4321 " B = http://b.com/\n"
4431 " C = http://c.com/", 4322 " C = http://c.com/",
4432 DepictFrameTree(root)); 4323 DepictFrameTree(root));
4433 4324
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
4550 4441
4551 // Verify that we receive a mouse cursor update message when we mouse over 4442 // Verify that we receive a mouse cursor update message when we mouse over
4552 // a text field contained in an out-of-process iframe. 4443 // a text field contained in an out-of-process iframe.
4553 // Fails under TSan. http://crbug.com/545237 4444 // Fails under TSan. http://crbug.com/545237
4554 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 4445 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
4555 DISABLED_CursorUpdateFromReceivedFromCrossSiteIframe) { 4446 DISABLED_CursorUpdateFromReceivedFromCrossSiteIframe) {
4556 GURL main_url(embedded_test_server()->GetURL( 4447 GURL main_url(embedded_test_server()->GetURL(
4557 "/frame_tree/page_with_positioned_frame.html")); 4448 "/frame_tree/page_with_positioned_frame.html"));
4558 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 4449 EXPECT_TRUE(NavigateToURL(shell(), main_url));
4559 4450
4560 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 4451 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
4561 ->GetFrameTree()
4562 ->root();
4563 4452
4564 FrameTreeNode* child_node = root->child_at(0); 4453 FrameTreeNode* child_node = root->child_at(0);
4565 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), 4454 EXPECT_NE(shell()->web_contents()->GetSiteInstance(),
4566 child_node->current_frame_host()->GetSiteInstance()); 4455 child_node->current_frame_host()->GetSiteInstance());
4567 4456
4568 scoped_refptr<CursorMessageFilter> filter = new CursorMessageFilter(); 4457 scoped_refptr<CursorMessageFilter> filter = new CursorMessageFilter();
4569 child_node->current_frame_host()->GetProcess()->AddFilter(filter.get()); 4458 child_node->current_frame_host()->GetProcess()->AddFilter(filter.get());
4570 4459
4571 // Send a MouseMove to the subframe. The frame contains text, and moving the 4460 // 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. 4461 // mouse over it should cause the renderer to send a mouse cursor update.
4573 blink::WebMouseEvent mouse_event; 4462 blink::WebMouseEvent mouse_event;
4574 mouse_event.type = blink::WebInputEvent::MouseMove; 4463 mouse_event.type = blink::WebInputEvent::MouseMove;
4575 mouse_event.x = 60; 4464 mouse_event.x = 60;
4576 mouse_event.y = 60; 4465 mouse_event.y = 60;
4577 RenderWidgetHost* rwh_child = 4466 RenderWidgetHost* rwh_child =
4578 root->child_at(0)->current_frame_host()->GetRenderWidgetHost(); 4467 root->child_at(0)->current_frame_host()->GetRenderWidgetHost();
4579 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( 4468 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>(
4580 root->current_frame_host()->GetRenderWidgetHost()->GetView()); 4469 root->current_frame_host()->GetRenderWidgetHost()->GetView());
4581 static_cast<WebContentsImpl*>(shell()->web_contents()) 4470 web_contents()->GetInputEventRouter()->RouteMouseEvent(root_view,
4582 ->GetInputEventRouter() 4471 &mouse_event);
4583 ->RouteMouseEvent(root_view, &mouse_event);
4584 4472
4585 // CursorMessageFilter::Wait() implicitly tests whether we receive a 4473 // CursorMessageFilter::Wait() implicitly tests whether we receive a
4586 // ViewHostMsg_SetCursor message from the renderer process, because it does 4474 // ViewHostMsg_SetCursor message from the renderer process, because it does
4587 // does not return otherwise. 4475 // does not return otherwise.
4588 filter->Wait(); 4476 filter->Wait();
4589 EXPECT_EQ(filter->last_set_cursor_routing_id(), rwh_child->GetRoutingID()); 4477 EXPECT_EQ(filter->last_set_cursor_routing_id(), rwh_child->GetRoutingID());
4590 } 4478 }
4591 #endif 4479 #endif
4592 4480
4593 // Tests that we are using the correct RenderFrameProxy when navigating an 4481 // Tests that we are using the correct RenderFrameProxy when navigating an
(...skipping 22 matching lines...) Expand all
4616 #if defined(USE_AURA) 4504 #if defined(USE_AURA)
4617 // Browser process hit testing is not implemented on Android, and this test 4505 // Browser process hit testing is not implemented on Android, and this test
4618 // requires Aura for RenderWidgetHostViewAura::OnTouchEvent(). 4506 // requires Aura for RenderWidgetHostViewAura::OnTouchEvent().
4619 // https://crbug.com/491334 4507 // https://crbug.com/491334
4620 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 4508 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
4621 SubframeTouchEventRouting) { 4509 SubframeTouchEventRouting) {
4622 GURL main_url(embedded_test_server()->GetURL( 4510 GURL main_url(embedded_test_server()->GetURL(
4623 "/frame_tree/page_with_positioned_nested_frames.html")); 4511 "/frame_tree/page_with_positioned_nested_frames.html"));
4624 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 4512 EXPECT_TRUE(NavigateToURL(shell(), main_url));
4625 4513
4626 WebContentsImpl* web_contents = 4514 WebContentsImpl* contents = web_contents();
4627 static_cast<WebContentsImpl*>(shell()->web_contents()); 4515 FrameTreeNode* root = contents->GetFrameTree()->root();
4628 FrameTreeNode* root = web_contents->GetFrameTree()->root();
4629 ASSERT_EQ(1U, root->child_count()); 4516 ASSERT_EQ(1U, root->child_count());
4630 4517
4631 GURL frame_url( 4518 GURL frame_url(
4632 embedded_test_server()->GetURL("b.com", "/page_with_touch_handler.html")); 4519 embedded_test_server()->GetURL("b.com", "/page_with_touch_handler.html"));
4633 NavigateFrameToURL(root->child_at(0), frame_url); 4520 NavigateFrameToURL(root->child_at(0), frame_url);
4634 4521
4635 // Synchronize with the child and parent renderers to guarantee that the 4522 // Synchronize with the child and parent renderers to guarantee that the
4636 // surface information required for event hit testing is ready. 4523 // surface information required for event hit testing is ready.
4637 RenderWidgetHostViewBase* child_rwhv = static_cast<RenderWidgetHostViewBase*>( 4524 RenderWidgetHostViewBase* child_rwhv = static_cast<RenderWidgetHostViewBase*>(
4638 root->child_at(0)->current_frame_host()->GetView()); 4525 root->child_at(0)->current_frame_host()->GetView());
4639 SurfaceHitTestReadyNotifier notifier( 4526 SurfaceHitTestReadyNotifier notifier(
4640 static_cast<RenderWidgetHostViewChildFrame*>(child_rwhv)); 4527 static_cast<RenderWidgetHostViewChildFrame*>(child_rwhv));
4641 notifier.WaitForSurfaceReady(); 4528 notifier.WaitForSurfaceReady();
4642 4529
4643 // Simulate touch event to sub-frame. 4530 // Simulate touch event to sub-frame.
4644 gfx::Point child_center(150, 150); 4531 gfx::Point child_center(150, 150);
4645 auto rwhv = static_cast<RenderWidgetHostViewAura*>( 4532 auto rwhv = static_cast<RenderWidgetHostViewAura*>(
4646 web_contents->GetRenderWidgetHostView()); 4533 contents->GetRenderWidgetHostView());
4647 ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, child_center, 0, 0, 4534 ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, child_center, 0, 0,
4648 ui::EventTimeForNow(), 30.f, 30.f, 0.f, 0.f); 4535 ui::EventTimeForNow(), 30.f, 30.f, 0.f, 0.f);
4649 rwhv->OnTouchEvent(&touch_event); 4536 rwhv->OnTouchEvent(&touch_event);
4650 4537
4651 // Verify touch handler in subframe was invoked 4538 // Verify touch handler in subframe was invoked
4652 std::string result; 4539 std::string result;
4653 EXPECT_TRUE(ExecuteScriptAndExtractString( 4540 EXPECT_TRUE(ExecuteScriptAndExtractString(
4654 root->child_at(0)->current_frame_host(), 4541 root->child_at(0)->current_frame_host(),
4655 "window.domAutomationController.send(getLastTouchEvent());", &result)); 4542 "window.domAutomationController.send(getLastTouchEvent());", &result));
4656 EXPECT_EQ("touchstart", result); 4543 EXPECT_EQ("touchstart", result);
(...skipping 15 matching lines...) Expand all
4672 #define MAYBE_SubframeGestureEventRouting DISABLED_SubframeGestureEventRouting 4559 #define MAYBE_SubframeGestureEventRouting DISABLED_SubframeGestureEventRouting
4673 #else 4560 #else
4674 #define MAYBE_SubframeGestureEventRouting SubframeGestureEventRouting 4561 #define MAYBE_SubframeGestureEventRouting SubframeGestureEventRouting
4675 #endif 4562 #endif
4676 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 4563 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
4677 MAYBE_SubframeGestureEventRouting) { 4564 MAYBE_SubframeGestureEventRouting) {
4678 GURL main_url(embedded_test_server()->GetURL( 4565 GURL main_url(embedded_test_server()->GetURL(
4679 "/frame_tree/page_with_positioned_nested_frames.html")); 4566 "/frame_tree/page_with_positioned_nested_frames.html"));
4680 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 4567 EXPECT_TRUE(NavigateToURL(shell(), main_url));
4681 4568
4682 WebContentsImpl* web_contents = 4569 WebContentsImpl* contents = web_contents();
4683 static_cast<WebContentsImpl*>(shell()->web_contents()); 4570 FrameTreeNode* root = contents->GetFrameTree()->root();
4684 FrameTreeNode* root = web_contents->GetFrameTree()->root();
4685 ASSERT_EQ(1U, root->child_count()); 4571 ASSERT_EQ(1U, root->child_count());
4686 4572
4687 GURL frame_url( 4573 GURL frame_url(
4688 embedded_test_server()->GetURL("b.com", "/page_with_click_handler.html")); 4574 embedded_test_server()->GetURL("b.com", "/page_with_click_handler.html"));
4689 NavigateFrameToURL(root->child_at(0), frame_url); 4575 NavigateFrameToURL(root->child_at(0), frame_url);
4690 auto child_frame_host = root->child_at(0)->current_frame_host(); 4576 auto child_frame_host = root->child_at(0)->current_frame_host();
4691 4577
4692 // Synchronize with the child and parent renderers to guarantee that the 4578 // Synchronize with the child and parent renderers to guarantee that the
4693 // surface information required for event hit testing is ready. 4579 // surface information required for event hit testing is ready.
4694 RenderWidgetHostViewBase* child_rwhv = static_cast<RenderWidgetHostViewBase*>( 4580 RenderWidgetHostViewBase* child_rwhv = static_cast<RenderWidgetHostViewBase*>(
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
4807 } 4693 }
4808 4694
4809 } // namespace anonymous 4695 } // namespace anonymous
4810 4696
4811 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 4697 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
4812 InputEventRouterGestureTargetQueueTest) { 4698 InputEventRouterGestureTargetQueueTest) {
4813 GURL main_url(embedded_test_server()->GetURL( 4699 GURL main_url(embedded_test_server()->GetURL(
4814 "/frame_tree/page_with_positioned_nested_frames.html")); 4700 "/frame_tree/page_with_positioned_nested_frames.html"));
4815 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 4701 EXPECT_TRUE(NavigateToURL(shell(), main_url));
4816 4702
4817 WebContentsImpl* web_contents = 4703 WebContentsImpl* contents = web_contents();
4818 static_cast<WebContentsImpl*>(shell()->web_contents()); 4704 FrameTreeNode* root = contents->GetFrameTree()->root();
4819 FrameTreeNode* root = web_contents->GetFrameTree()->root();
4820 ASSERT_EQ(1U, root->child_count()); 4705 ASSERT_EQ(1U, root->child_count());
4821 4706
4822 GURL frame_url( 4707 GURL frame_url(
4823 embedded_test_server()->GetURL("b.com", "/page_with_click_handler.html")); 4708 embedded_test_server()->GetURL("b.com", "/page_with_click_handler.html"));
4824 NavigateFrameToURL(root->child_at(0), frame_url); 4709 NavigateFrameToURL(root->child_at(0), frame_url);
4825 auto child_frame_host = root->child_at(0)->current_frame_host(); 4710 auto child_frame_host = root->child_at(0)->current_frame_host();
4826 4711
4827 // Synchronize with the child and parent renderers to guarantee that the 4712 // Synchronize with the child and parent renderers to guarantee that the
4828 // surface information required for event hit testing is ready. 4713 // surface information required for event hit testing is ready.
4829 auto rwhv_child = 4714 auto rwhv_child =
4830 static_cast<RenderWidgetHostViewBase*>(child_frame_host->GetView()); 4715 static_cast<RenderWidgetHostViewBase*>(child_frame_host->GetView());
4831 SurfaceHitTestReadyNotifier notifier( 4716 SurfaceHitTestReadyNotifier notifier(
4832 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_child)); 4717 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_child));
4833 notifier.WaitForSurfaceReady(); 4718 notifier.WaitForSurfaceReady();
4834 4719
4835 // All touches & gestures are sent to the main frame's view, and should be 4720 // All touches & gestures are sent to the main frame's view, and should be
4836 // routed appropriately from there. 4721 // routed appropriately from there.
4837 auto rwhv_parent = static_cast<RenderWidgetHostViewBase*>( 4722 auto rwhv_parent = static_cast<RenderWidgetHostViewBase*>(
4838 web_contents->GetRenderWidgetHostView()); 4723 contents->GetRenderWidgetHostView());
4839 4724
4840 RenderWidgetHostInputEventRouter* router = 4725 RenderWidgetHostInputEventRouter* router = contents->GetInputEventRouter();
4841 web_contents->GetInputEventRouter();
4842 EXPECT_TRUE(router->gesture_target_queue_.empty()); 4726 EXPECT_TRUE(router->gesture_target_queue_.empty());
4843 EXPECT_EQ(nullptr, router->gesture_target_); 4727 EXPECT_EQ(nullptr, router->gesture_target_);
4844 4728
4845 // Send touch sequence to main-frame. 4729 // Send touch sequence to main-frame.
4846 gfx::Point main_frame_point(25, 25); 4730 gfx::Point main_frame_point(25, 25);
4847 SendTouchTapWithExpectedTarget(rwhv_parent, main_frame_point, 4731 SendTouchTapWithExpectedTarget(rwhv_parent, main_frame_point,
4848 router->touch_target_, rwhv_parent); 4732 router->touch_target_, rwhv_parent);
4849 EXPECT_EQ(1LU, router->gesture_target_queue_.size()); 4733 EXPECT_EQ(1LU, router->gesture_target_queue_.size());
4850 EXPECT_EQ(nullptr, router->gesture_target_); 4734 EXPECT_EQ(nullptr, router->gesture_target_);
4851 4735
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
4895 #endif // defined(USE_AURA) 4779 #endif // defined(USE_AURA)
4896 4780
4897 // Ensure that a cross-process subframe can receive keyboard events when in 4781 // Ensure that a cross-process subframe can receive keyboard events when in
4898 // focus. Flaky: https://crbug.com/596508. 4782 // focus. Flaky: https://crbug.com/596508.
4899 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 4783 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
4900 DISABLED_SubframeKeyboardEventRouting) { 4784 DISABLED_SubframeKeyboardEventRouting) {
4901 GURL main_url(embedded_test_server()->GetURL( 4785 GURL main_url(embedded_test_server()->GetURL(
4902 "a.com", "/frame_tree/page_with_one_frame.html")); 4786 "a.com", "/frame_tree/page_with_one_frame.html"));
4903 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 4787 EXPECT_TRUE(NavigateToURL(shell(), main_url));
4904 4788
4905 WebContentsImpl* web_contents = 4789 WebContentsImpl* contents = web_contents();
4906 static_cast<WebContentsImpl*>(shell()->web_contents()); 4790 FrameTreeNode* root = contents->GetFrameTree()->root();
4907 FrameTreeNode* root = web_contents->GetFrameTree()->root();
4908 4791
4909 GURL frame_url( 4792 GURL frame_url(
4910 embedded_test_server()->GetURL("b.com", "/page_with_input_field.html")); 4793 embedded_test_server()->GetURL("b.com", "/page_with_input_field.html"));
4911 NavigateFrameToURL(root->child_at(0), frame_url); 4794 NavigateFrameToURL(root->child_at(0), frame_url);
4912 4795
4913 // Focus the subframe and then its input field. The return value 4796 // 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. 4797 // "input-focus" will be sent once the input field's focus event fires.
4915 FocusFrame(root->child_at(0)); 4798 FocusFrame(root->child_at(0));
4916 std::string result; 4799 std::string result;
4917 EXPECT_TRUE(ExecuteScriptAndExtractString( 4800 EXPECT_TRUE(ExecuteScriptAndExtractString(
4918 root->child_at(0)->current_frame_host(), "focusInputField()", &result)); 4801 root->child_at(0)->current_frame_host(), "focusInputField()", &result));
4919 EXPECT_EQ(result, "input-focus"); 4802 EXPECT_EQ(result, "input-focus");
4920 4803
4921 // The subframe should now be focused. 4804 // The subframe should now be focused.
4922 EXPECT_EQ(root->child_at(0), root->frame_tree()->GetFocusedFrame()); 4805 EXPECT_EQ(root->child_at(0), root->frame_tree()->GetFocusedFrame());
4923 4806
4924 // Generate a few keyboard events and route them to currently focused frame. 4807 // Generate a few keyboard events and route them to currently focused frame.
4925 SimulateKeyPress(web_contents, ui::VKEY_F, false, false, false, false); 4808 SimulateKeyPress(contents, ui::VKEY_F, false, false, false, false);
4926 SimulateKeyPress(web_contents, ui::VKEY_O, false, false, false, false); 4809 SimulateKeyPress(contents, ui::VKEY_O, false, false, false, false);
4927 SimulateKeyPress(web_contents, ui::VKEY_O, false, false, false, false); 4810 SimulateKeyPress(contents, ui::VKEY_O, false, false, false, false);
4928 4811
4929 // Verify that the input field in the subframe received the keystrokes. 4812 // Verify that the input field in the subframe received the keystrokes.
4930 EXPECT_TRUE(ExecuteScriptAndExtractString( 4813 EXPECT_TRUE(ExecuteScriptAndExtractString(
4931 root->child_at(0)->current_frame_host(), 4814 root->child_at(0)->current_frame_host(),
4932 "window.domAutomationController.send(getInputFieldText());", &result)); 4815 "window.domAutomationController.send(getInputFieldText());", &result));
4933 EXPECT_EQ("FOO", result); 4816 EXPECT_EQ("FOO", result);
4934 } 4817 }
4935 4818
4936 // Ensure that sequential focus navigation (advancing focused elements with 4819 // Ensure that sequential focus navigation (advancing focused elements with
4937 // <tab> and <shift-tab>) works across cross-process subframes. 4820 // <tab> and <shift-tab>) works across cross-process subframes.
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
5045 private: 4928 private:
5046 bool context_menu_created_; 4929 bool context_menu_created_;
5047 ContextMenuParams menu_params_; 4930 ContextMenuParams menu_params_;
5048 4931
5049 // The MessageLoopRunner used to spin the message loop. 4932 // The MessageLoopRunner used to spin the message loop.
5050 scoped_refptr<MessageLoopRunner> message_loop_runner_; 4933 scoped_refptr<MessageLoopRunner> message_loop_runner_;
5051 4934
5052 DISALLOW_COPY_AND_ASSIGN(ContextMenuObserverDelegate); 4935 DISALLOW_COPY_AND_ASSIGN(ContextMenuObserverDelegate);
5053 }; 4936 };
5054 4937
5055 // Test that a mouse right-click to an out-of-process iframe causes a context 4938 // Helper function to run the CreateContextMenuTest in either normal
Charlie Reis 2016/04/01 21:24:09 Why is this in your CL? This seems unrelated. Is
EhsanK 2016/04/02 03:14:02 I guess it is. Sorry about that. I reverted the re
5056 // menu to be generated with the correct screen position. 4939 // or high DPI mode.
5057 #if defined(OS_ANDROID) 4940 void CreateContextMenuTestHelper(
5058 // Browser process hit testing is not implemented on Android. 4941 Shell* shell,
5059 // https://crbug.com/491334 4942 net::test_server::EmbeddedTestServer* embedded_test_server) {
5060 #define MAYBE_CreateContextMenuTest DISABLED_CreateContextMenuTest 4943 GURL main_url(embedded_test_server->GetURL(
5061 #else
5062 #define MAYBE_CreateContextMenuTest CreateContextMenuTest
5063 #endif
5064 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_CreateContextMenuTest) {
5065 GURL main_url(embedded_test_server()->GetURL(
5066 "/frame_tree/page_with_positioned_frame.html")); 4944 "/frame_tree/page_with_positioned_frame.html"));
5067 NavigateToURL(shell(), main_url); 4945 EXPECT_TRUE(NavigateToURL(shell, main_url));
5068 4946
5069 // It is safe to obtain the root frame tree node here, as it doesn't change. 4947 // 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()) 4948 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell->web_contents())
5071 ->GetFrameTree() 4949 ->GetFrameTree()
5072 ->root(); 4950 ->root();
5073 ASSERT_EQ(1U, root->child_count()); 4951 ASSERT_EQ(1U, root->child_count());
5074 4952
5075 FrameTreeNode* child_node = root->child_at(0); 4953 FrameTreeNode* child_node = root->child_at(0);
5076 GURL site_url(embedded_test_server()->GetURL("baz.com", "/title1.html")); 4954 GURL site_url(embedded_test_server->GetURL("baz.com", "/title1.html"));
5077 EXPECT_EQ(site_url, child_node->current_url()); 4955 EXPECT_EQ(site_url, child_node->current_url());
5078 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), 4956 EXPECT_NE(shell->web_contents()->GetSiteInstance(),
5079 child_node->current_frame_host()->GetSiteInstance()); 4957 child_node->current_frame_host()->GetSiteInstance());
5080 4958
5081 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>( 4959 RenderWidgetHostViewBase* root_view = static_cast<RenderWidgetHostViewBase*>(
5082 root->current_frame_host()->GetRenderWidgetHost()->GetView()); 4960 root->current_frame_host()->GetRenderWidgetHost()->GetView());
5083 RenderWidgetHostViewBase* rwhv_child = static_cast<RenderWidgetHostViewBase*>( 4961 RenderWidgetHostViewBase* rwhv_child = static_cast<RenderWidgetHostViewBase*>(
5084 child_node->current_frame_host()->GetRenderWidgetHost()->GetView()); 4962 child_node->current_frame_host()->GetRenderWidgetHost()->GetView());
5085 4963
5086 // Ensure that the child process renderer is ready to have input events 4964 // Ensure that the child process renderer is ready to have input events
5087 // routed to it. This happens when the browser process has received 4965 // routed to it. This happens when the browser process has received
5088 // updated compositor surfaces from both renderer processes. 4966 // updated compositor surfaces from both renderer processes.
5089 gfx::Point point(75, 75); 4967 SurfaceHitTestReadyNotifier notifier(
5090 gfx::Point transformed_point; 4968 static_cast<RenderWidgetHostViewChildFrame*>(rwhv_child));
5091 while (root_view->SurfaceIdNamespaceAtPoint(nullptr, point, 4969 notifier.WaitForSurfaceReady();
5092 &transformed_point) !=
5093 rwhv_child->GetSurfaceIdNamespace()) {
5094 base::RunLoop run_loop;
5095 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
5096 FROM_HERE, run_loop.QuitClosure(), TestTimeouts::tiny_timeout());
5097 run_loop.Run();
5098 }
5099 4970
5100 // A WebContentsDelegate to listen for the ShowContextMenu message. 4971 // A WebContentsDelegate to listen for the ShowContextMenu message.
5101 ContextMenuObserverDelegate context_menu_delegate; 4972 ContextMenuObserverDelegate context_menu_delegate;
5102 shell()->web_contents()->SetDelegate(&context_menu_delegate); 4973 shell->web_contents()->SetDelegate(&context_menu_delegate);
5103 4974
5104 RenderWidgetHostInputEventRouter* router = 4975 RenderWidgetHostInputEventRouter* router =
5105 static_cast<WebContentsImpl*>(shell()->web_contents()) 4976 static_cast<WebContentsImpl*>(shell->web_contents())
5106 ->GetInputEventRouter(); 4977 ->GetInputEventRouter();
5107 4978
4979 gfx::Point point(75, 75);
4980
5108 // Target right-click event to child frame. 4981 // Target right-click event to child frame.
5109 blink::WebMouseEvent click_event; 4982 blink::WebMouseEvent click_event;
5110 click_event.type = blink::WebInputEvent::MouseDown; 4983 click_event.type = blink::WebInputEvent::MouseDown;
5111 click_event.button = blink::WebPointerProperties::ButtonRight; 4984 click_event.button = blink::WebPointerProperties::ButtonRight;
5112 click_event.x = 75; 4985 click_event.x = point.x();
5113 click_event.y = 75; 4986 click_event.y = point.y();
5114 click_event.clickCount = 1; 4987 click_event.clickCount = 1;
5115 router->RouteMouseEvent(root_view, &click_event); 4988 router->RouteMouseEvent(root_view, &click_event);
5116 4989
5117 // We also need a MouseUp event, needed by Windows. 4990 // We also need a MouseUp event, needed by Windows.
5118 click_event.type = blink::WebInputEvent::MouseUp; 4991 click_event.type = blink::WebInputEvent::MouseUp;
5119 click_event.x = 75; 4992 click_event.x = point.x();
5120 click_event.y = 75; 4993 click_event.y = point.y();
5121 router->RouteMouseEvent(root_view, &click_event); 4994 router->RouteMouseEvent(root_view, &click_event);
5122 4995
5123 context_menu_delegate.Wait(); 4996 context_menu_delegate.Wait();
5124 4997
5125 ContextMenuParams params = context_menu_delegate.getParams(); 4998 ContextMenuParams params = context_menu_delegate.getParams();
5126 4999
5127 EXPECT_EQ(point.x(), params.x); 5000 EXPECT_EQ(point.x(), params.x);
5128 EXPECT_EQ(point.y(), params.y); 5001 EXPECT_EQ(point.y(), params.y);
5129 } 5002 }
5130 5003
5004 // Test that a mouse right-click to an out-of-process iframe causes a context
5005 // menu to be generated with the correct screen position.
5006 #if defined(OS_ANDROID)
5007 // Browser process hit testing is not implemented on Android.
5008 // https://crbug.com/491334
5009 #define MAYBE_CreateContextMenuTest DISABLED_CreateContextMenuTest
5010 #else
5011 #define MAYBE_CreateContextMenuTest CreateContextMenuTest
5012 #endif
5013 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_CreateContextMenuTest) {
5014 CreateContextMenuTestHelper(shell(), embedded_test_server());
5015 }
5016
5017 // Test that a mouse right-click to an out-of-process iframe causes a context
5018 // menu to be generated with the correct screen position on a screen with
5019 // non-default scale factor.
5020 #if defined(OS_ANDROID) || defined(OS_WIN)
5021 // Browser process hit testing is not implemented on Android.
5022 // https://crbug.com/491334
5023 // Windows is disabled because of https://crbug.com/545547.
5024 #define MAYBE_HighDPICreateContextMenuTest DISABLED_HighDPICreateContextMenuTest
5025 #else
5026 #define MAYBE_HighDPICreateContextMenuTest HighDPICreateContextMenuTest
5027 #endif
5028 IN_PROC_BROWSER_TEST_F(SitePerProcessHighDPIBrowserTest,
5029 MAYBE_HighDPICreateContextMenuTest) {
5030 CreateContextMenuTestHelper(shell(), embedded_test_server());
5031 }
5032
5131 class ShowWidgetMessageFilter : public content::BrowserMessageFilter { 5033 class ShowWidgetMessageFilter : public content::BrowserMessageFilter {
5132 public: 5034 public:
5133 ShowWidgetMessageFilter() 5035 ShowWidgetMessageFilter()
5134 #if defined(OS_MACOSX) || defined(OS_ANDROID) 5036 #if defined(OS_MACOSX) || defined(OS_ANDROID)
5135 : content::BrowserMessageFilter(FrameMsgStart), 5037 : content::BrowserMessageFilter(FrameMsgStart),
5136 #else 5038 #else
5137 : content::BrowserMessageFilter(ViewMsgStart), 5039 : content::BrowserMessageFilter(ViewMsgStart),
5138 #endif 5040 #endif
5139 message_loop_runner_(new content::MessageLoopRunner) { 5041 message_loop_runner_(new content::MessageLoopRunner) {
5140 } 5042 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
5199 // on Android. 5101 // on Android.
5200 #define MAYBE_PopupMenuTest DISABLED_PopupMenuTest 5102 #define MAYBE_PopupMenuTest DISABLED_PopupMenuTest
5201 #else 5103 #else
5202 #define MAYBE_PopupMenuTest PopupMenuTest 5104 #define MAYBE_PopupMenuTest PopupMenuTest
5203 #endif 5105 #endif
5204 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_PopupMenuTest) { 5106 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_PopupMenuTest) {
5205 GURL main_url( 5107 GURL main_url(
5206 embedded_test_server()->GetURL("/cross_site_iframe_factory.html?a(a)")); 5108 embedded_test_server()->GetURL("/cross_site_iframe_factory.html?a(a)"));
5207 NavigateToURL(shell(), main_url); 5109 NavigateToURL(shell(), main_url);
5208 5110
5209 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 5111 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
5210 ->GetFrameTree()
5211 ->root();
5212 5112
5213 #if !defined(OS_MACOSX) 5113 #if !defined(OS_MACOSX)
5214 // Unused variable on Mac. 5114 // Unused variable on Mac.
5215 RenderWidgetHostViewBase* rwhv_root = static_cast<RenderWidgetHostViewBase*>( 5115 RenderWidgetHostViewBase* rwhv_root = static_cast<RenderWidgetHostViewBase*>(
5216 root->current_frame_host()->GetRenderWidgetHost()->GetView()); 5116 root->current_frame_host()->GetRenderWidgetHost()->GetView());
5217 #endif 5117 #endif
5218 static_cast<WebContentsImpl*>(shell()->web_contents())->SendScreenRects(); 5118 web_contents()->SendScreenRects();
5219 5119
5220 content::TestNavigationObserver navigation_observer(shell()->web_contents()); 5120 content::TestNavigationObserver navigation_observer(shell()->web_contents());
5221 FrameTreeNode* child_node = root->child_at(0); 5121 FrameTreeNode* child_node = root->child_at(0);
5222 GURL site_url(embedded_test_server()->GetURL( 5122 GURL site_url(embedded_test_server()->GetURL(
5223 "baz.com", "/site_isolation/page-with-select.html")); 5123 "baz.com", "/site_isolation/page-with-select.html"));
5224 NavigateFrameToURL(child_node, site_url); 5124 NavigateFrameToURL(child_node, site_url);
5225 navigation_observer.Wait(); 5125 navigation_observer.Wait();
5226 5126
5227 RenderWidgetHostViewBase* rwhv_child = static_cast<RenderWidgetHostViewBase*>( 5127 RenderWidgetHostViewBase* rwhv_child = static_cast<RenderWidgetHostViewBase*>(
5228 child_node->current_frame_host()->GetRenderWidgetHost()->GetView()); 5128 child_node->current_frame_host()->GetRenderWidgetHost()->GetView());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
5269 // Android. 5169 // Android.
5270 #define MAYBE_NestedPopupMenuTest DISABLED_NestedPopupMenuTest 5170 #define MAYBE_NestedPopupMenuTest DISABLED_NestedPopupMenuTest
5271 #else 5171 #else
5272 #define MAYBE_NestedPopupMenuTest NestedPopupMenuTest 5172 #define MAYBE_NestedPopupMenuTest NestedPopupMenuTest
5273 #endif 5173 #endif
5274 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_NestedPopupMenuTest) { 5174 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, MAYBE_NestedPopupMenuTest) {
5275 GURL main_url(embedded_test_server()->GetURL( 5175 GURL main_url(embedded_test_server()->GetURL(
5276 "/cross_site_iframe_factory.html?a(b(c))")); 5176 "/cross_site_iframe_factory.html?a(b(c))"));
5277 NavigateToURL(shell(), main_url); 5177 NavigateToURL(shell(), main_url);
5278 5178
5279 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 5179 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
5280 ->GetFrameTree()
5281 ->root();
5282 5180
5283 #if !defined(OS_MACOSX) 5181 #if !defined(OS_MACOSX)
5284 // Undefined variable on Mac. 5182 // Undefined variable on Mac.
5285 RenderWidgetHostViewBase* rwhv_root = static_cast<RenderWidgetHostViewBase*>( 5183 RenderWidgetHostViewBase* rwhv_root = static_cast<RenderWidgetHostViewBase*>(
5286 root->current_frame_host()->GetRenderWidgetHost()->GetView()); 5184 root->current_frame_host()->GetRenderWidgetHost()->GetView());
5287 #endif 5185 #endif
5288 static_cast<WebContentsImpl*>(shell()->web_contents())->SendScreenRects(); 5186 web_contents()->SendScreenRects();
5289 5187
5290 // For clarity, we are labeling the frame tree nodes as: 5188 // For clarity, we are labeling the frame tree nodes as:
5291 // - root_node 5189 // - root_node
5292 // \-> b_node (out-of-process from root and c_node) 5190 // \-> b_node (out-of-process from root and c_node)
5293 // \-> c_node (out-of-process from root and b_node) 5191 // \-> c_node (out-of-process from root and b_node)
5294 5192
5295 content::TestNavigationObserver navigation_observer(shell()->web_contents()); 5193 content::TestNavigationObserver navigation_observer(shell()->web_contents());
5296 FrameTreeNode* b_node = root->child_at(0); 5194 FrameTreeNode* b_node = root->child_at(0);
5297 FrameTreeNode* c_node = b_node->child_at(0); 5195 FrameTreeNode* c_node = b_node->child_at(0);
5298 GURL site_url(embedded_test_server()->GetURL( 5196 GURL site_url(embedded_test_server()->GetURL(
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
5555 // if a pending cross-process navigation is cancelled. The test works by trying 5453 // 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 5454 // 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. 5455 // entry with the same routing ID, a CHECK is hit and the process crashes.
5558 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 5456 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
5559 SubframePendingAndBackToSameSiteInstance) { 5457 SubframePendingAndBackToSameSiteInstance) {
5560 GURL main_url(embedded_test_server()->GetURL( 5458 GURL main_url(embedded_test_server()->GetURL(
5561 "a.com", "/cross_site_iframe_factory.html?a(b)")); 5459 "a.com", "/cross_site_iframe_factory.html?a(b)"));
5562 NavigateToURL(shell(), main_url); 5460 NavigateToURL(shell(), main_url);
5563 5461
5564 // Capture the FrameTreeNode this test will be navigating. 5462 // Capture the FrameTreeNode this test will be navigating.
5565 FrameTreeNode* node = static_cast<WebContentsImpl*>(shell()->web_contents()) 5463 FrameTreeNode* node = web_contents()->GetFrameTree()->root()->child_at(0);
5566 ->GetFrameTree()
5567 ->root()
5568 ->child_at(0);
5569 EXPECT_TRUE(node); 5464 EXPECT_TRUE(node);
5570 EXPECT_NE(node->current_frame_host()->GetSiteInstance(), 5465 EXPECT_NE(node->current_frame_host()->GetSiteInstance(),
5571 node->parent()->current_frame_host()->GetSiteInstance()); 5466 node->parent()->current_frame_host()->GetSiteInstance());
5572 5467
5573 // Navigate to the site of the parent, but to a page that will not commit. 5468 // 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")); 5469 GURL same_site_url(embedded_test_server()->GetURL("a.com", "/title1.html"));
5575 NavigationStallDelegate stall_delegate(same_site_url); 5470 NavigationStallDelegate stall_delegate(same_site_url);
5576 ResourceDispatcherHost::Get()->SetDelegate(&stall_delegate); 5471 ResourceDispatcherHost::Get()->SetDelegate(&stall_delegate);
5577 { 5472 {
5578 NavigationController::LoadURLParams params(same_site_url); 5473 NavigationController::LoadURLParams params(same_site_url);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
5632 5527
5633 // This test ensures that the RenderFrame isn't leaked in the renderer process 5528 // 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 5529 // 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 5530 // 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. 5531 // entry with the same routing ID, a CHECK is hit and the process crashes.
5637 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ParentDetachRemoteChild) { 5532 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ParentDetachRemoteChild) {
5638 GURL main_url(embedded_test_server()->GetURL( 5533 GURL main_url(embedded_test_server()->GetURL(
5639 "a.com", "/cross_site_iframe_factory.html?a(b,b)")); 5534 "a.com", "/cross_site_iframe_factory.html?a(b,b)"));
5640 NavigateToURL(shell(), main_url); 5535 NavigateToURL(shell(), main_url);
5641 5536
5642 WebContentsImpl* web_contents = 5537 WebContentsImpl* contents = web_contents();
5643 static_cast<WebContentsImpl*>(shell()->web_contents()); 5538 EXPECT_EQ(2U, contents->GetFrameTree()->root()->child_count());
5644 EXPECT_EQ(2U, web_contents->GetFrameTree()->root()->child_count());
5645 5539
5646 // Capture the FrameTreeNode this test will be navigating. 5540 // Capture the FrameTreeNode this test will be navigating.
5647 FrameTreeNode* node = web_contents->GetFrameTree()->root()->child_at(0); 5541 FrameTreeNode* node = contents->GetFrameTree()->root()->child_at(0);
5648 EXPECT_TRUE(node); 5542 EXPECT_TRUE(node);
5649 EXPECT_NE(node->current_frame_host()->GetSiteInstance(), 5543 EXPECT_NE(node->current_frame_host()->GetSiteInstance(),
5650 node->parent()->current_frame_host()->GetSiteInstance()); 5544 node->parent()->current_frame_host()->GetSiteInstance());
5651 5545
5652 // Grab the routing id of the first child RenderFrameHost and set up a process 5546 // 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 5547 // observer to ensure there is no crash when a new RenderFrame creation is
5654 // attempted. 5548 // attempted.
5655 RenderProcessHost* process = node->current_frame_host()->GetProcess(); 5549 RenderProcessHost* process = node->current_frame_host()->GetProcess();
5656 RenderProcessHostWatcher watcher( 5550 RenderProcessHostWatcher watcher(
5657 process, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); 5551 process, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT);
5658 int frame_routing_id = node->current_frame_host()->GetRoutingID(); 5552 int frame_routing_id = node->current_frame_host()->GetRoutingID();
5659 int widget_routing_id = 5553 int widget_routing_id =
5660 node->current_frame_host()->GetRenderWidgetHost()->GetRoutingID(); 5554 node->current_frame_host()->GetRenderWidgetHost()->GetRoutingID();
5661 int parent_routing_id = 5555 int parent_routing_id =
5662 node->parent()->render_manager()->GetRoutingIdForSiteInstance( 5556 node->parent()->render_manager()->GetRoutingIdForSiteInstance(
5663 node->current_frame_host()->GetSiteInstance()); 5557 node->current_frame_host()->GetSiteInstance());
5664 5558
5665 // Have the parent frame remove the child frame from its DOM. This should 5559 // 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. 5560 // result in the child RenderFrame being deleted in the remote process.
5667 EXPECT_TRUE(ExecuteScript(web_contents, 5561 EXPECT_TRUE(ExecuteScript(contents,
5668 "document.body.removeChild(" 5562 "document.body.removeChild("
5669 "document.querySelectorAll('iframe')[0])")); 5563 "document.querySelectorAll('iframe')[0])"));
5670 EXPECT_EQ(1U, web_contents->GetFrameTree()->root()->child_count()); 5564 EXPECT_EQ(1U, contents->GetFrameTree()->root()->child_count());
5671 5565
5672 { 5566 {
5673 FrameMsg_NewFrame_Params params; 5567 FrameMsg_NewFrame_Params params;
5674 params.routing_id = frame_routing_id; 5568 params.routing_id = frame_routing_id;
5675 params.proxy_routing_id = MSG_ROUTING_NONE; 5569 params.proxy_routing_id = MSG_ROUTING_NONE;
5676 params.opener_routing_id = MSG_ROUTING_NONE; 5570 params.opener_routing_id = MSG_ROUTING_NONE;
5677 params.parent_routing_id = parent_routing_id; 5571 params.parent_routing_id = parent_routing_id;
5678 params.previous_sibling_routing_id = MSG_ROUTING_NONE; 5572 params.previous_sibling_routing_id = MSG_ROUTING_NONE;
5679 params.widget_params.routing_id = widget_routing_id; 5573 params.widget_params.routing_id = widget_routing_id;
5680 params.widget_params.hidden = true; 5574 params.widget_params.hidden = true;
5681 params.replication_state.name = "name"; 5575 params.replication_state.name = "name";
5682 params.replication_state.unique_name = "name"; 5576 params.replication_state.unique_name = "name";
5683 5577
5684 process->Send(new FrameMsg_NewFrame(params)); 5578 process->Send(new FrameMsg_NewFrame(params));
5685 } 5579 }
5686 5580
5687 // The test must wait for the process to exit, but if there is no leak, the 5581 // 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. 5582 // RenderFrame will be properly created and there will be no crash.
5689 // Therefore, navigate the remaining subframe to completely different site, 5583 // Therefore, navigate the remaining subframe to completely different site,
5690 // which will cause the original process to exit cleanly. 5584 // which will cause the original process to exit cleanly.
5691 NavigateFrameToURL( 5585 NavigateFrameToURL(contents->GetFrameTree()->root()->child_at(0),
5692 web_contents->GetFrameTree()->root()->child_at(0), 5586 embedded_test_server()->GetURL("d.com", "/title3.html"));
5693 embedded_test_server()->GetURL("d.com", "/title3.html"));
5694 watcher.Wait(); 5587 watcher.Wait();
5695 EXPECT_TRUE(watcher.did_exit_normally()); 5588 EXPECT_TRUE(watcher.did_exit_normally());
5696 } 5589 }
5697 5590
5698 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, VisibilityChanged) { 5591 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, VisibilityChanged) {
5699 GURL main_url( 5592 GURL main_url(
5700 embedded_test_server()->GetURL("a.com", "/page_with_iframe.html")); 5593 embedded_test_server()->GetURL("a.com", "/page_with_iframe.html"));
5701 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 5594 EXPECT_TRUE(NavigateToURL(shell(), main_url));
5702 EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), main_url); 5595 EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), main_url);
5703 5596
5704 GURL cross_site_url = 5597 GURL cross_site_url =
5705 embedded_test_server()->GetURL("oopif.com", "/title1.html"); 5598 embedded_test_server()->GetURL("oopif.com", "/title1.html");
5706 5599
5707 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 5600 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
5708 ->GetFrameTree()
5709 ->root();
5710 5601
5711 TestNavigationObserver observer(shell()->web_contents()); 5602 TestNavigationObserver observer(shell()->web_contents());
5712 5603
5713 NavigateFrameToURL(root->child_at(0), cross_site_url); 5604 NavigateFrameToURL(root->child_at(0), cross_site_url);
5714 EXPECT_EQ(cross_site_url, observer.last_navigation_url()); 5605 EXPECT_EQ(cross_site_url, observer.last_navigation_url());
5715 EXPECT_TRUE(observer.last_navigation_succeeded()); 5606 EXPECT_TRUE(observer.last_navigation_succeeded());
5716 5607
5717 RenderWidgetHostImpl* render_widget_host = 5608 RenderWidgetHostImpl* render_widget_host =
5718 root->child_at(0)->current_frame_host()->GetRenderWidgetHost(); 5609 root->child_at(0)->current_frame_host()->GetRenderWidgetHost();
5719 EXPECT_FALSE(render_widget_host->is_hidden()); 5610 EXPECT_FALSE(render_widget_host->is_hidden());
(...skipping 17 matching lines...) Expand all
5737 } 5628 }
5738 5629
5739 // Verify that sandbox flags inheritance works across multiple levels of 5630 // Verify that sandbox flags inheritance works across multiple levels of
5740 // frames. See https://crbug.com/576845. 5631 // frames. See https://crbug.com/576845.
5741 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, SandboxFlagsInheritance) { 5632 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, SandboxFlagsInheritance) {
5742 GURL main_url(embedded_test_server()->GetURL( 5633 GURL main_url(embedded_test_server()->GetURL(
5743 "a.com", "/cross_site_iframe_factory.html?a(a)")); 5634 "a.com", "/cross_site_iframe_factory.html?a(a)"));
5744 NavigateToURL(shell(), main_url); 5635 NavigateToURL(shell(), main_url);
5745 5636
5746 // It is safe to obtain the root frame tree node here, as it doesn't change. 5637 // 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()) 5638 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
5748 ->GetFrameTree()
5749 ->root();
5750 5639
5751 // Set sandbox flags for child frame. 5640 // Set sandbox flags for child frame.
5752 EXPECT_TRUE(ExecuteScript( 5641 EXPECT_TRUE(ExecuteScript(
5753 root->current_frame_host(), 5642 root->current_frame_host(),
5754 "document.querySelector('iframe').sandbox = 'allow-scripts';")); 5643 "document.querySelector('iframe').sandbox = 'allow-scripts';"));
5755 5644
5756 // Calculate expected flags. Note that "allow-scripts" resets both 5645 // Calculate expected flags. Note that "allow-scripts" resets both
5757 // WebSandboxFlags::Scripts and WebSandboxFlags::AutomaticFeatures bits per 5646 // WebSandboxFlags::Scripts and WebSandboxFlags::AutomaticFeatures bits per
5758 // blink::parseSandboxPolicy(). 5647 // blink::parseSandboxPolicy().
5759 blink::WebSandboxFlags expected_flags = 5648 blink::WebSandboxFlags expected_flags =
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
5792 // a child frame, update its sandbox flags but don't navigate the frame, and 5681 // 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 5682 // ensure that a new cross-site grandchild frame doesn't inherit the new flags
5794 // (which shouldn't have taken effect). 5683 // (which shouldn't have taken effect).
5795 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 5684 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
5796 SandboxFlagsNotInheritedBeforeNavigation) { 5685 SandboxFlagsNotInheritedBeforeNavigation) {
5797 GURL main_url(embedded_test_server()->GetURL( 5686 GURL main_url(embedded_test_server()->GetURL(
5798 "a.com", "/cross_site_iframe_factory.html?a(a)")); 5687 "a.com", "/cross_site_iframe_factory.html?a(a)"));
5799 NavigateToURL(shell(), main_url); 5688 NavigateToURL(shell(), main_url);
5800 5689
5801 // It is safe to obtain the root frame tree node here, as it doesn't change. 5690 // 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()) 5691 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
5803 ->GetFrameTree()
5804 ->root();
5805 5692
5806 // Set sandbox flags for child frame. 5693 // Set sandbox flags for child frame.
5807 EXPECT_TRUE(ExecuteScript( 5694 EXPECT_TRUE(ExecuteScript(
5808 root->current_frame_host(), 5695 root->current_frame_host(),
5809 "document.querySelector('iframe').sandbox = 'allow-scripts';")); 5696 "document.querySelector('iframe').sandbox = 'allow-scripts';"));
5810 5697
5811 // These flags should be pending but not take effect, since there's been no 5698 // These flags should be pending but not take effect, since there's been no
5812 // navigation. 5699 // navigation.
5813 blink::WebSandboxFlags expected_flags = 5700 blink::WebSandboxFlags expected_flags =
5814 blink::WebSandboxFlags::All & ~blink::WebSandboxFlags::Scripts & 5701 blink::WebSandboxFlags::All & ~blink::WebSandboxFlags::Scripts &
(...skipping 29 matching lines...) Expand all
5844 // Verify that popups opened from sandboxed frames inherit sandbox flags from 5731 // Verify that popups opened from sandboxed frames inherit sandbox flags from
5845 // their opener, and that they keep these inherited flags after being navigated 5732 // their opener, and that they keep these inherited flags after being navigated
5846 // cross-site. See https://crbug.com/483584. 5733 // cross-site. See https://crbug.com/483584.
5847 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 5734 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
5848 NewPopupInheritsSandboxFlagsFromOpener) { 5735 NewPopupInheritsSandboxFlagsFromOpener) {
5849 GURL main_url(embedded_test_server()->GetURL( 5736 GURL main_url(embedded_test_server()->GetURL(
5850 "a.com", "/cross_site_iframe_factory.html?a(a)")); 5737 "a.com", "/cross_site_iframe_factory.html?a(a)"));
5851 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 5738 EXPECT_TRUE(NavigateToURL(shell(), main_url));
5852 5739
5853 // It is safe to obtain the root frame tree node here, as it doesn't change. 5740 // 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()) 5741 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
5855 ->GetFrameTree()
5856 ->root();
5857 5742
5858 // Set sandbox flags for child frame. 5743 // Set sandbox flags for child frame.
5859 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), 5744 EXPECT_TRUE(ExecuteScript(root->current_frame_host(),
5860 "document.querySelector('iframe').sandbox = " 5745 "document.querySelector('iframe').sandbox = "
5861 " 'allow-scripts allow-popups';")); 5746 " 'allow-scripts allow-popups';"));
5862 5747
5863 // Calculate expected flags. Note that "allow-scripts" resets both 5748 // Calculate expected flags. Note that "allow-scripts" resets both
5864 // WebSandboxFlags::Scripts and WebSandboxFlags::AutomaticFeatures bits per 5749 // WebSandboxFlags::Scripts and WebSandboxFlags::AutomaticFeatures bits per
5865 // blink::parseSandboxPolicy(). 5750 // blink::parseSandboxPolicy().
5866 blink::WebSandboxFlags expected_flags = 5751 blink::WebSandboxFlags expected_flags =
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
5915 // Verify that popups opened from frames sandboxed with the 5800 // Verify that popups opened from frames sandboxed with the
5916 // "allow-popups-to-escape-sandbox" directive do *not* inherit sandbox flags 5801 // "allow-popups-to-escape-sandbox" directive do *not* inherit sandbox flags
5917 // from their opener. 5802 // from their opener.
5918 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 5803 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
5919 OpenUnsandboxedPopupFromSandboxedFrame) { 5804 OpenUnsandboxedPopupFromSandboxedFrame) {
5920 GURL main_url(embedded_test_server()->GetURL( 5805 GURL main_url(embedded_test_server()->GetURL(
5921 "a.com", "/cross_site_iframe_factory.html?a(a)")); 5806 "a.com", "/cross_site_iframe_factory.html?a(a)"));
5922 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 5807 EXPECT_TRUE(NavigateToURL(shell(), main_url));
5923 5808
5924 // It is safe to obtain the root frame tree node here, as it doesn't change. 5809 // 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()) 5810 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
5926 ->GetFrameTree()
5927 ->root();
5928 5811
5929 // Set sandbox flags for child frame, specifying that popups opened from it 5812 // Set sandbox flags for child frame, specifying that popups opened from it
5930 // should not be sandboxed. 5813 // should not be sandboxed.
5931 EXPECT_TRUE(ExecuteScript( 5814 EXPECT_TRUE(ExecuteScript(
5932 root->current_frame_host(), 5815 root->current_frame_host(),
5933 "document.querySelector('iframe').sandbox = " 5816 "document.querySelector('iframe').sandbox = "
5934 " 'allow-scripts allow-popups allow-popups-to-escape-sandbox';")); 5817 " 'allow-scripts allow-popups allow-popups-to-escape-sandbox';"));
5935 5818
5936 // Set expected flags for the child frame. Note that "allow-scripts" resets 5819 // Set expected flags for the child frame. Note that "allow-scripts" resets
5937 // both WebSandboxFlags::Scripts and WebSandboxFlags::AutomaticFeatures bits 5820 // both WebSandboxFlags::Scripts and WebSandboxFlags::AutomaticFeatures bits
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
5986 SetupCrossSiteRedirector(&https_server); 5869 SetupCrossSiteRedirector(&https_server);
5987 5870
5988 GURL iframe_url( 5871 GURL iframe_url(
5989 https_server.GetURL("/mixed-content/basic-passive-in-iframe.html")); 5872 https_server.GetURL("/mixed-content/basic-passive-in-iframe.html"));
5990 EXPECT_TRUE(NavigateToURL(shell(), iframe_url)); 5873 EXPECT_TRUE(NavigateToURL(shell(), iframe_url));
5991 EXPECT_TRUE(shell()->web_contents()->DisplayedInsecureContent()); 5874 EXPECT_TRUE(shell()->web_contents()->DisplayedInsecureContent());
5992 5875
5993 // When the subframe navigates, the WebContents should still be marked 5876 // When the subframe navigates, the WebContents should still be marked
5994 // as having displayed insecure content. 5877 // as having displayed insecure content.
5995 GURL navigate_url(https_server.GetURL("/title1.html")); 5878 GURL navigate_url(https_server.GetURL("/title1.html"));
5996 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 5879 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
5997 ->GetFrameTree()
5998 ->root();
5999 NavigateFrameToURL(root->child_at(0), navigate_url); 5880 NavigateFrameToURL(root->child_at(0), navigate_url);
6000 EXPECT_TRUE(shell()->web_contents()->DisplayedInsecureContent()); 5881 EXPECT_TRUE(shell()->web_contents()->DisplayedInsecureContent());
6001 5882
6002 // When the main frame navigates, it should no longer be marked as 5883 // When the main frame navigates, it should no longer be marked as
6003 // displaying insecure content. 5884 // displaying insecure content.
6004 EXPECT_TRUE( 5885 EXPECT_TRUE(
6005 NavigateToURL(shell(), https_server.GetURL("b.com", "/title1.html"))); 5886 NavigateToURL(shell(), https_server.GetURL("b.com", "/title1.html")));
6006 EXPECT_FALSE(shell()->web_contents()->DisplayedInsecureContent()); 5887 EXPECT_FALSE(shell()->web_contents()->DisplayedInsecureContent());
6007 } 5888 }
6008 5889
6009 // Tests that, when a parent frame is set to strictly block mixed 5890 // Tests that, when a parent frame is set to strictly block mixed
6010 // content via Content Security Policy, child OOPIFs cannot display 5891 // content via Content Security Policy, child OOPIFs cannot display
6011 // mixed content. 5892 // mixed content.
6012 IN_PROC_BROWSER_TEST_F(SitePerProcessIgnoreCertErrorsBrowserTest, 5893 IN_PROC_BROWSER_TEST_F(SitePerProcessIgnoreCertErrorsBrowserTest,
6013 PassiveMixedContentInIframeWithStrictBlocking) { 5894 PassiveMixedContentInIframeWithStrictBlocking) {
6014 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); 5895 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS);
6015 https_server.ServeFilesFromSourceDirectory("content/test/data"); 5896 https_server.ServeFilesFromSourceDirectory("content/test/data");
6016 ASSERT_TRUE(https_server.Start()); 5897 ASSERT_TRUE(https_server.Start());
6017 SetupCrossSiteRedirector(&https_server); 5898 SetupCrossSiteRedirector(&https_server);
6018 5899
6019 GURL iframe_url_with_strict_blocking(https_server.GetURL( 5900 GURL iframe_url_with_strict_blocking(https_server.GetURL(
6020 "/mixed-content/basic-passive-in-iframe-with-strict-blocking.html")); 5901 "/mixed-content/basic-passive-in-iframe-with-strict-blocking.html"));
6021 EXPECT_TRUE(NavigateToURL(shell(), iframe_url_with_strict_blocking)); 5902 EXPECT_TRUE(NavigateToURL(shell(), iframe_url_with_strict_blocking));
6022 EXPECT_FALSE(shell()->web_contents()->DisplayedInsecureContent()); 5903 EXPECT_FALSE(shell()->web_contents()->DisplayedInsecureContent());
6023 5904
6024 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 5905 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
6025 ->GetFrameTree()
6026 ->root();
6027 EXPECT_TRUE(root->current_replication_state() 5906 EXPECT_TRUE(root->current_replication_state()
6028 .should_enforce_strict_mixed_content_checking); 5907 .should_enforce_strict_mixed_content_checking);
6029 EXPECT_TRUE(root->child_at(0) 5908 EXPECT_TRUE(root->child_at(0)
6030 ->current_replication_state() 5909 ->current_replication_state()
6031 .should_enforce_strict_mixed_content_checking); 5910 .should_enforce_strict_mixed_content_checking);
6032 5911
6033 // When the subframe navigates, it should still be marked as enforcing 5912 // When the subframe navigates, it should still be marked as enforcing
6034 // strict mixed content. 5913 // strict mixed content.
6035 GURL navigate_url(https_server.GetURL("/title1.html")); 5914 GURL navigate_url(https_server.GetURL("/title1.html"));
6036 NavigateFrameToURL(root->child_at(0), navigate_url); 5915 NavigateFrameToURL(root->child_at(0), navigate_url);
(...skipping 18 matching lines...) Expand all
6055 IN_PROC_BROWSER_TEST_F(SitePerProcessIgnoreCertErrorsBrowserTest, 5934 IN_PROC_BROWSER_TEST_F(SitePerProcessIgnoreCertErrorsBrowserTest,
6056 ActiveMixedContentInIframe) { 5935 ActiveMixedContentInIframe) {
6057 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); 5936 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS);
6058 https_server.ServeFilesFromSourceDirectory("content/test/data"); 5937 https_server.ServeFilesFromSourceDirectory("content/test/data");
6059 ASSERT_TRUE(https_server.Start()); 5938 ASSERT_TRUE(https_server.Start());
6060 SetupCrossSiteRedirector(&https_server); 5939 SetupCrossSiteRedirector(&https_server);
6061 5940
6062 GURL iframe_url( 5941 GURL iframe_url(
6063 https_server.GetURL("/mixed-content/basic-active-in-iframe.html")); 5942 https_server.GetURL("/mixed-content/basic-active-in-iframe.html"));
6064 EXPECT_TRUE(NavigateToURL(shell(), iframe_url)); 5943 EXPECT_TRUE(NavigateToURL(shell(), iframe_url));
6065 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 5944 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
6066 ->GetFrameTree()
6067 ->root();
6068 ASSERT_EQ(1U, root->child_count()); 5945 ASSERT_EQ(1U, root->child_count());
6069 FrameTreeNode* mixed_child = root->child_at(0)->child_at(0); 5946 FrameTreeNode* mixed_child = root->child_at(0)->child_at(0);
6070 ASSERT_TRUE(mixed_child); 5947 ASSERT_TRUE(mixed_child);
6071 // The child iframe attempted to create a mixed iframe; this should 5948 // The child iframe attempted to create a mixed iframe; this should
6072 // have been blocked, so the mixed iframe should not have committed a 5949 // have been blocked, so the mixed iframe should not have committed a
6073 // load. 5950 // load.
6074 EXPECT_FALSE(mixed_child->has_committed_real_load()); 5951 EXPECT_FALSE(mixed_child->has_committed_real_load());
6075 } 5952 }
6076 5953
6077 // Test setting a cross-origin iframe to display: none. 5954 // Test setting a cross-origin iframe to display: none.
6078 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframeDisplayNone) { 5955 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, CrossSiteIframeDisplayNone) {
6079 GURL main_url(embedded_test_server()->GetURL( 5956 GURL main_url(embedded_test_server()->GetURL(
6080 "a.com", "/cross_site_iframe_factory.html?a(b)")); 5957 "a.com", "/cross_site_iframe_factory.html?a(b)"));
6081 NavigateToURL(shell(), main_url); 5958 NavigateToURL(shell(), main_url);
6082 5959
6083 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 5960 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
6084 ->GetFrameTree()
6085 ->root();
6086 RenderWidgetHost* root_render_widget_host = 5961 RenderWidgetHost* root_render_widget_host =
6087 root->current_frame_host()->GetRenderWidgetHost(); 5962 root->current_frame_host()->GetRenderWidgetHost();
6088 5963
6089 // Set the iframe to display: none. 5964 // Set the iframe to display: none.
6090 EXPECT_TRUE( 5965 EXPECT_TRUE(
6091 ExecuteScript(shell()->web_contents(), 5966 ExecuteScript(shell()->web_contents(),
6092 "document.querySelector('iframe').style.display = 'none'")); 5967 "document.querySelector('iframe').style.display = 'none'"));
6093 5968
6094 // Waits until pending frames are done. 5969 // Waits until pending frames are done.
6095 scoped_ptr<MainThreadFrameObserver> observer( 5970 scoped_ptr<MainThreadFrameObserver> observer(
6096 new MainThreadFrameObserver(root_render_widget_host)); 5971 new MainThreadFrameObserver(root_render_widget_host));
6097 observer->Wait(); 5972 observer->Wait();
6098 5973
6099 // Force the renderer to generate a new frame. 5974 // Force the renderer to generate a new frame.
6100 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), 5975 EXPECT_TRUE(ExecuteScript(shell()->web_contents(),
6101 "document.body.style.background = 'black'")); 5976 "document.body.style.background = 'black'"));
6102 5977
6103 // Waits for the next frame. 5978 // Waits for the next frame.
6104 observer->Wait(); 5979 observer->Wait();
6105 } 5980 }
6106 5981
6107 // Test that a cross-origin iframe can be blocked by X-Frame-Options and CSP 5982 // Test that a cross-origin iframe can be blocked by X-Frame-Options and CSP
6108 // frame-ancestors. 5983 // frame-ancestors.
6109 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 5984 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
6110 CrossSiteIframeBlockedByXFrameOptionsOrCSP) { 5985 CrossSiteIframeBlockedByXFrameOptionsOrCSP) {
6111 GURL main_url(embedded_test_server()->GetURL( 5986 GURL main_url(embedded_test_server()->GetURL(
6112 "a.com", "/cross_site_iframe_factory.html?a(a)")); 5987 "a.com", "/cross_site_iframe_factory.html?a(a)"));
6113 NavigateToURL(shell(), main_url); 5988 NavigateToURL(shell(), main_url);
6114 5989
6115 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 5990 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
6116 ->GetFrameTree()
6117 ->root();
6118 5991
6119 // Add a load event handler for the iframe element. 5992 // Add a load event handler for the iframe element.
6120 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), 5993 EXPECT_TRUE(ExecuteScript(shell()->web_contents(),
6121 "document.querySelector('iframe').onload = " 5994 "document.querySelector('iframe').onload = "
6122 " function() { document.title = 'loaded'; };")); 5995 " function() { document.title = 'loaded'; };"));
6123 5996
6124 GURL blocked_urls[] = { 5997 GURL blocked_urls[] = {
6125 embedded_test_server()->GetURL("b.com", "/frame-ancestors-none.html"), 5998 embedded_test_server()->GetURL("b.com", "/frame-ancestors-none.html"),
6126 embedded_test_server()->GetURL("b.com", "/x-frame-options-deny.html") 5999 embedded_test_server()->GetURL("b.com", "/x-frame-options-deny.html")
6127 }; 6000 };
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
6175 EXPECT_EQ(blink::WebSandboxFlags::None, 6048 EXPECT_EQ(blink::WebSandboxFlags::None,
6176 root->child_at(0)->effective_sandbox_flags()); 6049 root->child_at(0)->effective_sandbox_flags());
6177 } 6050 }
6178 } 6051 }
6179 6052
6180 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ScreenCoordinates) { 6053 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ScreenCoordinates) {
6181 GURL main_url(embedded_test_server()->GetURL( 6054 GURL main_url(embedded_test_server()->GetURL(
6182 "a.com", "/cross_site_iframe_factory.html?a(b)")); 6055 "a.com", "/cross_site_iframe_factory.html?a(b)"));
6183 NavigateToURL(shell(), main_url); 6056 NavigateToURL(shell(), main_url);
6184 6057
6185 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) 6058 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
6186 ->GetFrameTree()
6187 ->root();
6188 FrameTreeNode* child = root->child_at(0); 6059 FrameTreeNode* child = root->child_at(0);
6189 6060
6190 const char* properties[] = {"screenX", "screenY", "outerWidth", 6061 const char* properties[] = {"screenX", "screenY", "outerWidth",
6191 "outerHeight"}; 6062 "outerHeight"};
6192 6063
6193 for (const char* property : properties) { 6064 for (const char* property : properties) {
6194 std::string script = "window.domAutomationController.send(window."; 6065 std::string script = "window.domAutomationController.send(window.";
6195 script += property; 6066 script += property;
6196 script += ");"; 6067 script += ");";
6197 int root_value = 1; 6068 int root_value = 1;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
6261 6132
6262 // Tests that the swapped out state on RenderViewHost is properly reset when 6133 // Tests that the swapped out state on RenderViewHost is properly reset when
6263 // the main frame is navigated to the same SiteInstance as one of its child 6134 // the main frame is navigated to the same SiteInstance as one of its child
6264 // frames. 6135 // frames.
6265 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 6136 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
6266 NavigateMainFrameToChildSite) { 6137 NavigateMainFrameToChildSite) {
6267 GURL main_url(embedded_test_server()->GetURL( 6138 GURL main_url(embedded_test_server()->GetURL(
6268 "a.com", "/cross_site_iframe_factory.html?a(b)")); 6139 "a.com", "/cross_site_iframe_factory.html?a(b)"));
6269 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 6140 EXPECT_TRUE(NavigateToURL(shell(), main_url));
6270 6141
6271 WebContentsImpl* contents = 6142 WebContentsImpl* contents = web_contents();
6272 static_cast<WebContentsImpl*>(shell()->web_contents());
6273 FrameTreeNode* root = contents->GetFrameTree()->root(); 6143 FrameTreeNode* root = contents->GetFrameTree()->root();
6274 EXPECT_EQ(1U, root->child_count()); 6144 EXPECT_EQ(1U, root->child_count());
6275 6145
6276 // Ensure the RenderViewHost for the SiteInstance of the child is considered 6146 // Ensure the RenderViewHost for the SiteInstance of the child is considered
6277 // in swapped out state. 6147 // in swapped out state.
6278 RenderViewHostImpl* rvh = contents->GetFrameTree()->GetRenderViewHost( 6148 RenderViewHostImpl* rvh = contents->GetFrameTree()->GetRenderViewHost(
6279 root->child_at(0)->current_frame_host()->GetSiteInstance()); 6149 root->child_at(0)->current_frame_host()->GetSiteInstance());
6280 EXPECT_TRUE(rvh->is_swapped_out_); 6150 EXPECT_TRUE(rvh->is_swapped_out_);
6281 6151
6282 // Have the child frame navigate its parent to its SiteInstance. 6152 // Have the child frame navigate its parent to its SiteInstance.
6283 GURL b_url(embedded_test_server()->GetURL("b.com", "/title1.html")); 6153 GURL b_url(embedded_test_server()->GetURL("b.com", "/title1.html"));
6284 std::string script = base::StringPrintf( 6154 std::string script = base::StringPrintf(
6285 "window.domAutomationController.send(" 6155 "window.domAutomationController.send("
6286 "parent.location = '%s');", 6156 "parent.location = '%s');",
6287 b_url.spec().c_str()); 6157 b_url.spec().c_str());
6288 6158
6289 TestFrameNavigationObserver frame_observer(root); 6159 TestFrameNavigationObserver frame_observer(root);
6290 EXPECT_TRUE(ExecuteScript(root->child_at(0)->current_frame_host(), script)); 6160 EXPECT_TRUE(ExecuteScript(root->child_at(0)->current_frame_host(), script));
6291 frame_observer.Wait(); 6161 frame_observer.Wait();
6292 EXPECT_EQ(b_url, root->current_url()); 6162 EXPECT_EQ(b_url, root->current_url());
6293 6163
6294 // Verify that the same RenderViewHost is preserved and that it is no longer 6164 // Verify that the same RenderViewHost is preserved and that it is no longer
6295 // in swapped out state. 6165 // in swapped out state.
6296 EXPECT_EQ(rvh, contents->GetFrameTree()->GetRenderViewHost( 6166 EXPECT_EQ(rvh, contents->GetFrameTree()->GetRenderViewHost(
6297 root->current_frame_host()->GetSiteInstance())); 6167 root->current_frame_host()->GetSiteInstance()));
6298 EXPECT_FALSE(rvh->is_swapped_out_); 6168 EXPECT_FALSE(rvh->is_swapped_out_);
6299 } 6169 }
6300 6170
6171 // This class will sniff incoming IPC for ViewHostMsg_TextInputStateChanged.
6172 class TextInputStateChangedMessageFilter : public BrowserMessageFilter {
6173 public:
6174 explicit TextInputStateChangedMessageFilter(
6175 RenderWidgetHostImpl* render_widget_host)
6176 : BrowserMessageFilter(ViewMsgStart), text_input_state_changed_(false) {
6177 if (!render_widget_host || !render_widget_host->GetProcess())
6178 text_input_state_changed_ = true;
6179 old_state = *render_widget_host->GetView()->text_input_state();
6180 render_widget_host->GetProcess()->AddFilter(this);
6181 }
6182
6183 void WaitUntilTextInputStateChanges() {
6184 if (!text_input_state_changed_) {
6185 message_loop_runner_ = new MessageLoopRunner;
6186 message_loop_runner_->Run();
6187 }
6188 }
6189
6190 private:
6191 ~TextInputStateChangedMessageFilter() override {}
6192
6193 bool OnMessageReceived(const IPC::Message& msg) override {
6194 IPC_BEGIN_MESSAGE_MAP(TextInputStateChangedMessageFilter, msg)
6195 IPC_MESSAGE_HANDLER(ViewHostMsg_TextInputStateChanged,
6196 OnTextInputStateChangedMessageReceived)
6197 IPC_END_MESSAGE_MAP()
6198 return false;
6199 }
6200
6201 void OnTextInputStateChangedMessageReceived(const TextInputState& new_state) {
6202 if (new_state.type != old_state.type || new_state.mode != old_state.mode ||
6203 new_state.value != old_state.value) {
6204 text_input_state_changed_ = true;
6205 if (message_loop_runner_)
6206 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
6207 message_loop_runner_->QuitClosure());
6208 }
6209 }
6210
6211 bool text_input_state_changed_;
6212 scoped_refptr<MessageLoopRunner> message_loop_runner_;
6213 TextInputState old_state;
6214
6215 DISALLOW_COPY_AND_ASSIGN(TextInputStateChangedMessageFilter);
6216 };
6217
6218 // Verify that when moving the focus between different frames, the WebContents
6219 // properly keeps track of the text input state.
6220 // The test loads a page with one input field, two out of process frames, and a
6221 // second input field positioned after the last <iframe>. Then a sequence of TAB
6222 // inputs are faked to navigate focus in between the different <input> elements.
6223 // After each change, we check with the RWHV of the frame as well as the
6224 // WebContents to make sure the text input state is as expected.
6225 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, TextInputStateChanged) {
6226 GURL main_page_url(embedded_test_server()->GetURL(
6227 "a.com", "/textinput/page_with_input_iframeX2_input.html"));
6228 NavigateToURL(shell(), main_page_url);
6229
6230 WebContents* contents = shell()->web_contents();
6231
6232 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
6233
6234 FrameTreeNode* child_b = root->child_at(0);
6235 GURL child_b_url(embedded_test_server()->GetURL(
6236 "b.com", "/textinput/page_with_input.html"));
6237 NavigateFrameToURL(child_b, child_b_url);
6238 EXPECT_TRUE(WaitForRenderFrameReady(child_b->current_frame_host()));
6239
6240 FrameTreeNode* child_c = root->child_at(1);
6241 GURL child_c_url(embedded_test_server()->GetURL(
6242 "c.com", "/textinput/page_with_input.html"));
6243 NavigateFrameToURL(child_c, child_c_url);
6244 EXPECT_TRUE(WaitForRenderFrameReady(child_c->current_frame_host()));
6245
6246 RenderWidgetHostImpl* root_rwh =
6247 root->current_frame_host()->GetRenderWidgetHost();
6248 RenderWidgetHostViewBase* root_rwhv = root_rwh->GetView();
6249
6250 RenderWidgetHostImpl* child_b_rwh =
6251 child_b->current_frame_host()->GetRenderWidgetHost();
6252 RenderWidgetHostViewBase* child_b_rwhv = child_b_rwh->GetView();
6253
6254 RenderWidgetHostImpl* child_c_rwh =
6255 child_c->current_frame_host()->GetRenderWidgetHost();
6256 RenderWidgetHostViewBase* child_c_rwhv = child_c_rwh->GetView();
6257
6258 // Change the text value in <input> field of either frame so that we can
6259 // later track the changes.
6260 EXPECT_TRUE(
6261 ExecuteScript(child_b->current_frame_host(),
6262 "document.querySelector('input').value = 'second';"));
6263 EXPECT_TRUE(
6264 ExecuteScript(child_c->current_frame_host(),
6265 "document.querySelector('input').value = 'third';"));
6266
6267 // Verfy the input type is none in the begning.
Charlie Reis 2016/04/01 21:24:10 nit: beginning
EhsanK 2016/04/02 03:14:02 Done. Thanks!
6268 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, root_rwhv->text_input_state()->type);
6269
6270 // A helper function to send a tab key to the frame and wait for a state
6271 // changed message.
6272 auto press_tab_and_wait_for_text_input_state_change =
6273 [contents](RenderWidgetHostImpl* rwh) {
6274 scoped_refptr<TextInputStateChangedMessageFilter> filter =
6275 new TextInputStateChangedMessageFilter(rwh);
6276 SimulateKeyPress(contents, ui::VKEY_TAB, false, false, false, false);
6277 filter->WaitUntilTextInputStateChanges();
6278 };
6279
6280 // Send focus to the first input field
Charlie Reis 2016/04/01 21:24:09 nit: End with period.
EhsanK 2016/04/02 03:14:02 Done. Thanks!
6281 press_tab_and_wait_for_text_input_state_change(root_rwh);
6282 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, root_rwhv->text_input_state()->type);
6283 EXPECT_EQ("first", root_rwhv->text_input_state()->value);
6284
6285 // Verify the top-level state is changed.
6286 EXPECT_EQ("first", web_contents()->GetTextInputState().value);
6287
6288 // Send focus to the input field in frame b.
6289 press_tab_and_wait_for_text_input_state_change(child_b_rwh);
6290 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, child_b_rwhv->text_input_state()->type);
6291 EXPECT_EQ("second", child_b_rwhv->text_input_state()->value);
6292
6293 EXPECT_EQ("second", web_contents()->GetTextInputState().value);
6294
6295 // Send focus to the input field in frame c.
6296 press_tab_and_wait_for_text_input_state_change(child_c_rwh);
6297 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, child_c_rwhv->text_input_state()->type);
6298 EXPECT_EQ("third", child_c_rwhv->text_input_state()->value);
6299
6300 EXPECT_EQ("third", web_contents()->GetTextInputState().value);
6301
6302 // Send focus to the last input field in top frame.
6303 press_tab_and_wait_for_text_input_state_change(root_rwh);
6304 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, root_rwhv->text_input_state()->type);
6305 EXPECT_EQ("fourth", root_rwhv->text_input_state()->value);
6306
6307 EXPECT_EQ("fourth", web_contents()->GetTextInputState().value);
6308 }
6309
6310 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
6311 TextInputStateChangesAfterRendererCrashes) {
6312 GURL main_url(
6313 embedded_test_server()->GetURL("a.com", "/page_with_iframe.html"));
6314 NavigateToURL(shell(), main_url);
6315 WebContentsImpl* contents = web_contents();
6316
6317 FrameTreeNode* root = contents->GetFrameTree()->root();
6318
6319 FrameTreeNode* child = root->child_at(0);
6320 GURL child_url(embedded_test_server()->GetURL(
6321 "b.com", "/textinput/page_with_input.html"));
6322 NavigateFrameToURL(child, child_url);
6323 EXPECT_TRUE(WaitForRenderFrameReady(child->current_frame_host()));
6324
6325 // Verify that the text input state is initially none.
6326 EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE, contents->GetTextInputState().type);
6327
6328 auto press_tab_and_wait_for_state_change =
6329 [contents](RenderWidgetHostImpl* rwh) {
6330 scoped_refptr<TextInputStateChangedMessageFilter> filter =
6331 new TextInputStateChangedMessageFilter(rwh);
6332 SimulateKeyPress(contents, ui::VKEY_TAB, false, false, false, false);
6333 filter->WaitUntilTextInputStateChanges();
6334 };
6335
6336 auto crash_renderer_and_wait_for_input_state_none = [contents](
6337 RenderProcessHost* host) {
6338 RenderProcessHostWatcher crash_observer(
6339 host, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT);
6340 host->Shutdown(0, false);
6341 crash_observer.Wait();
6342
6343 // We need to wait until the actual text input state update occurs.
6344 while (contents->GetTextInputState().type != ui::TEXT_INPUT_TYPE_NONE) {
6345 scoped_refptr<MessageLoopRunner> loop_runner_ = new MessageLoopRunner();
6346 BrowserThread::PostDelayedTask(BrowserThread::UI, FROM_HERE,
6347 loop_runner_->QuitClosure(),
6348 base::TimeDelta::FromMilliseconds(0LL));
6349 loop_runner_->Run();
6350 }
6351 };
6352
6353 // Press a tab key to focus the <input> and verify that the top level
6354 // WebContents sees it.
6355 RenderWidgetHostImpl* child_rwh =
6356 child->current_frame_host()->GetRenderWidgetHost();
6357 press_tab_and_wait_for_state_change(child_rwh);
6358 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, contents->GetTextInputState().type);
6359
6360 // Crash the renderer and wait until WebContentsImpl has updates the
6361 // state.
6362 RenderProcessHost* child_process = child_rwh->GetProcess();
6363 crash_renderer_and_wait_for_input_state_none(child_process);
6364
6365 // Now repeat the same test for the top level RWHV.
6366 // First remove the <iframe> and append an <input>
6367 EXPECT_TRUE(ExecuteScript(contents,
6368 "var f = document.querySelector('iframe'); "
6369 "f.parentNode.removeChild(f);"));
6370 EXPECT_TRUE(ExecuteScript(
6371 contents, "document.body.appendChild(document.createElement('input'));"));
6372
6373 // Press tab to focus the <input> and observe the state change.
6374 RenderWidgetHostImpl* root_rwh =
6375 root->current_frame_host()->GetRenderWidgetHost();
6376 press_tab_and_wait_for_state_change(root_rwh);
6377 EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT, contents->GetTextInputState().type);
6378
6379 // Crash the tab renderer and observer the input state going back to none.
6380 RenderProcessHost* host_process = root_rwh->GetProcess();
6381 crash_renderer_and_wait_for_input_state_none(host_process);
6382 }
6383
6301 } // namespace content 6384 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698