Index: content/browser/site_per_process_browsertest.cc |
diff --git a/content/browser/site_per_process_browsertest.cc b/content/browser/site_per_process_browsertest.cc |
index c3014f396661be7483768565d9eedd69db7a2306..dc72ecc333f7dc7a4e123d9fe395d7e916e3d131 100644 |
--- a/content/browser/site_per_process_browsertest.cc |
+++ b/content/browser/site_per_process_browsertest.cc |
@@ -8908,4 +8908,79 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessNonIntegerScaleFactorBrowserTest, |
gfx::Point(event_monitor.event().x, event_monitor.event().y)); |
} |
+// This tests that we don't hide the RenderViewHost when reusing the |
+// RenderViewHost for a subframe. See https://crbug.com/638375. |
+IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ReusedRenderViewNotHidden) { |
+ GURL a_url(embedded_test_server()->GetURL("a.com", "/title1.html")); |
+ GURL b_url_a_subframe(embedded_test_server()->GetURL( |
+ "b.com", "/cross_site_iframe_factory.html?b(a)")); |
+ |
+ EXPECT_TRUE(NavigateToURL(shell(), a_url)); |
+ |
+ // Open a popup in a.com. |
+ Shell* popup = OpenPopup(shell(), a_url, "popup"); |
+ |
+ // Navigate this popup to b.com with an a.com subframe. |
+ EXPECT_TRUE(NavigateToURL(popup, b_url_a_subframe)); |
+ |
+ FrameTreeNode* root = static_cast<WebContentsImpl*>(popup->web_contents()) |
+ ->GetFrameTree() |
+ ->root(); |
+ FrameTreeNode* child_node = root->child_at(0); |
+ |
+ EXPECT_FALSE(child_node->current_frame_host() |
+ ->render_view_host() |
+ ->GetWidget() |
+ ->is_hidden()); |
+} |
+ |
+IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
+ RenderViewHostStaysActiveWithLateSwapoutACK) { |
+ EXPECT_TRUE(NavigateToURL( |
+ shell(), embedded_test_server()->GetURL("a.com", "/title1.html"))); |
+ |
+ // Open a popup and navigate it to b.com. |
+ Shell* popup = OpenPopup( |
+ shell(), embedded_test_server()->GetURL("a.com", "/title2.html"), "foo"); |
+ |
+ RenderFrameHostImpl* rfh = |
+ static_cast<RenderFrameHostImpl*>(popup->web_contents()->GetMainFrame()); |
+ RenderViewHostImpl* rvh = rfh->render_view_host(); |
+ |
+ // Disable the swapout ACK and the swapout timer. |
+ scoped_refptr<SwapoutACKMessageFilter> filter = new SwapoutACKMessageFilter(); |
+ rfh->GetProcess()->AddFilter(filter.get()); |
+ rfh->DisableSwapOutTimerForTesting(); |
+ |
+ // Navigate popup to b.com. Because there's an opener, the RVH for a.com |
+ // stays around in swapped-out state. |
+ EXPECT_TRUE(NavigateToURL( |
+ popup, embedded_test_server()->GetURL("b.com", "/title3.html"))); |
+ EXPECT_FALSE(rvh->is_active()); |
+ |
+ // Kill the b.com process. |
+ RenderProcessHost* b_process = |
+ popup->web_contents()->GetMainFrame()->GetProcess(); |
+ RenderProcessHostWatcher crash_observer( |
+ b_process, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); |
+ b_process->Shutdown(0, false); |
+ crash_observer.Wait(); |
+ |
+ // Go back in the popup from b.com to a.com/title2.html. Because the current |
+ // b.com RFH is dead, the new RFH is committed right away (without waiting |
+ // for renderer to commit), so that users don't need to look at the sad tab. |
+ TestNavigationObserver back_observer(popup->web_contents()); |
+ popup->web_contents()->GetController().GoBack(); |
+ |
+ // Pretend that the original RFH in a.com now finishes running its unload |
+ // handler and sends the swapout ACK. |
+ rfh->OnSwappedOut(); |
+ |
+ // Wait for the new a.com navigation to finish. |
+ back_observer.Wait(); |
+ |
+ // The RVH for a.com should've been reused, and it should be active. |
+ EXPECT_TRUE(rvh->is_active()); |
+} |
+ |
} // namespace content |