| 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..7ffd0fd56a27e7496f4606c00bb8241f74995165 100644
|
| --- a/content/browser/frame_host/navigation_controller_impl_unittest.cc
|
| +++ b/content/browser/frame_host/navigation_controller_impl_unittest.cc
|
| @@ -2880,6 +2880,59 @@ TEST_F(NavigationControllerTest, ShowRendererURLInNewTabUntilModified) {
|
| notifications.Reset();
|
| }
|
|
|
| +// Tests that the URLs for browser-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, ShowBrowserURLAfterFailUntilModified) {
|
| + NavigationControllerImpl& controller = controller_impl();
|
| + TestNotificationTracker notifications;
|
| + RegisterForAllNavNotifications(¬ifications, &controller);
|
| +
|
| + const GURL url("http://foo");
|
| +
|
| + // For browser-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. This is possible in cases that the user types a URL into a popup
|
| + // tab created with a slow URL.
|
| + NavigationController::LoadURLParams load_url_params(url);
|
| + load_url_params.transition_type = PAGE_TRANSITION_TYPED;
|
| + load_url_params.is_renderer_initiated = false;
|
| + controller.LoadURLWithParams(load_url_params);
|
| + EXPECT_EQ(url, controller.GetVisibleEntry()->GetURL());
|
| + EXPECT_EQ(url, controller.GetPendingEntry()->GetURL());
|
| + EXPECT_FALSE(
|
| + 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, params));
|
| + contents()->SetIsLoading(test_rvh(), false, true, NULL);
|
| + 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_FALSE(controller.GetPendingEntry());
|
| +
|
| + notifications.Reset();
|
| +}
|
| +
|
| TEST_F(NavigationControllerTest, DontShowRendererURLInNewTabAfterCommit) {
|
| NavigationControllerImpl& controller = controller_impl();
|
| TestNotificationTracker notifications;
|
|
|