Chromium Code Reviews| Index: content/browser/frame_host/navigation_controller_impl_unittest.cc |
| diff --git a/content/browser/frame_host/navigation_controller_impl_unittest.cc b/content/browser/frame_host/navigation_controller_impl_unittest.cc |
| index fdedfc25cb87629959701d35e65806952b142a91..21ccb8822ec8c055437a943af02fa5d4b76cb603 100644 |
| --- a/content/browser/frame_host/navigation_controller_impl_unittest.cc |
| +++ b/content/browser/frame_host/navigation_controller_impl_unittest.cc |
| @@ -1046,7 +1046,7 @@ TEST_F(NavigationControllerTest, LoadURL_RedirectAbortDoesntShowPendingURL) { |
| EXPECT_EQ(-1, controller.GetPendingEntryIndex()); |
| EXPECT_FALSE(controller.GetPendingEntry()); |
| EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
| - EXPECT_EQ(0, delegate->navigation_state_change_count()); |
| + EXPECT_EQ(1, delegate->navigation_state_change_count()); |
|
Charlie Reis
2014/04/18 01:23:53
We're now triggering a state change in DidFail so
|
| // The visible entry should be the last committed URL, not the pending one, |
| // so that no spoof is possible. |
| @@ -2880,6 +2880,58 @@ TEST_F(NavigationControllerTest, ShowRendererURLInNewTabUntilModified) { |
| notifications.Reset(); |
| } |
| +// Tests that the URLs for renderer-initiated navigations in new tabs are |
| +// displayed to the user even after they fail, as long as the initial |
| +// about:blank page has not been modified. If so, we must revert to showing |
| +// about:blank. See http://crbug.com/355537. |
| +TEST_F(NavigationControllerTest, ShowRendererURLAfterFailUntilModified) { |
|
Charlie Reis
2014/04/18 01:23:53
This is similar to the test above but checks the D
|
| + NavigationControllerImpl& controller = controller_impl(); |
| + TestNotificationTracker notifications; |
| + RegisterForAllNavNotifications(¬ifications, &controller); |
| + |
| + const GURL url("http://foo"); |
| + |
| + // For renderer-initiated navigations in new tabs (with no committed entries), |
| + // we show the pending entry's URL as long as the about:blank page is not |
| + // modified. |
| + NavigationController::LoadURLParams load_url_params(url); |
| + load_url_params.transition_type = PAGE_TRANSITION_LINK; |
| + load_url_params.is_renderer_initiated = true; |
| + controller.LoadURLWithParams(load_url_params); |
| + EXPECT_EQ(url, controller.GetVisibleEntry()->GetURL()); |
| + EXPECT_EQ(url, controller.GetPendingEntry()->GetURL()); |
| + EXPECT_TRUE( |
| + NavigationEntryImpl::FromNavigationEntry(controller.GetPendingEntry())-> |
| + is_renderer_initiated()); |
| + EXPECT_TRUE(controller.IsInitialNavigation()); |
| + EXPECT_FALSE(test_rvh()->has_accessed_initial_document()); |
| + |
| + // There should be no title yet. |
| + EXPECT_TRUE(contents()->GetTitle().empty()); |
| + |
| + // Suppose it aborts before committing, if it's a 204 or download or due to a |
| + // stop or a new navigation from the user. The URL should remain visible. |
| + FrameHostMsg_DidFailProvisionalLoadWithError_Params params; |
| + params.error_code = net::ERR_ABORTED; |
| + params.error_description = base::string16(); |
| + params.url = url; |
| + params.showing_repost_interstitial = false; |
| + main_test_rfh()->OnMessageReceived( |
| + FrameHostMsg_DidFailProvisionalLoadWithError(0, // routing_id |
| + params)); |
| + EXPECT_EQ(url, controller.GetVisibleEntry()->GetURL()); |
| + |
| + // If something else later modifies the contents of the about:blank page, then |
| + // we must revert to showing about:blank to avoid a URL spoof. |
| + test_rvh()->OnMessageReceived( |
| + ViewHostMsg_DidAccessInitialDocument(0)); |
| + EXPECT_TRUE(test_rvh()->has_accessed_initial_document()); |
| + EXPECT_FALSE(controller.GetVisibleEntry()); |
| + EXPECT_EQ(url, controller.GetPendingEntry()->GetURL()); |
| + |
| + notifications.Reset(); |
| +} |
| + |
| TEST_F(NavigationControllerTest, DontShowRendererURLInNewTabAfterCommit) { |
| NavigationControllerImpl& controller = controller_impl(); |
| TestNotificationTracker notifications; |