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 8890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8901 mouse_event.type = blink::WebInputEvent::MouseUp; | 8901 mouse_event.type = blink::WebInputEvent::MouseUp; |
8902 mouse_event.x = 75; | 8902 mouse_event.x = 75; |
8903 mouse_event.y = 75; | 8903 mouse_event.y = 75; |
8904 router->RouteMouseEvent(rwhv, &mouse_event, ui::LatencyInfo()); | 8904 router->RouteMouseEvent(rwhv, &mouse_event, ui::LatencyInfo()); |
8905 | 8905 |
8906 EXPECT_TRUE(event_monitor.EventWasReceived()); | 8906 EXPECT_TRUE(event_monitor.EventWasReceived()); |
8907 EXPECT_EQ(mouse_down_coords, | 8907 EXPECT_EQ(mouse_down_coords, |
8908 gfx::Point(event_monitor.event().x, event_monitor.event().y)); | 8908 gfx::Point(event_monitor.event().x, event_monitor.event().y)); |
8909 } | 8909 } |
8910 | 8910 |
| 8911 // This tests that we don't hide the RenderViewHost when reusing the |
| 8912 // RenderViewHost for a subframe. See https://crbug.com/638375. |
| 8913 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ReusedRenderViewNotHidden) { |
| 8914 GURL a_url(embedded_test_server()->GetURL("a.com", "/title1.html")); |
| 8915 GURL b_url_a_subframe(embedded_test_server()->GetURL( |
| 8916 "b.com", "/cross_site_iframe_factory.html?b(a)")); |
| 8917 |
| 8918 EXPECT_TRUE(NavigateToURL(shell(), a_url)); |
| 8919 |
| 8920 // Open a popup in a.com. |
| 8921 Shell* popup = OpenPopup(shell(), a_url, "popup"); |
| 8922 |
| 8923 // Navigate this popup to b.com with an a.com subframe. |
| 8924 EXPECT_TRUE(NavigateToURL(popup, b_url_a_subframe)); |
| 8925 |
| 8926 FrameTreeNode* root = static_cast<WebContentsImpl*>(popup->web_contents()) |
| 8927 ->GetFrameTree() |
| 8928 ->root(); |
| 8929 FrameTreeNode* child_node = root->child_at(0); |
| 8930 |
| 8931 EXPECT_FALSE(child_node->current_frame_host() |
| 8932 ->render_view_host() |
| 8933 ->GetWidget() |
| 8934 ->is_hidden()); |
| 8935 } |
| 8936 |
| 8937 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| 8938 RenderViewHostStaysActiveWithLateSwapoutACK) { |
| 8939 EXPECT_TRUE(NavigateToURL( |
| 8940 shell(), embedded_test_server()->GetURL("a.com", "/title1.html"))); |
| 8941 |
| 8942 // Open a popup and navigate it to b.com. |
| 8943 Shell* popup = OpenPopup( |
| 8944 shell(), embedded_test_server()->GetURL("a.com", "/title2.html"), "foo"); |
| 8945 |
| 8946 RenderFrameHostImpl* rfh = |
| 8947 static_cast<RenderFrameHostImpl*>(popup->web_contents()->GetMainFrame()); |
| 8948 RenderViewHostImpl* rvh = rfh->render_view_host(); |
| 8949 |
| 8950 // Disable the swapout ACK and the swapout timer. |
| 8951 scoped_refptr<SwapoutACKMessageFilter> filter = new SwapoutACKMessageFilter(); |
| 8952 rfh->GetProcess()->AddFilter(filter.get()); |
| 8953 rfh->DisableSwapOutTimerForTesting(); |
| 8954 |
| 8955 // Navigate popup to b.com. Because there's an opener, the RVH for a.com |
| 8956 // stays around in swapped-out state. |
| 8957 EXPECT_TRUE(NavigateToURL( |
| 8958 popup, embedded_test_server()->GetURL("b.com", "/title3.html"))); |
| 8959 EXPECT_FALSE(rvh->is_active()); |
| 8960 |
| 8961 // Kill the b.com process. |
| 8962 RenderProcessHost* b_process = |
| 8963 popup->web_contents()->GetMainFrame()->GetProcess(); |
| 8964 RenderProcessHostWatcher crash_observer( |
| 8965 b_process, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); |
| 8966 b_process->Shutdown(0, false); |
| 8967 crash_observer.Wait(); |
| 8968 |
| 8969 // Go back in the popup from b.com to a.com/title2.html. Because the current |
| 8970 // b.com RFH is dead, the new RFH is committed right away (without waiting |
| 8971 // for renderer to commit), so that users don't need to look at the sad tab. |
| 8972 TestNavigationObserver back_observer(popup->web_contents()); |
| 8973 popup->web_contents()->GetController().GoBack(); |
| 8974 |
| 8975 // Pretend that the original RFH in a.com now finishes running its unload |
| 8976 // handler and sends the swapout ACK. |
| 8977 rfh->OnSwappedOut(); |
| 8978 |
| 8979 // Wait for the new a.com navigation to finish. |
| 8980 back_observer.Wait(); |
| 8981 |
| 8982 // The RVH for a.com should've been reused, and it should be active. |
| 8983 EXPECT_TRUE(rvh->is_active()); |
| 8984 } |
| 8985 |
8911 } // namespace content | 8986 } // namespace content |
OLD | NEW |