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

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

Issue 917043004: Mark error pages as such on Ctrl-Shift-T reload. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 5 years, 10 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
« no previous file with comments | « content/browser/frame_host/navigation_controller_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c02ff995e2631104c5b0f5483f09e595c628867f..2ffa0eabc9a22e0c416510b8ad528038ae151b32 100644
--- a/content/browser/frame_host/navigation_controller_impl_unittest.cc
+++ b/content/browser/frame_host/navigation_controller_impl_unittest.cc
@@ -30,6 +30,7 @@
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/page_state.h"
+#include "content/public/common/page_type.h"
#include "content/public/common/url_constants.h"
#include "content/public/test/mock_render_process_host.h"
#include "content/public/test/test_notification_tracker.h"
@@ -4534,4 +4535,61 @@ TEST_F(NavigationControllerTest, PostThenReplaceStateThenReload) {
EXPECT_EQ(0, delegate->repost_form_warning_count());
}
+TEST_F(NavigationControllerTest, UnreachableURLGivesErrorPage) {
+ GURL url("http://foo");
+ FrameHostMsg_DidCommitProvisionalLoad_Params params;
+ params.page_id = 1;
+ params.url = url;
+ params.transition = ui::PAGE_TRANSITION_LINK;
+ params.gesture = NavigationGestureUser;
+ params.page_state = PageState::CreateFromURL(url);
+ params.was_within_same_page = false;
+ params.is_post = true;
+ params.post_id = 2;
+ params.url_is_unreachable = true;
+ // Navigate to new page
+ {
+ LoadCommittedDetails details;
+ controller_impl().RendererDidNavigate(main_test_rfh(), params, &details);
+ EXPECT_EQ(PAGE_TYPE_ERROR,
+ controller_impl().GetLastCommittedEntry()->GetPageType());
+ EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, details.type);
+ }
+
+ // Navigate to existing page.
+ {
+ LoadCommittedDetails details;
+ controller_impl().RendererDidNavigate(main_test_rfh(), params, &details);
+ EXPECT_EQ(PAGE_TYPE_ERROR,
+ controller_impl().GetLastCommittedEntry()->GetPageType());
+ EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, details.type);
+ }
+
+ // Navigate to same page.
+ // Note: The call to LoadURL() creates a pending entry in order to trigger the
+ // same-page transition.
+ controller_impl().LoadURL(
+ url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
+ params.transition = ui::PAGE_TRANSITION_TYPED;
+ {
+ LoadCommittedDetails details;
+ controller_impl().RendererDidNavigate(main_test_rfh(), params, &details);
+ EXPECT_EQ(PAGE_TYPE_ERROR,
+ controller_impl().GetLastCommittedEntry()->GetPageType());
+ EXPECT_EQ(NAVIGATION_TYPE_SAME_PAGE, details.type);
+ }
+
+ // Navigate in page.
+ params.url = GURL("http://foo#foo");
+ params.transition = ui::PAGE_TRANSITION_LINK;
+ params.was_within_same_page = true;
+ {
+ LoadCommittedDetails details;
+ controller_impl().RendererDidNavigate(main_test_rfh(), params, &details);
+ EXPECT_EQ(PAGE_TYPE_ERROR,
+ controller_impl().GetLastCommittedEntry()->GetPageType());
+ EXPECT_EQ(NAVIGATION_TYPE_IN_PAGE, details.type);
+ }
+}
+
} // namespace content
« no previous file with comments | « content/browser/frame_host/navigation_controller_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698