Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Unified Diff: content/browser/frame_host/navigation_controller_impl_unittest.cc

Issue 232463007: Don't leave aborted URLs in the omnibox unless we're on a new tab. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 7ffd0fd56a27e7496f4606c00bb8241f74995165..16850fd786a0d842e3b9986ebf92a7aaa209bfe3 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());
// The visible entry should be the last committed URL, not the pending one,
// so that no spoof is possible.
@@ -2933,6 +2933,57 @@ TEST_F(NavigationControllerTest, ShowBrowserURLAfterFailUntilModified) {
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) {
+ NavigationControllerImpl& controller = controller_impl();
+ TestNotificationTracker notifications;
+ RegisterForAllNavNotifications(&notifications, &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, 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;
« no previous file with comments | « content/browser/frame_host/navigation_controller_impl.cc ('k') | content/browser/frame_host/navigator_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698