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/files/file_path.h" | 5 #include "base/files/file_path.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "content/browser/frame_host/cross_site_transferring_request.h" | 7 #include "content/browser/frame_host/cross_site_transferring_request.h" |
8 #include "content/browser/frame_host/navigation_controller_impl.h" | 8 #include "content/browser/frame_host/navigation_controller_impl.h" |
9 #include "content/browser/frame_host/navigation_entry_impl.h" | 9 #include "content/browser/frame_host/navigation_entry_impl.h" |
10 #include "content/browser/frame_host/navigator.h" | 10 #include "content/browser/frame_host/navigator.h" |
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 EXPECT_TRUE(static_cast<SiteInstanceImpl*>(host3->GetSiteInstance())-> | 943 EXPECT_TRUE(static_cast<SiteInstanceImpl*>(host3->GetSiteInstance())-> |
944 HasSite()); | 944 HasSite()); |
945 // Check the pending RenderFrameHost has been committed. | 945 // Check the pending RenderFrameHost has been committed. |
946 EXPECT_FALSE(manager->pending_frame_host()); | 946 EXPECT_FALSE(manager->pending_frame_host()); |
947 | 947 |
948 // We should observe a notification. | 948 // We should observe a notification. |
949 EXPECT_TRUE( | 949 EXPECT_TRUE( |
950 notifications.Check1AndReset(NOTIFICATION_RENDER_VIEW_HOST_CHANGED)); | 950 notifications.Check1AndReset(NOTIFICATION_RENDER_VIEW_HOST_CHANGED)); |
951 } | 951 } |
952 | 952 |
| 953 // Test that navigation is not blocked when we make new navigation before |
| 954 // previous one has been committed. This is also a regression test for |
| 955 // http://crbug.com/104600. |
| 956 TEST_F(RenderFrameHostManagerTest, NewCrossNavigationBetweenSwapOutAndCommit) { |
| 957 const GURL kUrl1("http://www.google.com/"); |
| 958 const GURL kUrl2("http://www.chromium.org/"); |
| 959 const GURL kUrl3("http://www.youtube.com/"); |
| 960 |
| 961 contents()->NavigateAndCommit(kUrl1); |
| 962 TestRenderViewHost* rvh1 = test_rvh(); |
| 963 |
| 964 // Keep active_view_count nonzero so that no swapped out views in |
| 965 // this SiteInstance get forcefully deleted. |
| 966 static_cast<SiteInstanceImpl*>(rvh1->GetSiteInstance())-> |
| 967 increment_active_view_count(); |
| 968 |
| 969 // Navigate but don't commit. |
| 970 contents()->GetController().LoadURL( |
| 971 kUrl2, Referrer(), PAGE_TRANSITION_LINK, std::string()); |
| 972 EXPECT_TRUE(rvh1->is_waiting_for_beforeunload_ack()); |
| 973 contents()->ProceedWithCrossSiteNavigation(); |
| 974 EXPECT_FALSE(rvh1->is_waiting_for_beforeunload_ack()); |
| 975 StartCrossSiteTransition(contents()); |
| 976 EXPECT_TRUE(rvh1->IsWaitingForUnloadACK()); |
| 977 |
| 978 rvh1->OnSwappedOut(false); |
| 979 EXPECT_EQ(RenderViewHostImpl::STATE_WAITING_FOR_COMMIT, rvh1->rvh_state()); |
| 980 |
| 981 TestRenderViewHost* rvh2 = pending_test_rvh(); |
| 982 EXPECT_TRUE(rvh2); |
| 983 static_cast<SiteInstanceImpl*>(rvh2->GetSiteInstance())-> |
| 984 increment_active_view_count(); |
| 985 |
| 986 contents()->GetController().LoadURL( |
| 987 kUrl3, Referrer(), PAGE_TRANSITION_LINK, std::string()); |
| 988 // Pending rvh2 is already deleted. |
| 989 contents()->ProceedWithCrossSiteNavigation(); |
| 990 |
| 991 TestRenderViewHost* rvh3 = pending_test_rvh(); |
| 992 EXPECT_TRUE(rvh3); |
| 993 // Navigation should be already unblocked by rvh1. |
| 994 EXPECT_FALSE(rvh3->are_navigations_suspended()); |
| 995 } |
| 996 |
953 // Tests WebUI creation. | 997 // Tests WebUI creation. |
954 TEST_F(RenderFrameHostManagerTest, WebUI) { | 998 TEST_F(RenderFrameHostManagerTest, WebUI) { |
955 set_should_create_webui(true); | 999 set_should_create_webui(true); |
956 SiteInstance* instance = SiteInstance::Create(browser_context()); | 1000 SiteInstance* instance = SiteInstance::Create(browser_context()); |
957 | 1001 |
958 scoped_ptr<TestWebContents> web_contents( | 1002 scoped_ptr<TestWebContents> web_contents( |
959 TestWebContents::Create(browser_context(), instance)); | 1003 TestWebContents::Create(browser_context(), instance)); |
960 FrameTree tree(web_contents->GetFrameTree()->root()->navigator(), | 1004 FrameTree tree(web_contents->GetFrameTree()->root()->navigator(), |
961 web_contents.get(), web_contents.get(), | 1005 web_contents.get(), web_contents.get(), |
962 web_contents.get(), web_contents.get()); | 1006 web_contents.get(), web_contents.get()); |
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1714 | 1758 |
1715 // Simulate the swap out ack. | 1759 // Simulate the swap out ack. |
1716 rvh1->OnSwappedOut(false); | 1760 rvh1->OnSwappedOut(false); |
1717 | 1761 |
1718 // rvh1 should be swapped out. | 1762 // rvh1 should be swapped out. |
1719 EXPECT_FALSE(rvh_deleted_observer.deleted()); | 1763 EXPECT_FALSE(rvh_deleted_observer.deleted()); |
1720 EXPECT_TRUE(rvh1->IsSwappedOut()); | 1764 EXPECT_TRUE(rvh1->IsSwappedOut()); |
1721 } | 1765 } |
1722 | 1766 |
1723 } // namespace content | 1767 } // namespace content |
OLD | NEW |