| 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 9405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9416 mouse_event.setType(blink::WebInputEvent::MouseUp); | 9416 mouse_event.setType(blink::WebInputEvent::MouseUp); |
| 9417 mouse_event.x = 75; | 9417 mouse_event.x = 75; |
| 9418 mouse_event.y = 75; | 9418 mouse_event.y = 75; |
| 9419 router->RouteMouseEvent(rwhv, &mouse_event, ui::LatencyInfo()); | 9419 router->RouteMouseEvent(rwhv, &mouse_event, ui::LatencyInfo()); |
| 9420 | 9420 |
| 9421 EXPECT_TRUE(event_monitor.EventWasReceived()); | 9421 EXPECT_TRUE(event_monitor.EventWasReceived()); |
| 9422 EXPECT_EQ(mouse_down_coords, | 9422 EXPECT_EQ(mouse_down_coords, |
| 9423 gfx::Point(event_monitor.event().x, event_monitor.event().y)); | 9423 gfx::Point(event_monitor.event().x, event_monitor.event().y)); |
| 9424 } | 9424 } |
| 9425 | 9425 |
| 9426 // This tests that we don't hide the RenderViewHost when reusing the | |
| 9427 // RenderViewHost for a subframe. See https://crbug.com/638375. | |
| 9428 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, ReusedRenderViewNotHidden) { | |
| 9429 GURL a_url(embedded_test_server()->GetURL("a.com", "/title1.html")); | |
| 9430 GURL b_url_a_subframe(embedded_test_server()->GetURL( | |
| 9431 "b.com", "/cross_site_iframe_factory.html?b(a)")); | |
| 9432 | |
| 9433 EXPECT_TRUE(NavigateToURL(shell(), a_url)); | |
| 9434 | |
| 9435 // Open a popup in a.com. | |
| 9436 Shell* popup = OpenPopup(shell(), a_url, "popup"); | |
| 9437 | |
| 9438 // Navigate this popup to b.com with an a.com subframe. | |
| 9439 EXPECT_TRUE(NavigateToURL(popup, b_url_a_subframe)); | |
| 9440 | |
| 9441 FrameTreeNode* root = static_cast<WebContentsImpl*>(popup->web_contents()) | |
| 9442 ->GetFrameTree() | |
| 9443 ->root(); | |
| 9444 FrameTreeNode* child_node = root->child_at(0); | |
| 9445 | |
| 9446 EXPECT_FALSE(child_node->current_frame_host() | |
| 9447 ->render_view_host() | |
| 9448 ->GetWidget() | |
| 9449 ->is_hidden()); | |
| 9450 } | |
| 9451 | |
| 9452 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | |
| 9453 RenderViewHostStaysActiveWithLateSwapoutACK) { | |
| 9454 EXPECT_TRUE(NavigateToURL( | |
| 9455 shell(), embedded_test_server()->GetURL("a.com", "/title1.html"))); | |
| 9456 | |
| 9457 // Open a popup and navigate it to b.com. | |
| 9458 Shell* popup = OpenPopup( | |
| 9459 shell(), embedded_test_server()->GetURL("a.com", "/title2.html"), "foo"); | |
| 9460 | |
| 9461 RenderFrameHostImpl* rfh = | |
| 9462 static_cast<RenderFrameHostImpl*>(popup->web_contents()->GetMainFrame()); | |
| 9463 RenderViewHostImpl* rvh = rfh->render_view_host(); | |
| 9464 | |
| 9465 // Disable the swapout ACK and the swapout timer. | |
| 9466 scoped_refptr<SwapoutACKMessageFilter> filter = new SwapoutACKMessageFilter(); | |
| 9467 rfh->GetProcess()->AddFilter(filter.get()); | |
| 9468 rfh->DisableSwapOutTimerForTesting(); | |
| 9469 | |
| 9470 // Navigate popup to b.com. Because there's an opener, the RVH for a.com | |
| 9471 // stays around in swapped-out state. | |
| 9472 EXPECT_TRUE(NavigateToURL( | |
| 9473 popup, embedded_test_server()->GetURL("b.com", "/title3.html"))); | |
| 9474 EXPECT_FALSE(rvh->is_active()); | |
| 9475 | |
| 9476 // Kill the b.com process. | |
| 9477 RenderProcessHost* b_process = | |
| 9478 popup->web_contents()->GetMainFrame()->GetProcess(); | |
| 9479 RenderProcessHostWatcher crash_observer( | |
| 9480 b_process, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); | |
| 9481 b_process->Shutdown(0, false); | |
| 9482 crash_observer.Wait(); | |
| 9483 | |
| 9484 // Go back in the popup from b.com to a.com/title2.html. Because the current | |
| 9485 // b.com RFH is dead, the new RFH is committed right away (without waiting | |
| 9486 // for renderer to commit), so that users don't need to look at the sad tab. | |
| 9487 TestNavigationObserver back_observer(popup->web_contents()); | |
| 9488 popup->web_contents()->GetController().GoBack(); | |
| 9489 | |
| 9490 // Pretend that the original RFH in a.com now finishes running its unload | |
| 9491 // handler and sends the swapout ACK. | |
| 9492 rfh->OnSwappedOut(); | |
| 9493 | |
| 9494 // Wait for the new a.com navigation to finish. | |
| 9495 back_observer.Wait(); | |
| 9496 | |
| 9497 // The RVH for a.com should've been reused, and it should be active. | |
| 9498 EXPECT_TRUE(rvh->is_active()); | |
| 9499 } | |
| 9500 | |
| 9501 // Verify that a remote-to-local navigation in a crashed subframe works. See | 9426 // Verify that a remote-to-local navigation in a crashed subframe works. See |
| 9502 // https://crbug.com/487872. | 9427 // https://crbug.com/487872. |
| 9503 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 9428 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| 9504 RemoteToLocalNavigationInCrashedSubframe) { | 9429 RemoteToLocalNavigationInCrashedSubframe) { |
| 9505 GURL main_url(embedded_test_server()->GetURL( | 9430 GURL main_url(embedded_test_server()->GetURL( |
| 9506 "a.com", "/cross_site_iframe_factory.html?a(b)")); | 9431 "a.com", "/cross_site_iframe_factory.html?a(b)")); |
| 9507 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 9432 EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| 9508 | 9433 |
| 9509 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); | 9434 FrameTreeNode* root = web_contents()->GetFrameTree()->root(); |
| 9510 FrameTreeNode* child = root->child_at(0); | 9435 FrameTreeNode* child = root->child_at(0); |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9995 names.insert(root->children[0]->frame_entry->frame_unique_name()); | 9920 names.insert(root->children[0]->frame_entry->frame_unique_name()); |
| 9996 } | 9921 } |
| 9997 | 9922 |
| 9998 // More than one entry in the set means that the subframe frame navigation | 9923 // More than one entry in the set means that the subframe frame navigation |
| 9999 // entries didn't have a consistent unique name. This will break history | 9924 // entries didn't have a consistent unique name. This will break history |
| 10000 // navigations =( | 9925 // navigations =( |
| 10001 EXPECT_THAT(names, SizeIs(1)) << "Mismatched names for subframe!"; | 9926 EXPECT_THAT(names, SizeIs(1)) << "Mismatched names for subframe!"; |
| 10002 } | 9927 } |
| 10003 | 9928 |
| 10004 } // namespace content | 9929 } // namespace content |
| OLD | NEW |