Chromium Code Reviews| 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 <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 Loading... | |
| 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 for https://crbug.com/627400, where reusing a top-level pending | |
|
nasko
2016/08/09 18:32:32
nit: Let's say what the test is testing without th
alexmos
2016/08/09 23:09:46
Done for both tests.
| |
| 7652 // RenderFrameHost which is not live was hitting a CHECK in CreateRenderView | |
| 7653 // due to having neither a main frame routing ID nor a proxy routing ID. With | |
| 7654 // the fix, the pending RFH should be canceled and destroyed when its process | |
| 7655 // dies. | |
| 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 be swapped-out. | |
|
nasko
2016/08/09 18:32:32
nit: s/swapped-out/not active/, especially since t
alexmos
2016/08/09 23:09:46
Done (here and below)
| |
| 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 NavigationStallDelegate stall_delegate(stall_url); | |
|
nasko
2016/08/09 18:32:32
Let's start using the TestNavigationManager manage
alexmos
2016/08/09 23:09:46
Done.
| |
| 7676 ResourceDispatcherHost::Get()->SetDelegate(&stall_delegate); | |
| 7677 shell()->LoadURL(stall_url); | |
| 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 ResourceDispatcherHost::Get()->SetDelegate(nullptr); | |
| 7695 | |
| 7696 // The pending RFH should have been canceled and destroyed, so that it won't | |
| 7697 // be reused while it's not live in the next navigation. | |
| 7698 { | |
| 7699 RenderFrameHostImpl* pending_rfh = | |
| 7700 IsBrowserSideNavigationEnabled() | |
| 7701 ? root->render_manager()->speculative_frame_host() | |
| 7702 : root->render_manager()->pending_frame_host(); | |
| 7703 EXPECT_FALSE(pending_rfh); | |
| 7704 } | |
| 7705 | |
| 7706 // Navigate main tab to b.com again. This should not crash. | |
| 7707 GURL b_url(embedded_test_server()->GetURL("b.com", "/title3.html")); | |
| 7708 EXPECT_TRUE(NavigateToURL(shell(), b_url)); | |
| 7709 | |
| 7710 // The b.com RVH in the main tab should become active. | |
| 7711 EXPECT_TRUE(rvh->is_active()); | |
| 7712 } | |
| 7713 | |
| 7714 // Test for https://crbug.com/627893, where killing a pending RenderFrameHost's | |
| 7715 // process left an existing RenderViewHost confused whether it's swapped out or | |
| 7716 // not for future navigations that try to reuse it. Similar to the test | |
| 7717 // above for https://crbug.com/627400, except the popup is navigated after | |
| 7718 // pending RFH's process is killed, rather than the main tab. | |
|
nasko
2016/08/09 18:32:32
Since so much code is common between the two tests
alexmos
2016/08/09 23:09:46
Leaving this as-is per the discussion on chat.
| |
| 7719 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | |
| 7720 RenderViewHostKeepsSwappedOutStateIfPendingRFHDies) { | |
| 7721 GURL main_url(embedded_test_server()->GetURL("a.com", "/title1.html")); | |
| 7722 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | |
| 7723 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); | |
| 7724 | |
| 7725 // Open a popup at b.com. | |
| 7726 GURL popup_url(embedded_test_server()->GetURL("b.com", "/title1.html")); | |
| 7727 Shell* popup_shell = OpenPopup(root, popup_url, "foo"); | |
| 7728 EXPECT_TRUE(popup_shell); | |
| 7729 | |
| 7730 // The RenderViewHost for b.com in the main tab should be swapped-out. | |
| 7731 SiteInstance* b_instance = popup_shell->web_contents()->GetSiteInstance(); | |
| 7732 RenderViewHostImpl* rvh = | |
| 7733 web_contents()->GetFrameTree()->GetRenderViewHost(b_instance); | |
| 7734 EXPECT_FALSE(rvh->is_active()); | |
| 7735 | |
| 7736 // Navigate main tab to a b.com URL that will not commit. | |
| 7737 GURL stall_url(embedded_test_server()->GetURL("b.com", "/title2.html")); | |
| 7738 NavigationStallDelegate stall_delegate(stall_url); | |
| 7739 ResourceDispatcherHost::Get()->SetDelegate(&stall_delegate); | |
| 7740 shell()->LoadURL(stall_url); | |
| 7741 | |
| 7742 // Kill the b.com process, currently in use by the pending RenderFrameHost | |
| 7743 // and the popup. | |
| 7744 RenderProcessHost* pending_process = | |
| 7745 popup_shell->web_contents()->GetMainFrame()->GetProcess(); | |
| 7746 RenderProcessHostWatcher crash_observer( | |
| 7747 pending_process, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); | |
| 7748 EXPECT_TRUE(pending_process->Shutdown(0, false)); | |
| 7749 crash_observer.Wait(); | |
| 7750 ResourceDispatcherHost::Get()->SetDelegate(nullptr); | |
| 7751 | |
| 7752 // Since the navigation above didn't commit, the b.com RenderViewHost in the | |
| 7753 // main tab should still be swapped out. | |
| 7754 EXPECT_FALSE(rvh->is_active()); | |
| 7755 | |
| 7756 // Navigate popup to b.com to recreate the b.com process. When creating | |
| 7757 // opener proxies, |rvh| should be reused as a swapped out RVH. In | |
| 7758 // https://crbug.com/627893, recreating the opener RenderView was hitting a | |
| 7759 // CHECK(params.swapped_out) in the renderer process, since its | |
| 7760 // RenderViewHost was brought into an active state by the navigation to | |
| 7761 // |stall_url| above, even though it never committed. | |
| 7762 GURL b_url(embedded_test_server()->GetURL("b.com", "/title3.html")); | |
| 7763 EXPECT_TRUE(NavigateToURL(popup_shell, b_url)); | |
| 7764 EXPECT_FALSE(rvh->is_active()); | |
| 7765 } | |
| 7766 | |
| 7651 } // namespace content | 7767 } // namespace content |
| OLD | NEW |