OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/site_per_process_browsertest.h" | 5 #include "content/browser/site_per_process_browsertest.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 " +--Site A ------- proxies for B\n" | 884 " +--Site A ------- proxies for B\n" |
885 "Where A = http://a.com/\n" | 885 "Where A = http://a.com/\n" |
886 " B = http://b.com/", | 886 " B = http://b.com/", |
887 DepictFrameTree(root)); | 887 DepictFrameTree(root)); |
888 | 888 |
889 // Kill the first subframe's b.com renderer. | 889 // Kill the first subframe's b.com renderer. |
890 RenderProcessHost* child_process = | 890 RenderProcessHost* child_process = |
891 root->child_at(0)->current_frame_host()->GetProcess(); | 891 root->child_at(0)->current_frame_host()->GetProcess(); |
892 RenderProcessHostWatcher crash_observer( | 892 RenderProcessHostWatcher crash_observer( |
893 child_process, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); | 893 child_process, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); |
| 894 LOG(ERROR) << "Process " << child_process->GetHandle() << " will crash"; |
894 child_process->Shutdown(0, false); | 895 child_process->Shutdown(0, false); |
895 crash_observer.Wait(); | 896 crash_observer.Wait(); |
896 | 897 |
897 // Navigate the second subframe to b.com to recreate the b.com process. | 898 // Navigate the second subframe to b.com to recreate the b.com process. |
898 GURL b_url = embedded_test_server()->GetURL("b.com", "/post_message.html"); | 899 GURL b_url = embedded_test_server()->GetURL("b.com", "/post_message.html"); |
| 900 LOG(ERROR) << "Will navigate to " << b_url; |
899 NavigateFrameToURL(root->child_at(1), b_url); | 901 NavigateFrameToURL(root->child_at(1), b_url); |
| 902 LOG(ERROR) << "Will navigate to " << b_url << " - complete"; |
900 // TODO(alexmos): This can be removed once TestFrameNavigationObserver is | 903 // TODO(alexmos): This can be removed once TestFrameNavigationObserver is |
901 // fixed to use DidFinishLoad. | 904 // fixed to use DidFinishLoad. |
902 EXPECT_TRUE( | 905 EXPECT_TRUE( |
903 WaitForRenderFrameReady(root->child_at(1)->current_frame_host())); | 906 WaitForRenderFrameReady(root->child_at(1)->current_frame_host())); |
904 EXPECT_TRUE(observer.last_navigation_succeeded()); | 907 EXPECT_TRUE(observer.last_navigation_succeeded()); |
905 EXPECT_EQ(b_url, observer.last_navigation_url()); | 908 EXPECT_EQ(b_url, observer.last_navigation_url()); |
906 EXPECT_TRUE(root->child_at(1)->current_frame_host()->IsRenderFrameLive()); | 909 EXPECT_TRUE(root->child_at(1)->current_frame_host()->IsRenderFrameLive()); |
907 | 910 |
908 EXPECT_EQ( | 911 EXPECT_EQ( |
909 " Site A ------------ proxies for B\n" | 912 " Site A ------------ proxies for B\n" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 " +--Site A ------- proxies for B\n" | 984 " +--Site A ------- proxies for B\n" |
982 " +--Site A -- proxies for B\n" | 985 " +--Site A -- proxies for B\n" |
983 "Where A = http://a.com/\n" | 986 "Where A = http://a.com/\n" |
984 " B = http://b.com/ (no process)", | 987 " B = http://b.com/ (no process)", |
985 DepictFrameTree(root)); | 988 DepictFrameTree(root)); |
986 FrameTreeNode* grandchild = root->child_at(2)->child_at(0); | 989 FrameTreeNode* grandchild = root->child_at(2)->child_at(0); |
987 RenderFrameProxyHost* grandchild_rfph = | 990 RenderFrameProxyHost* grandchild_rfph = |
988 grandchild->render_manager()->GetRenderFrameProxyHost(b_site_instance); | 991 grandchild->render_manager()->GetRenderFrameProxyHost(b_site_instance); |
989 EXPECT_FALSE(grandchild_rfph->is_render_frame_proxy_live()); | 992 EXPECT_FALSE(grandchild_rfph->is_render_frame_proxy_live()); |
990 | 993 |
| 994 LOG(ERROR) << "!!! Test will navigate subframe"; |
| 995 |
991 // Navigate the second subframe to b.com to recreate process B. | 996 // Navigate the second subframe to b.com to recreate process B. |
992 TestNavigationObserver observer(shell()->web_contents()); | 997 TestNavigationObserver observer(shell()->web_contents()); |
993 GURL b_url = embedded_test_server()->GetURL("b.com", "/title1.html"); | 998 GURL b_url = embedded_test_server()->GetURL("b.com", "/title1.html"); |
994 NavigateFrameToURL(root->child_at(1), b_url); | 999 NavigateFrameToURL(root->child_at(1), b_url); |
995 EXPECT_TRUE(observer.last_navigation_succeeded()); | 1000 EXPECT_TRUE(observer.last_navigation_succeeded()); |
996 EXPECT_EQ(b_url, observer.last_navigation_url()); | 1001 EXPECT_EQ(b_url, observer.last_navigation_url()); |
997 | 1002 |
998 // Ensure that the grandchild RenderFrameProxy in B was created when process | 1003 // Ensure that the grandchild RenderFrameProxy in B was created when process |
999 // B was restored. | 1004 // B was restored. |
| 1005 LOG(ERROR) << "Will check RFPH for liveness:" << grandchild_rfph; |
1000 EXPECT_TRUE(grandchild_rfph->is_render_frame_proxy_live()); | 1006 EXPECT_TRUE(grandchild_rfph->is_render_frame_proxy_live()); |
1001 } | 1007 } |
1002 | 1008 |
1003 // In A-embed-B-embed-C scenario, verify that killing process B clears proxies | 1009 // In A-embed-B-embed-C scenario, verify that killing process B clears proxies |
1004 // of C from the tree. | 1010 // of C from the tree. |
1005 // | 1011 // |
1006 // 1 A A | 1012 // 1 A A |
1007 // / \ / \ / \ . | 1013 // / \ / \ / \ . |
1008 // 2 3 -> B A -> Kill B -> B* A | 1014 // 2 3 -> B A -> Kill B -> B* A |
1009 // / / | 1015 // / / |
1010 // 4 C | 1016 // 4 C |
1011 // | 1017 // |
1012 // node1 is the root. | 1018 // node1 is the root. |
1013 // Initially, both node1.proxy_hosts_ and node3.proxy_hosts_ contain C. | 1019 // Initially, both node1.proxy_hosts_ and node3.proxy_hosts_ contain C. |
1014 // After we kill B, make sure proxies for C are cleared. | 1020 // After we kill B, make sure proxies for C are cleared. |
1015 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 1021 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
1016 KillingRendererClearsDescendantProxies) { | 1022 KillingRendererClearsDescendantProxies) { |
1017 GURL main_url(embedded_test_server()->GetURL( | 1023 GURL main_url(embedded_test_server()->GetURL( |
1018 "a.com", "/frame_tree/page_with_two_frames_nested.html")); | 1024 "a.com", "/frame_tree/page_with_two_frames_nested.html")); |
| 1025 LOG(ERROR) << ">>> Navigate to a.com with two frames"; |
1019 NavigateToURL(shell(), main_url); | 1026 NavigateToURL(shell(), main_url); |
| 1027 LOG(ERROR) << ">>> Navigate to a.com with two frames - complete"; |
1020 | 1028 |
1021 // It is safe to obtain the root frame tree node here, as it doesn't change. | 1029 // It is safe to obtain the root frame tree node here, as it doesn't change. |
1022 FrameTreeNode* root = | 1030 FrameTreeNode* root = |
1023 static_cast<WebContentsImpl*>(shell()->web_contents())-> | 1031 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
1024 GetFrameTree()->root(); | 1032 GetFrameTree()->root(); |
1025 ASSERT_EQ(2U, root->child_count()); | 1033 ASSERT_EQ(2U, root->child_count()); |
1026 | 1034 |
1027 GURL site_b_url( | 1035 GURL site_b_url( |
1028 embedded_test_server()->GetURL( | 1036 embedded_test_server()->GetURL( |
1029 "bar.com", "/frame_tree/page_with_one_frame.html")); | 1037 "bar.com", "/frame_tree/page_with_one_frame.html")); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 " C = http://baz.com/", | 1069 " C = http://baz.com/", |
1062 DepictFrameTree(root)); | 1070 DepictFrameTree(root)); |
1063 | 1071 |
1064 EXPECT_GT(site_instance_c->active_frame_count(), 0U); | 1072 EXPECT_GT(site_instance_c->active_frame_count(), 0U); |
1065 | 1073 |
1066 // Kill process B. | 1074 // Kill process B. |
1067 RenderProcessHost* child_process_b = | 1075 RenderProcessHost* child_process_b = |
1068 root->child_at(0)->current_frame_host()->GetProcess(); | 1076 root->child_at(0)->current_frame_host()->GetProcess(); |
1069 RenderProcessHostWatcher crash_observer( | 1077 RenderProcessHostWatcher crash_observer( |
1070 child_process_b, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); | 1078 child_process_b, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); |
| 1079 LOG(ERROR) << ">>> Killing process " << child_process_b->GetHandle(); |
1071 child_process_b->Shutdown(0, false); | 1080 child_process_b->Shutdown(0, false); |
1072 crash_observer.Wait(); | 1081 crash_observer.Wait(); |
| 1082 LOG(ERROR) << ">>> Killing process - complete"; |
1073 | 1083 |
1074 // Make sure proxy C has gone from root. | 1084 // Make sure proxy C has gone from root. |
1075 // Make sure proxy C has gone from node3 as well. | 1085 // Make sure proxy C has gone from node3 as well. |
1076 // Make sure proxy B stays around in root and node3. | 1086 // Make sure proxy B stays around in root and node3. |
1077 EXPECT_EQ( | 1087 EXPECT_EQ( |
1078 " Site A ------------ proxies for B\n" | 1088 " Site A ------------ proxies for B\n" |
1079 " |--Site B ------- proxies for A\n" | 1089 " |--Site B ------- proxies for A\n" |
1080 " +--Site A ------- proxies for B\n" | 1090 " +--Site A ------- proxies for B\n" |
1081 "Where A = http://a.com/\n" | 1091 "Where A = http://a.com/\n" |
1082 " B = http://bar.com/ (no process)", | 1092 " B = http://bar.com/ (no process)", |
(...skipping 1520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2603 " |--Site A\n" | 2613 " |--Site A\n" |
2604 " +--Site A\n" | 2614 " +--Site A\n" |
2605 " |--Site A\n" | 2615 " |--Site A\n" |
2606 " +--Site A\n" | 2616 " +--Site A\n" |
2607 " +--Site A\n" | 2617 " +--Site A\n" |
2608 "Where A = http://127.0.0.1/", | 2618 "Where A = http://127.0.0.1/", |
2609 DepictFrameTree(root)); | 2619 DepictFrameTree(root)); |
2610 } | 2620 } |
2611 | 2621 |
2612 } // namespace content | 2622 } // namespace content |
OLD | NEW |