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 "base/logging.h" | 5 #include "base/logging.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "content/browser/frame_host/interstitial_page_impl.h" | 7 #include "content/browser/frame_host/interstitial_page_impl.h" |
8 #include "content/browser/frame_host/navigation_entry_impl.h" | 8 #include "content/browser/frame_host/navigation_entry_impl.h" |
9 #include "content/browser/renderer_host/render_view_host_impl.h" | 9 #include "content/browser/renderer_host/render_view_host_impl.h" |
10 #include "content/browser/site_instance_impl.h" | 10 #include "content/browser/site_instance_impl.h" |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 // DidNavigate from the back action | 505 // DidNavigate from the back action |
506 contents()->TestDidNavigate( | 506 contents()->TestDidNavigate( |
507 goback_rvh, 1, url2, PAGE_TRANSITION_TYPED); | 507 goback_rvh, 1, url2, PAGE_TRANSITION_TYPED); |
508 EXPECT_FALSE(contents()->cross_navigation_pending()); | 508 EXPECT_FALSE(contents()->cross_navigation_pending()); |
509 EXPECT_EQ(goback_rvh, contents()->GetRenderViewHost()); | 509 EXPECT_EQ(goback_rvh, contents()->GetRenderViewHost()); |
510 EXPECT_EQ(instance1, contents()->GetSiteInstance()); | 510 EXPECT_EQ(instance1, contents()->GetSiteInstance()); |
511 // The pending RFH should now be swapped out, not deleted. | 511 // The pending RFH should now be swapped out, not deleted. |
512 EXPECT_TRUE(contents()->GetRenderManagerForTesting()-> | 512 EXPECT_TRUE(contents()->GetRenderManagerForTesting()-> |
513 IsOnSwappedOutList(pending_rfh)); | 513 IsOnSwappedOutList(pending_rfh)); |
514 EXPECT_EQ(pending_rvh_delete_count, 0); | 514 EXPECT_EQ(pending_rvh_delete_count, 0); |
| 515 pending_rvh->OnSwappedOut(false); |
515 | 516 |
516 // Close contents and ensure RVHs are deleted. | 517 // Close contents and ensure RVHs are deleted. |
517 DeleteContents(); | 518 DeleteContents(); |
518 EXPECT_EQ(orig_rvh_delete_count, 1); | 519 EXPECT_EQ(orig_rvh_delete_count, 1); |
519 EXPECT_EQ(pending_rvh_delete_count, 1); | 520 EXPECT_EQ(pending_rvh_delete_count, 1); |
520 } | 521 } |
521 | 522 |
522 // Test that navigating across a site boundary after a crash creates a new | 523 // Test that navigating across a site boundary after a crash creates a new |
523 // RVH without requiring a cross-site transition (i.e., PENDING state). | 524 // RVH without requiring a cross-site transition (i.e., PENDING state). |
524 TEST_F(WebContentsImplTest, CrossSiteBoundariesAfterCrash) { | 525 TEST_F(WebContentsImplTest, CrossSiteBoundariesAfterCrash) { |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 EXPECT_FALSE(contents()->cross_navigation_pending()); | 703 EXPECT_FALSE(contents()->cross_navigation_pending()); |
703 EXPECT_EQ(pending_rvh, contents()->GetRenderViewHost()); | 704 EXPECT_EQ(pending_rvh, contents()->GetRenderViewHost()); |
704 EXPECT_EQ(url2, contents()->GetLastCommittedURL()); | 705 EXPECT_EQ(url2, contents()->GetLastCommittedURL()); |
705 EXPECT_EQ(url2, contents()->GetVisibleURL()); | 706 EXPECT_EQ(url2, contents()->GetVisibleURL()); |
706 EXPECT_NE(new_instance, orig_instance); | 707 EXPECT_NE(new_instance, orig_instance); |
707 EXPECT_FALSE(contents()->GetPendingRenderViewHost()); | 708 EXPECT_FALSE(contents()->GetPendingRenderViewHost()); |
708 // We keep the original RFH around, swapped out. | 709 // We keep the original RFH around, swapped out. |
709 EXPECT_TRUE(contents()->GetRenderManagerForTesting()->IsOnSwappedOutList( | 710 EXPECT_TRUE(contents()->GetRenderManagerForTesting()->IsOnSwappedOutList( |
710 orig_rfh)); | 711 orig_rfh)); |
711 EXPECT_EQ(orig_rvh_delete_count, 0); | 712 EXPECT_EQ(orig_rvh_delete_count, 0); |
| 713 orig_rvh->OnSwappedOut(false); |
712 | 714 |
713 // Close contents and ensure RVHs are deleted. | 715 // Close contents and ensure RVHs are deleted. |
714 DeleteContents(); | 716 DeleteContents(); |
715 EXPECT_EQ(orig_rvh_delete_count, 1); | 717 EXPECT_EQ(orig_rvh_delete_count, 1); |
716 EXPECT_EQ(pending_rvh_delete_count, 1); | 718 EXPECT_EQ(pending_rvh_delete_count, 1); |
717 } | 719 } |
718 | 720 |
719 // Test that we can find an opener RVH even if it's pending. | 721 // Test that we can find an opener RVH even if it's pending. |
720 // http://crbug.com/176252. | 722 // http://crbug.com/176252. |
721 TEST_F(WebContentsImplTest, FindOpenerRVHWhenPending) { | 723 TEST_F(WebContentsImplTest, FindOpenerRVHWhenPending) { |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1129 | 1131 |
1130 // Navigate to new site, simulating an onbeforeunload approval. | 1132 // Navigate to new site, simulating an onbeforeunload approval. |
1131 const GURL url2("http://www.yahoo.com"); | 1133 const GURL url2("http://www.yahoo.com"); |
1132 controller().LoadURL(url2, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 1134 controller().LoadURL(url2, Referrer(), PAGE_TRANSITION_TYPED, std::string()); |
1133 EXPECT_TRUE(orig_rvh->is_waiting_for_beforeunload_ack()); | 1135 EXPECT_TRUE(orig_rvh->is_waiting_for_beforeunload_ack()); |
1134 base::TimeTicks now = base::TimeTicks::Now(); | 1136 base::TimeTicks now = base::TimeTicks::Now(); |
1135 orig_rvh->OnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true, now, now)); | 1137 orig_rvh->OnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true, now, now)); |
1136 EXPECT_TRUE(contents()->cross_navigation_pending()); | 1138 EXPECT_TRUE(contents()->cross_navigation_pending()); |
1137 | 1139 |
1138 // Simulate swap out message when the response arrives. | 1140 // Simulate swap out message when the response arrives. |
1139 orig_rvh->set_is_swapped_out(true); | 1141 orig_rvh->OnSwappedOut(false); |
1140 | 1142 |
1141 // Suppose the navigation doesn't get a chance to commit, and the user | 1143 // Suppose the navigation doesn't get a chance to commit, and the user |
1142 // navigates in the current RVH's SiteInstance. | 1144 // navigates in the current RVH's SiteInstance. |
1143 controller().LoadURL(url, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 1145 controller().LoadURL(url, Referrer(), PAGE_TRANSITION_TYPED, std::string()); |
1144 | 1146 |
1145 // Verify that the pending navigation is cancelled and the renderer is no | 1147 // Verify that the pending navigation is cancelled and the renderer is no |
1146 // longer swapped out. | 1148 // longer swapped out. |
1147 EXPECT_FALSE(orig_rvh->is_waiting_for_beforeunload_ack()); | 1149 EXPECT_FALSE(orig_rvh->is_waiting_for_beforeunload_ack()); |
1148 SiteInstance* instance2 = contents()->GetSiteInstance(); | 1150 SiteInstance* instance2 = contents()->GetSiteInstance(); |
1149 EXPECT_FALSE(contents()->cross_navigation_pending()); | 1151 EXPECT_FALSE(contents()->cross_navigation_pending()); |
1150 EXPECT_EQ(orig_rvh, rvh()); | 1152 EXPECT_EQ(orig_rvh, rvh()); |
1151 EXPECT_FALSE(orig_rvh->is_swapped_out()); | 1153 EXPECT_EQ(RenderViewHostImpl::STATE_LIVE, orig_rvh->rvh_state()); |
1152 EXPECT_EQ(instance1, instance2); | 1154 EXPECT_EQ(instance1, instance2); |
1153 EXPECT_TRUE(contents()->GetPendingRenderViewHost() == NULL); | 1155 EXPECT_TRUE(contents()->GetPendingRenderViewHost() == NULL); |
1154 } | 1156 } |
1155 | 1157 |
1156 // Test that NavigationEntries have the correct page state after going | 1158 // Test that NavigationEntries have the correct page state after going |
1157 // forward and back. Prevents regression for bug 1116137. | 1159 // forward and back. Prevents regression for bug 1116137. |
1158 TEST_F(WebContentsImplTest, NavigationEntryContentState) { | 1160 TEST_F(WebContentsImplTest, NavigationEntryContentState) { |
1159 TestRenderViewHost* orig_rvh = test_rvh(); | 1161 TestRenderViewHost* orig_rvh = test_rvh(); |
1160 | 1162 |
1161 // Navigate to URL. There should be no committed entry yet. | 1163 // Navigate to URL. There should be no committed entry yet. |
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2164 TEST_F(WebContentsImplTest, PendingContents) { | 2166 TEST_F(WebContentsImplTest, PendingContents) { |
2165 scoped_ptr<TestWebContents> other_contents( | 2167 scoped_ptr<TestWebContents> other_contents( |
2166 static_cast<TestWebContents*>(CreateTestWebContents())); | 2168 static_cast<TestWebContents*>(CreateTestWebContents())); |
2167 contents()->AddPendingContents(other_contents.get()); | 2169 contents()->AddPendingContents(other_contents.get()); |
2168 int route_id = other_contents->GetRenderViewHost()->GetRoutingID(); | 2170 int route_id = other_contents->GetRenderViewHost()->GetRoutingID(); |
2169 other_contents.reset(); | 2171 other_contents.reset(); |
2170 EXPECT_EQ(NULL, contents()->GetCreatedWindow(route_id)); | 2172 EXPECT_EQ(NULL, contents()->GetCreatedWindow(route_id)); |
2171 } | 2173 } |
2172 | 2174 |
2173 } // namespace content | 2175 } // namespace content |
OLD | NEW |