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/cross_site_transferring_request.h" | 9 #include "content/browser/renderer_host/cross_site_transferring_request.h" |
10 #include "content/browser/renderer_host/render_view_host_impl.h" | 10 #include "content/browser/renderer_host/render_view_host_impl.h" |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 // DidNavigate from the back action | 506 // DidNavigate from the back action |
507 contents()->TestDidNavigate( | 507 contents()->TestDidNavigate( |
508 goback_rvh, 1, url2, PAGE_TRANSITION_TYPED); | 508 goback_rvh, 1, url2, PAGE_TRANSITION_TYPED); |
509 EXPECT_FALSE(contents()->cross_navigation_pending()); | 509 EXPECT_FALSE(contents()->cross_navigation_pending()); |
510 EXPECT_EQ(goback_rvh, contents()->GetRenderViewHost()); | 510 EXPECT_EQ(goback_rvh, contents()->GetRenderViewHost()); |
511 EXPECT_EQ(instance1, contents()->GetSiteInstance()); | 511 EXPECT_EQ(instance1, contents()->GetSiteInstance()); |
512 // The pending RFH should now be swapped out, not deleted. | 512 // The pending RFH should now be swapped out, not deleted. |
513 EXPECT_TRUE(contents()->GetRenderManagerForTesting()-> | 513 EXPECT_TRUE(contents()->GetRenderManagerForTesting()-> |
514 IsOnSwappedOutList(pending_rfh)); | 514 IsOnSwappedOutList(pending_rfh)); |
515 EXPECT_EQ(pending_rvh_delete_count, 0); | 515 EXPECT_EQ(pending_rvh_delete_count, 0); |
| 516 pending_rvh->OnSwappedOut(false); |
516 | 517 |
517 // Close contents and ensure RVHs are deleted. | 518 // Close contents and ensure RVHs are deleted. |
518 DeleteContents(); | 519 DeleteContents(); |
519 EXPECT_EQ(orig_rvh_delete_count, 1); | 520 EXPECT_EQ(orig_rvh_delete_count, 1); |
520 EXPECT_EQ(pending_rvh_delete_count, 1); | 521 EXPECT_EQ(pending_rvh_delete_count, 1); |
521 } | 522 } |
522 | 523 |
523 // Test that navigating across a site boundary after a crash creates a new | 524 // Test that navigating across a site boundary after a crash creates a new |
524 // RVH without requiring a cross-site transition (i.e., PENDING state). | 525 // RVH without requiring a cross-site transition (i.e., PENDING state). |
525 TEST_F(WebContentsImplTest, CrossSiteBoundariesAfterCrash) { | 526 TEST_F(WebContentsImplTest, CrossSiteBoundariesAfterCrash) { |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 EXPECT_FALSE(contents()->cross_navigation_pending()); | 704 EXPECT_FALSE(contents()->cross_navigation_pending()); |
704 EXPECT_EQ(pending_rvh, contents()->GetRenderViewHost()); | 705 EXPECT_EQ(pending_rvh, contents()->GetRenderViewHost()); |
705 EXPECT_EQ(url2, contents()->GetLastCommittedURL()); | 706 EXPECT_EQ(url2, contents()->GetLastCommittedURL()); |
706 EXPECT_EQ(url2, contents()->GetVisibleURL()); | 707 EXPECT_EQ(url2, contents()->GetVisibleURL()); |
707 EXPECT_NE(new_instance, orig_instance); | 708 EXPECT_NE(new_instance, orig_instance); |
708 EXPECT_FALSE(contents()->GetPendingRenderViewHost()); | 709 EXPECT_FALSE(contents()->GetPendingRenderViewHost()); |
709 // We keep the original RFH around, swapped out. | 710 // We keep the original RFH around, swapped out. |
710 EXPECT_TRUE(contents()->GetRenderManagerForTesting()->IsOnSwappedOutList( | 711 EXPECT_TRUE(contents()->GetRenderManagerForTesting()->IsOnSwappedOutList( |
711 orig_rfh)); | 712 orig_rfh)); |
712 EXPECT_EQ(orig_rvh_delete_count, 0); | 713 EXPECT_EQ(orig_rvh_delete_count, 0); |
| 714 orig_rvh->OnSwappedOut(false); |
713 | 715 |
714 // Close contents and ensure RVHs are deleted. | 716 // Close contents and ensure RVHs are deleted. |
715 DeleteContents(); | 717 DeleteContents(); |
716 EXPECT_EQ(orig_rvh_delete_count, 1); | 718 EXPECT_EQ(orig_rvh_delete_count, 1); |
717 EXPECT_EQ(pending_rvh_delete_count, 1); | 719 EXPECT_EQ(pending_rvh_delete_count, 1); |
718 } | 720 } |
719 | 721 |
720 // Test that we can find an opener RVH even if it's pending. | 722 // Test that we can find an opener RVH even if it's pending. |
721 // http://crbug.com/176252. | 723 // http://crbug.com/176252. |
722 TEST_F(WebContentsImplTest, FindOpenerRVHWhenPending) { | 724 TEST_F(WebContentsImplTest, FindOpenerRVHWhenPending) { |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1131 | 1133 |
1132 // Navigate to new site, simulating an onbeforeunload approval. | 1134 // Navigate to new site, simulating an onbeforeunload approval. |
1133 const GURL url2("http://www.yahoo.com"); | 1135 const GURL url2("http://www.yahoo.com"); |
1134 controller().LoadURL(url2, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 1136 controller().LoadURL(url2, Referrer(), PAGE_TRANSITION_TYPED, std::string()); |
1135 EXPECT_TRUE(orig_rvh->is_waiting_for_beforeunload_ack()); | 1137 EXPECT_TRUE(orig_rvh->is_waiting_for_beforeunload_ack()); |
1136 base::TimeTicks now = base::TimeTicks::Now(); | 1138 base::TimeTicks now = base::TimeTicks::Now(); |
1137 orig_rvh->OnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true, now, now)); | 1139 orig_rvh->OnMessageReceived(ViewHostMsg_ShouldClose_ACK(0, true, now, now)); |
1138 EXPECT_TRUE(contents()->cross_navigation_pending()); | 1140 EXPECT_TRUE(contents()->cross_navigation_pending()); |
1139 | 1141 |
1140 // Simulate swap out message when the response arrives. | 1142 // Simulate swap out message when the response arrives. |
1141 orig_rvh->set_is_swapped_out(true); | 1143 orig_rvh->OnSwappedOut(false); |
1142 | 1144 |
1143 // Suppose the navigation doesn't get a chance to commit, and the user | 1145 // Suppose the navigation doesn't get a chance to commit, and the user |
1144 // navigates in the current RVH's SiteInstance. | 1146 // navigates in the current RVH's SiteInstance. |
1145 controller().LoadURL(url, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 1147 controller().LoadURL(url, Referrer(), PAGE_TRANSITION_TYPED, std::string()); |
1146 | 1148 |
1147 // Verify that the pending navigation is cancelled and the renderer is no | 1149 // Verify that the pending navigation is cancelled and the renderer is no |
1148 // longer swapped out. | 1150 // longer swapped out. |
1149 EXPECT_FALSE(orig_rvh->is_waiting_for_beforeunload_ack()); | 1151 EXPECT_FALSE(orig_rvh->is_waiting_for_beforeunload_ack()); |
1150 SiteInstance* instance2 = contents()->GetSiteInstance(); | 1152 SiteInstance* instance2 = contents()->GetSiteInstance(); |
1151 EXPECT_FALSE(contents()->cross_navigation_pending()); | 1153 EXPECT_FALSE(contents()->cross_navigation_pending()); |
1152 EXPECT_EQ(orig_rvh, rvh()); | 1154 EXPECT_EQ(orig_rvh, rvh()); |
1153 EXPECT_FALSE(orig_rvh->is_swapped_out()); | 1155 EXPECT_EQ(RenderViewHostImpl::STATE_DEFAULT, orig_rvh->rvh_state()); |
1154 EXPECT_EQ(instance1, instance2); | 1156 EXPECT_EQ(instance1, instance2); |
1155 EXPECT_TRUE(contents()->GetPendingRenderViewHost() == NULL); | 1157 EXPECT_TRUE(contents()->GetPendingRenderViewHost() == NULL); |
1156 } | 1158 } |
1157 | 1159 |
1158 // Test that NavigationEntries have the correct page state after going | 1160 // Test that NavigationEntries have the correct page state after going |
1159 // forward and back. Prevents regression for bug 1116137. | 1161 // forward and back. Prevents regression for bug 1116137. |
1160 TEST_F(WebContentsImplTest, NavigationEntryContentState) { | 1162 TEST_F(WebContentsImplTest, NavigationEntryContentState) { |
1161 TestRenderViewHost* orig_rvh = test_rvh(); | 1163 TestRenderViewHost* orig_rvh = test_rvh(); |
1162 | 1164 |
1163 // Navigate to URL. There should be no committed entry yet. | 1165 // Navigate to URL. There should be no committed entry yet. |
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2224 // Reset the last active time to a known-bad value. | 2226 // Reset the last active time to a known-bad value. |
2225 contents()->last_active_time_ = base::TimeTicks(); | 2227 contents()->last_active_time_ = base::TimeTicks(); |
2226 ASSERT_TRUE(contents()->GetLastActiveTime().is_null()); | 2228 ASSERT_TRUE(contents()->GetLastActiveTime().is_null()); |
2227 | 2229 |
2228 // Simulate activating the WebContents. The active time should update. | 2230 // Simulate activating the WebContents. The active time should update. |
2229 contents()->WasShown(); | 2231 contents()->WasShown(); |
2230 EXPECT_FALSE(contents()->GetLastActiveTime().is_null()); | 2232 EXPECT_FALSE(contents()->GetLastActiveTime().is_null()); |
2231 } | 2233 } |
2232 | 2234 |
2233 } // namespace content | 2235 } // namespace content |
OLD | NEW |