| 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 "base/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
| 6 #include "content/browser/frame_host/navigation_controller_impl.h" | 6 #include "content/browser/frame_host/navigation_controller_impl.h" |
| 7 #include "content/browser/frame_host/navigation_entry_impl.h" | 7 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 8 #include "content/browser/frame_host/navigator.h" | 8 #include "content/browser/frame_host/navigator.h" |
| 9 #include "content/browser/frame_host/render_frame_host_manager.h" | 9 #include "content/browser/frame_host/render_frame_host_manager.h" |
| 10 #include "content/browser/renderer_host/cross_site_transferring_request.h" | 10 #include "content/browser/renderer_host/cross_site_transferring_request.h" |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 EXPECT_NE(host2, host); | 749 EXPECT_NE(host2, host); |
| 750 | 750 |
| 751 // Check that the navigation is still suspended because the old RVH | 751 // Check that the navigation is still suspended because the old RVH |
| 752 // is not swapped out, yet. | 752 // is not swapped out, yet. |
| 753 EXPECT_TRUE(host2->render_view_host()->are_navigations_suspended()); | 753 EXPECT_TRUE(host2->render_view_host()->are_navigations_suspended()); |
| 754 MockRenderProcessHost* test_process_host2 = | 754 MockRenderProcessHost* test_process_host2 = |
| 755 static_cast<MockRenderProcessHost*>(host2->GetProcess()); | 755 static_cast<MockRenderProcessHost*>(host2->GetProcess()); |
| 756 test_process_host2->sink().ClearMessages(); | 756 test_process_host2->sink().ClearMessages(); |
| 757 host2->render_view_host()->NavigateToURL(kUrl2); | 757 host2->render_view_host()->NavigateToURL(kUrl2); |
| 758 EXPECT_FALSE(test_process_host2->sink().GetUniqueMessageMatching( | 758 EXPECT_FALSE(test_process_host2->sink().GetUniqueMessageMatching( |
| 759 ViewMsg_Navigate::ID)); | 759 FrameMsg_Navigate::ID)); |
| 760 | 760 |
| 761 // Allow closing the current Render View (precondition for swapping out | 761 // Allow closing the current Render View (precondition for swapping out |
| 762 // the RVH): Simulate response from RenderView for ViewMsg_ShouldClose sent by | 762 // the RVH): Simulate response from RenderView for ViewMsg_ShouldClose sent by |
| 763 // FirePageBeforeUnload. | 763 // FirePageBeforeUnload. |
| 764 TestRenderViewHost* test_host = | 764 TestRenderViewHost* test_host = |
| 765 static_cast<TestRenderViewHost*>(host->render_view_host()); | 765 static_cast<TestRenderViewHost*>(host->render_view_host()); |
| 766 MockRenderProcessHost* test_process_host = | 766 MockRenderProcessHost* test_process_host = |
| 767 static_cast<MockRenderProcessHost*>(test_host->GetProcess()); | 767 static_cast<MockRenderProcessHost*>(test_host->GetProcess()); |
| 768 EXPECT_TRUE(test_process_host->sink().GetUniqueMessageMatching( | 768 EXPECT_TRUE(test_process_host->sink().GetUniqueMessageMatching( |
| 769 ViewMsg_ShouldClose::ID)); | 769 ViewMsg_ShouldClose::ID)); |
| 770 test_host->SendShouldCloseACK(true); | 770 test_host->SendShouldCloseACK(true); |
| 771 | 771 |
| 772 // CrossSiteResourceHandler::StartCrossSiteTransition triggers a | 772 // CrossSiteResourceHandler::StartCrossSiteTransition triggers a |
| 773 // call of RenderFrameHostManager::SwapOutOldPage before | 773 // call of RenderFrameHostManager::SwapOutOldPage before |
| 774 // RenderFrameHostManager::DidNavigateMainFrame is called. | 774 // RenderFrameHostManager::DidNavigateMainFrame is called. |
| 775 // The RVH is swapped out after receiving the unload ack. | 775 // The RVH is swapped out after receiving the unload ack. |
| 776 manager->SwapOutOldPage(); | 776 manager->SwapOutOldPage(); |
| 777 EXPECT_TRUE(test_process_host->sink().GetUniqueMessageMatching( | 777 EXPECT_TRUE(test_process_host->sink().GetUniqueMessageMatching( |
| 778 ViewMsg_SwapOut::ID)); | 778 ViewMsg_SwapOut::ID)); |
| 779 test_host->OnSwappedOut(false); | 779 test_host->OnSwappedOut(false); |
| 780 | 780 |
| 781 EXPECT_EQ(host, manager->current_frame_host()); | 781 EXPECT_EQ(host, manager->current_frame_host()); |
| 782 EXPECT_FALSE(manager->current_frame_host()->is_swapped_out()); | 782 EXPECT_FALSE(manager->current_frame_host()->is_swapped_out()); |
| 783 EXPECT_EQ(host2, manager->pending_frame_host()); | 783 EXPECT_EQ(host2, manager->pending_frame_host()); |
| 784 // There should be still no navigation messages being sent. | 784 // There should be still no navigation messages being sent. |
| 785 EXPECT_FALSE(test_process_host2->sink().GetUniqueMessageMatching( | 785 EXPECT_FALSE(test_process_host2->sink().GetUniqueMessageMatching( |
| 786 ViewMsg_Navigate::ID)); | 786 FrameMsg_Navigate::ID)); |
| 787 | 787 |
| 788 // 3) Cross-site navigate to next site before 2) has committed. -------------- | 788 // 3) Cross-site navigate to next site before 2) has committed. -------------- |
| 789 const GURL kUrl3("http://webkit.org/"); | 789 const GURL kUrl3("http://webkit.org/"); |
| 790 NavigationEntryImpl entry3(NULL /* instance */, -1 /* page_id */, kUrl3, | 790 NavigationEntryImpl entry3(NULL /* instance */, -1 /* page_id */, kUrl3, |
| 791 Referrer(), base::string16() /* title */, | 791 Referrer(), base::string16() /* title */, |
| 792 PAGE_TRANSITION_TYPED, | 792 PAGE_TRANSITION_TYPED, |
| 793 false /* is_renderer_init */); | 793 false /* is_renderer_init */); |
| 794 test_process_host->sink().ClearMessages(); | 794 test_process_host->sink().ClearMessages(); |
| 795 RenderFrameHostImpl* host3 = manager->Navigate(entry3); | 795 RenderFrameHostImpl* host3 = manager->Navigate(entry3); |
| 796 | 796 |
| (...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1565 | 1565 |
| 1566 // Simulate the swap out ack. | 1566 // Simulate the swap out ack. |
| 1567 rvh1->OnSwappedOut(false); | 1567 rvh1->OnSwappedOut(false); |
| 1568 | 1568 |
| 1569 // rvh1 should be swapped out. | 1569 // rvh1 should be swapped out. |
| 1570 EXPECT_FALSE(destruction_observer.rvh_deleted()); | 1570 EXPECT_FALSE(destruction_observer.rvh_deleted()); |
| 1571 EXPECT_TRUE(rvh1->IsSwappedOut()); | 1571 EXPECT_TRUE(rvh1->IsSwappedOut()); |
| 1572 } | 1572 } |
| 1573 | 1573 |
| 1574 } // namespace content | 1574 } // namespace content |
| OLD | NEW |