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

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

Issue 1138413002: OOPIF: Don't resurrect a dead process just to create proxies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 <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 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 " B = http://b.com/", 882 " B = http://b.com/",
883 DepictFrameTree(root)); 883 DepictFrameTree(root));
884 884
885 // Check that third subframe's proxy is available in the b.com process by 885 // Check that third subframe's proxy is available in the b.com process by
886 // sending it a postMessage from second subframe, and waiting for a reply. 886 // sending it a postMessage from second subframe, and waiting for a reply.
887 PostMessageAndWaitForReply(root->child_at(1), 887 PostMessageAndWaitForReply(root->child_at(1),
888 "postToSibling('subframe-msg','frame3')", 888 "postToSibling('subframe-msg','frame3')",
889 "\"done-frame2\""); 889 "\"done-frame2\"");
890 } 890 }
891 891
892 // Verify that killing a cross-site frame's process B and then creating a child
893 // frame in process A doesn't resurrect process B just to create the new proxy.
nasko 2015/05/14 21:26:29 Let's abstract this sentence to avoid the A and B,
alexmos 2015/05/14 22:02:50 Done.
894 //
895 // 1 A A A
896 // / | \ / | \ / | \ / | \ .
897 // 2 3 4 -> B A A -> Kill B -> B* A A -> B* A A
898 // \ .
899 // A
900 // See https://crbug.com/476846.
901 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
902 CreateChildFrameAfterKillingProcess) {
903 // Navigate to a page with three frames: one cross-site and two same-site.
904 GURL main_url(embedded_test_server()->GetURL(
905 "a.com", "/frame_tree/page_with_three_frames.html"));
906 EXPECT_TRUE(NavigateToURL(shell(), main_url));
907
908 // It is safe to obtain the root frame tree node here, as it doesn't change.
909 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
910 ->GetFrameTree()
911 ->root();
912 TestNavigationObserver observer(shell()->web_contents());
nasko 2015/05/14 21:26:29 nit: The observer should be declared as close to t
alexmos 2015/05/14 22:02:50 Done. Thanks for noticing; it got left behind aft
913
914 EXPECT_EQ(
915 " Site A ------------ proxies for B\n"
916 " |--Site B ------- proxies for A\n"
917 " |--Site A ------- proxies for B\n"
918 " +--Site A ------- proxies for B\n"
919 "Where A = http://a.com/\n"
920 " B = http://b.com/",
921 DepictFrameTree(root));
922 SiteInstance* b_site_instance =
923 root->child_at(0)->current_frame_host()->GetSiteInstance();
924
925 // Kill the first subframe's renderer (B).
926 RenderProcessHost* child_process =
927 root->child_at(0)->current_frame_host()->GetProcess();
928 RenderProcessHostWatcher crash_observer(
929 child_process, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT);
930 child_process->Shutdown(0, false);
931 crash_observer.Wait();
932
933 // Add a new child frame to the third subframe.
934 RenderFrameHostCreatedObserver frame_observer(shell()->web_contents(), 1);
935 EXPECT_TRUE(ExecuteScript(
936 root->child_at(2)->current_frame_host(),
937 "document.body.appendChild(document.createElement('iframe'));"));
938 frame_observer.Wait();
939
940 // The new frame should have a RenderFrameProxyHost for B, but it should not
941 // be live, and B should still not have a process.
nasko 2015/05/14 21:26:29 nit: alive? I don't see a test for the "B should s
alexmos 2015/05/14 22:02:50 Done.
942 EXPECT_EQ(
943 " Site A ------------ proxies for B\n"
944 " |--Site B ------- proxies for A\n"
945 " |--Site A ------- proxies for B\n"
946 " +--Site A ------- proxies for B\n"
947 " +--Site A -- proxies for B\n"
948 "Where A = http://a.com/\n"
949 " B = http://b.com/ (no process)",
950 DepictFrameTree(root));
951 FrameTreeNode* grandchild = root->child_at(2)->child_at(0);
952 RenderFrameProxyHost* grandchild_rfph =
953 grandchild->render_manager()->GetRenderFrameProxyHost(b_site_instance);
954 EXPECT_FALSE(grandchild_rfph->is_render_frame_proxy_live());
955
956 // Navigate the second subframe to b.com to recreate process B.
957 GURL b_url = embedded_test_server()->GetURL("b.com", "/title1.html");
958 NavigateFrameToURL(root->child_at(1), b_url);
959 EXPECT_TRUE(observer.last_navigation_succeeded());
960 EXPECT_EQ(b_url, observer.last_navigation_url());
961
962 // Ensure that the grandchild RenderFrameProxy in B was created when process
963 // B was restored.
964 EXPECT_TRUE(grandchild_rfph->is_render_frame_proxy_live());
965 }
966
892 // In A-embed-B-embed-C scenario, verify that killing process B clears proxies 967 // In A-embed-B-embed-C scenario, verify that killing process B clears proxies
893 // of C from the tree. 968 // of C from the tree.
894 // 969 //
895 // 1 A A 970 // 1 A A
896 // / \ / \ / \ . 971 // / \ / \ / \ .
897 // 2 3 -> B A -> Kill B -> B* A 972 // 2 3 -> B A -> Kill B -> B* A
898 // / / 973 // / /
899 // 4 C 974 // 4 C
900 // 975 //
901 // node1 is the root. 976 // node1 is the root.
(...skipping 1487 matching lines...) Expand 10 before | Expand all | Expand 10 after
2389 " |--Site A\n" 2464 " |--Site A\n"
2390 " +--Site A\n" 2465 " +--Site A\n"
2391 " |--Site A\n" 2466 " |--Site A\n"
2392 " +--Site A\n" 2467 " +--Site A\n"
2393 " +--Site A\n" 2468 " +--Site A\n"
2394 "Where A = http://127.0.0.1/", 2469 "Where A = http://127.0.0.1/",
2395 DepictFrameTree(root)); 2470 DepictFrameTree(root));
2396 } 2471 }
2397 2472
2398 } // namespace content 2473 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698