| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 2383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2394 commit_observer.WaitForCommit(); | 2394 commit_observer.WaitForCommit(); |
| 2395 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), | 2395 EXPECT_NE(shell()->web_contents()->GetSiteInstance(), |
| 2396 new_shell->web_contents()->GetSiteInstance()); | 2396 new_shell->web_contents()->GetSiteInstance()); |
| 2397 EXPECT_TRUE(root->render_manager()->GetRenderFrameProxyHost(site_instance_a)); | 2397 EXPECT_TRUE(root->render_manager()->GetRenderFrameProxyHost(site_instance_a)); |
| 2398 | 2398 |
| 2399 // The previous RFH should still be pending deletion, as we wait for either | 2399 // The previous RFH should still be pending deletion, as we wait for either |
| 2400 // the SwapOut ACK or a timeout. | 2400 // the SwapOut ACK or a timeout. |
| 2401 ASSERT_TRUE(rfh_a->IsRenderFrameLive()); | 2401 ASSERT_TRUE(rfh_a->IsRenderFrameLive()); |
| 2402 ASSERT_FALSE(rfh_a->is_active()); | 2402 ASSERT_FALSE(rfh_a->is_active()); |
| 2403 | 2403 |
| 2404 // The corresponding RVH should not be pending deletion due to the proxy. | 2404 // The corresponding RVH should still be referenced by the proxy and the old |
| 2405 EXPECT_FALSE(root->render_manager()->IsViewPendingDeletion( | 2405 // frame. |
| 2406 rfh_a->render_view_host())); | 2406 RenderViewHostImpl* rvh_a = rfh_a->render_view_host(); |
| 2407 EXPECT_EQ(2, rvh_a->ref_count()); |
| 2407 | 2408 |
| 2408 // Kill the old process. | 2409 // Kill the old process. |
| 2409 RenderProcessHost* process = rfh_a->GetProcess(); | 2410 RenderProcessHost* process = rfh_a->GetProcess(); |
| 2410 RenderProcessHostWatcher crash_observer( | 2411 RenderProcessHostWatcher crash_observer( |
| 2411 process, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); | 2412 process, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); |
| 2412 process->Shutdown(0, false); | 2413 process->Shutdown(0, false); |
| 2413 crash_observer.Wait(); | 2414 crash_observer.Wait(); |
| 2414 EXPECT_FALSE(popup_root->current_frame_host()->IsRenderFrameLive()); | 2415 EXPECT_FALSE(popup_root->current_frame_host()->IsRenderFrameLive()); |
| 2415 // |rfh_a| is now deleted, thanks to the bug fix. | 2416 // |rfh_a| is now deleted, thanks to the bug fix. |
| 2416 | 2417 |
| 2418 // With |rfh_a| gone, the RVH should only be referenced by the (dead) proxy. |
| 2419 EXPECT_EQ(1, rvh_a->ref_count()); |
| 2420 EXPECT_TRUE(root->render_manager()->GetRenderFrameProxyHost(site_instance_a)); |
| 2421 EXPECT_FALSE(root->render_manager() |
| 2422 ->GetRenderFrameProxyHost(site_instance_a) |
| 2423 ->is_render_frame_proxy_live()); |
| 2424 |
| 2417 // Close the popup so there is no proxy for a.com in the original tab. | 2425 // Close the popup so there is no proxy for a.com in the original tab. |
| 2418 new_shell->Close(); | 2426 new_shell->Close(); |
| 2419 EXPECT_FALSE( | 2427 EXPECT_FALSE( |
| 2420 root->render_manager()->GetRenderFrameProxyHost(site_instance_a)); | 2428 root->render_manager()->GetRenderFrameProxyHost(site_instance_a)); |
| 2421 | 2429 |
| 2430 // This should delete the RVH as well. |
| 2431 EXPECT_FALSE(root->frame_tree()->GetRenderViewHost(site_instance_a)); |
| 2432 |
| 2422 // Go back in the main frame from b.com to a.com. In https://crbug.com/581912, | 2433 // Go back in the main frame from b.com to a.com. In https://crbug.com/581912, |
| 2423 // the browser process would crash here because there was no main frame | 2434 // the browser process would crash here because there was no main frame |
| 2424 // routing ID or proxy in RVHI::CreateRenderView. | 2435 // routing ID or proxy in RVHI::CreateRenderView. |
| 2425 { | 2436 { |
| 2426 TestNavigationObserver back_nav_load_observer(shell()->web_contents()); | 2437 TestNavigationObserver back_nav_load_observer(shell()->web_contents()); |
| 2427 shell()->web_contents()->GetController().GoBack(); | 2438 shell()->web_contents()->GetController().GoBack(); |
| 2428 back_nav_load_observer.Wait(); | 2439 back_nav_load_observer.Wait(); |
| 2429 } | 2440 } |
| 2430 } | 2441 } |
| 2431 | 2442 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2447 // Navigate the tab to a different site, and only wait for commit, not load | 2458 // Navigate the tab to a different site, and only wait for commit, not load |
| 2448 // stop. | 2459 // stop. |
| 2449 RenderFrameHostImpl* rfh_a = root->current_frame_host(); | 2460 RenderFrameHostImpl* rfh_a = root->current_frame_host(); |
| 2450 rfh_a->DisableSwapOutTimerForTesting(); | 2461 rfh_a->DisableSwapOutTimerForTesting(); |
| 2451 SiteInstanceImpl* site_instance_a = rfh_a->GetSiteInstance(); | 2462 SiteInstanceImpl* site_instance_a = rfh_a->GetSiteInstance(); |
| 2452 TestFrameNavigationObserver commit_observer(root); | 2463 TestFrameNavigationObserver commit_observer(root); |
| 2453 shell()->LoadURL(embedded_test_server()->GetURL("b.com", "/title2.html")); | 2464 shell()->LoadURL(embedded_test_server()->GetURL("b.com", "/title2.html")); |
| 2454 commit_observer.WaitForCommit(); | 2465 commit_observer.WaitForCommit(); |
| 2455 EXPECT_NE(site_instance_a, shell()->web_contents()->GetSiteInstance()); | 2466 EXPECT_NE(site_instance_a, shell()->web_contents()->GetSiteInstance()); |
| 2456 | 2467 |
| 2457 // The previous RFH and RVH should still be pending deletion, as we wait for | 2468 // The previous RFH should still be pending deletion, as we wait for either |
| 2458 // either the SwapOut ACK or a timeout. | 2469 // the SwapOut ACK or a timeout. |
| 2459 ASSERT_TRUE(rfh_a->IsRenderFrameLive()); | 2470 ASSERT_TRUE(rfh_a->IsRenderFrameLive()); |
| 2460 ASSERT_FALSE(rfh_a->is_active()); | 2471 ASSERT_FALSE(rfh_a->is_active()); |
| 2461 EXPECT_TRUE(root->render_manager()->IsViewPendingDeletion( | 2472 |
| 2462 rfh_a->render_view_host())); | 2473 // When the previous RFH was swapped out, it should have still gotten a |
| 2474 // replacement proxy even though it's the last active frame in the process. |
| 2475 EXPECT_TRUE(root->render_manager()->GetRenderFrameProxyHost(site_instance_a)); |
| 2463 | 2476 |
| 2464 // Open a popup in the new B process. | 2477 // Open a popup in the new B process. |
| 2465 Shell* new_shell = | 2478 Shell* new_shell = |
| 2466 OpenPopup(shell()->web_contents(), GURL(url::kAboutBlankURL), "foo"); | 2479 OpenPopup(shell()->web_contents(), GURL(url::kAboutBlankURL), "foo"); |
| 2467 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), | 2480 EXPECT_EQ(shell()->web_contents()->GetSiteInstance(), |
| 2468 new_shell->web_contents()->GetSiteInstance()); | 2481 new_shell->web_contents()->GetSiteInstance()); |
| 2469 | 2482 |
| 2470 // Navigate the popup to the original site, but don't wait for commit (which | 2483 // Navigate the popup to the original site, but don't wait for commit (which |
| 2471 // won't happen). This creates a proxy in the original tab, alongside the | 2484 // won't happen). This should reuse the proxy in the original tab, which at |
| 2472 // RFH and RVH pending deletion. | 2485 // this point exists alongside the RFH pending deletion. |
| 2473 new_shell->LoadURL(embedded_test_server()->GetURL("a.com", "/title2.html")); | 2486 new_shell->LoadURL(embedded_test_server()->GetURL("a.com", "/title2.html")); |
| 2474 EXPECT_TRUE(root->render_manager()->GetRenderFrameProxyHost(site_instance_a)); | 2487 EXPECT_TRUE(root->render_manager()->GetRenderFrameProxyHost(site_instance_a)); |
| 2475 | 2488 |
| 2476 // Kill the old process. | 2489 // Kill the old process. |
| 2477 RenderProcessHost* process = rfh_a->GetProcess(); | 2490 RenderProcessHost* process = rfh_a->GetProcess(); |
| 2478 RenderProcessHostWatcher crash_observer( | 2491 RenderProcessHostWatcher crash_observer( |
| 2479 process, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); | 2492 process, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); |
| 2480 process->Shutdown(0, false); | 2493 process->Shutdown(0, false); |
| 2481 crash_observer.Wait(); | 2494 crash_observer.Wait(); |
| 2482 // |rfh_a| is now deleted, thanks to the bug fix. | 2495 // |rfh_a| is now deleted, thanks to the bug fix. |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2682 // Accessing a property with normal security checks should throw a | 2695 // Accessing a property with normal security checks should throw a |
| 2683 // SecurityError if the same-origin windows are in different processes. | 2696 // SecurityError if the same-origin windows are in different processes. |
| 2684 EXPECT_THAT(result, | 2697 EXPECT_THAT(result, |
| 2685 ::testing::MatchesRegex("SecurityError: Blocked a frame with " | 2698 ::testing::MatchesRegex("SecurityError: Blocked a frame with " |
| 2686 "origin \"http://a.com:\\d+\" from " | 2699 "origin \"http://a.com:\\d+\" from " |
| 2687 "accessing a cross-origin frame.")); | 2700 "accessing a cross-origin frame.")); |
| 2688 } | 2701 } |
| 2689 } | 2702 } |
| 2690 | 2703 |
| 2691 } // namespace content | 2704 } // namespace content |
| OLD | NEW |