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

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

Issue 2226023003: Fix RenderView reuse issues after a pending RenderFrameHost dies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback from creis@ and nasko@ Created 4 years, 4 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
« no previous file with comments | « content/browser/renderer_host/render_view_host_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7630 matching lines...) Expand 10 before | Expand all | Expand 10 after
7641 EXPECT_EQ(blink::WebInputEvent::GesturePinchEnd, 7641 EXPECT_EQ(blink::WebInputEvent::GesturePinchEnd,
7642 root_frame_monitor.events_received()[5]); 7642 root_frame_monitor.events_received()[5]);
7643 EXPECT_EQ(blink::WebInputEvent::GestureScrollEnd, 7643 EXPECT_EQ(blink::WebInputEvent::GestureScrollEnd,
7644 root_frame_monitor.events_received()[6]); 7644 root_frame_monitor.events_received()[6]);
7645 7645
7646 // Verify child-RWHI gets no events. 7646 // Verify child-RWHI gets no events.
7647 EXPECT_FALSE(child_frame_monitor.EventWasReceived()); 7647 EXPECT_FALSE(child_frame_monitor.EventWasReceived());
7648 } 7648 }
7649 #endif 7649 #endif
7650 7650
7651 // Test that the pending RenderFrameHost is canceled and destroyed when its
7652 // process dies. Previously, reusing a top-level pending RFH which
7653 // is not live was hitting a CHECK in CreateRenderView due to having neither a
7654 // main frame routing ID nor a proxy routing ID. See https://crbug.com/627400
7655 // for more details.
7656 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
7657 PendingRFHIsCanceledWhenItsProcessDies) {
7658 GURL main_url(embedded_test_server()->GetURL("a.com", "/title1.html"));
7659 EXPECT_TRUE(NavigateToURL(shell(), main_url));
7660 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
7661
7662 // Open a popup at b.com.
7663 GURL popup_url(embedded_test_server()->GetURL("b.com", "/title1.html"));
7664 Shell* popup_shell = OpenPopup(root, popup_url, "foo");
7665 EXPECT_TRUE(popup_shell);
7666
7667 // The RenderViewHost for b.com in the main tab should not be active.
7668 SiteInstance* b_instance = popup_shell->web_contents()->GetSiteInstance();
7669 RenderViewHostImpl* rvh =
7670 web_contents()->GetFrameTree()->GetRenderViewHost(b_instance);
7671 EXPECT_FALSE(rvh->is_active());
7672
7673 // Navigate main tab to a b.com URL that will not commit.
7674 GURL stall_url(embedded_test_server()->GetURL("b.com", "/title2.html"));
7675 TestNavigationManager delayer(shell()->web_contents(), stall_url);
7676 shell()->LoadURL(stall_url);
7677 EXPECT_TRUE(delayer.WaitForWillStartRequest());
7678
7679 // The pending RFH should be in the same process as the popup.
7680 RenderFrameHostImpl* pending_rfh =
7681 IsBrowserSideNavigationEnabled()
7682 ? root->render_manager()->speculative_frame_host()
7683 : root->render_manager()->pending_frame_host();
7684 RenderProcessHost* pending_process = pending_rfh->GetProcess();
7685 EXPECT_EQ(pending_process,
7686 popup_shell->web_contents()->GetMainFrame()->GetProcess());
7687
7688 // Kill the b.com process, currently in use by the pending RenderFrameHost
7689 // and the popup.
7690 RenderProcessHostWatcher crash_observer(
7691 pending_process, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT);
7692 EXPECT_TRUE(pending_process->Shutdown(0, false));
7693 crash_observer.Wait();
7694
7695 // The pending RFH should have been canceled and destroyed, so that it won't
7696 // be reused while it's not live in the next navigation.
7697 {
7698 RenderFrameHostImpl* pending_rfh =
7699 IsBrowserSideNavigationEnabled()
7700 ? root->render_manager()->speculative_frame_host()
7701 : root->render_manager()->pending_frame_host();
7702 EXPECT_FALSE(pending_rfh);
7703 }
7704
7705 // Navigate main tab to b.com again. This should not crash.
7706 GURL b_url(embedded_test_server()->GetURL("b.com", "/title3.html"));
7707 EXPECT_TRUE(NavigateToURL(shell(), b_url));
7708
7709 // The b.com RVH in the main tab should become active.
7710 EXPECT_TRUE(rvh->is_active());
7711 }
7712
7713 // Test that killing a pending RenderFrameHost's process doesn't leave its
7714 // RenderViewHost confused whether it's active or not for future navigations
7715 // that try to reuse it. See https://crbug.com/627893 for more details.
7716 // Similar to the test above for https://crbug.com/627400, except the popup is
7717 // navigated after pending RFH's process is killed, rather than the main tab.
7718 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
7719 RenderViewHostKeepsSwappedOutStateIfPendingRFHDies) {
7720 GURL main_url(embedded_test_server()->GetURL("a.com", "/title1.html"));
7721 EXPECT_TRUE(NavigateToURL(shell(), main_url));
7722 FrameTreeNode* root = web_contents()->GetFrameTree()->root();
7723
7724 // Open a popup at b.com.
7725 GURL popup_url(embedded_test_server()->GetURL("b.com", "/title1.html"));
7726 Shell* popup_shell = OpenPopup(root, popup_url, "foo");
7727 EXPECT_TRUE(popup_shell);
7728
7729 // The RenderViewHost for b.com in the main tab should not be active.
7730 SiteInstance* b_instance = popup_shell->web_contents()->GetSiteInstance();
7731 RenderViewHostImpl* rvh =
7732 web_contents()->GetFrameTree()->GetRenderViewHost(b_instance);
7733 EXPECT_FALSE(rvh->is_active());
7734
7735 // Navigate main tab to a b.com URL that will not commit.
7736 GURL stall_url(embedded_test_server()->GetURL("b.com", "/title2.html"));
7737 TestNavigationManager delayer(shell()->web_contents(), stall_url);
7738 shell()->LoadURL(stall_url);
7739 EXPECT_TRUE(delayer.WaitForWillStartRequest());
7740
7741 // Kill the b.com process, currently in use by the pending RenderFrameHost
7742 // and the popup.
7743 RenderProcessHost* pending_process =
7744 popup_shell->web_contents()->GetMainFrame()->GetProcess();
7745 RenderProcessHostWatcher crash_observer(
7746 pending_process, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT);
7747 EXPECT_TRUE(pending_process->Shutdown(0, false));
7748 crash_observer.Wait();
7749
7750 // Since the navigation above didn't commit, the b.com RenderViewHost in the
7751 // main tab should still not be active.
7752 EXPECT_FALSE(rvh->is_active());
7753
7754 // Navigate popup to b.com to recreate the b.com process. When creating
7755 // opener proxies, |rvh| should be reused as a swapped out RVH. In
7756 // https://crbug.com/627893, recreating the opener RenderView was hitting a
7757 // CHECK(params.swapped_out) in the renderer process, since its
7758 // RenderViewHost was brought into an active state by the navigation to
7759 // |stall_url| above, even though it never committed.
7760 GURL b_url(embedded_test_server()->GetURL("b.com", "/title3.html"));
7761 EXPECT_TRUE(NavigateToURL(popup_shell, b_url));
7762 EXPECT_FALSE(rvh->is_active());
7763 }
7764
7651 } // namespace content 7765 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_view_host_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698