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

Unified Diff: chrome/browser/errorpage_browsertest.cc

Issue 2190463008: Add an error page for HTTP 404 error pages without bodies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Switch runtime test to title1.html Created 4 years, 4 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: chrome/browser/errorpage_browsertest.cc
diff --git a/chrome/browser/errorpage_browsertest.cc b/chrome/browser/errorpage_browsertest.cc
index 33ac9fe9b64ff81487369a331741fc9bd2f167d6..c22fcd71cac6f146ed8552293cc8950053c86ecb 100644
--- a/chrome/browser/errorpage_browsertest.cc
+++ b/chrome/browser/errorpage_browsertest.cc
@@ -104,13 +104,6 @@ void ToggleHelpBox(Browser* browser) {
"document.getElementById('details-button').click();"));
}
-// Returns true if |browser| is displaying the text representation of
-// |error_code| on the current page.
-bool WARN_UNUSED_RESULT IsDisplayingNetError(Browser* browser,
- net::Error error_code) {
- return IsDisplayingText(browser, net::ErrorToShortString(error_code));
-}
-
// Returns true if the diagnostics link suggestion is displayed.
bool WARN_UNUSED_RESULT IsDisplayingDiagnosticsLink(Browser* browser) {
std::string command = base::StringPrintf(
@@ -123,9 +116,10 @@ bool WARN_UNUSED_RESULT IsDisplayingDiagnosticsLink(Browser* browser) {
}
// Checks that the local error page is being displayed, without remotely
-// retrieved navigation corrections, and with the specified error code.
-void ExpectDisplayingLocalErrorPage(Browser* browser, net::Error error_code) {
- EXPECT_TRUE(IsDisplayingNetError(browser, error_code));
+// retrieved navigation corrections, and with the specified error string.
+void ExpectDisplayingLocalErrorPage(Browser* browser,
+ const std::string& error_string) {
+ EXPECT_TRUE(IsDisplayingText(browser, error_string));
// Locally generated error pages should not have navigation corrections.
EXPECT_FALSE(IsDisplayingText(browser, "http://mock.http/title2.html"));
@@ -134,12 +128,18 @@ void ExpectDisplayingLocalErrorPage(Browser* browser, net::Error error_code) {
EXPECT_FALSE(IsDisplayingText(browser, "search query"));
}
+// Checks that the local error page is being displayed, without remotely
+// retrieved navigation corrections, and with the specified error code.
+void ExpectDisplayingLocalErrorPage(Browser* browser, net::Error error_code) {
+ ExpectDisplayingLocalErrorPage(browser, net::ErrorToShortString(error_code));
+}
+
// Checks that an error page with information retrieved from the navigation
// correction service is being displayed, with the specified specified error
-// code.
+// string.
void ExpectDisplayingNavigationCorrections(Browser* browser,
- net::Error error_code) {
- EXPECT_TRUE(IsDisplayingNetError(browser, error_code));
+ const std::string& error_string) {
+ EXPECT_TRUE(IsDisplayingText(browser, error_string));
// Check that the mock navigation corrections are displayed.
EXPECT_TRUE(IsDisplayingText(browser, "http://mock.http/title2.html"));
@@ -152,6 +152,15 @@ void ExpectDisplayingNavigationCorrections(Browser* browser,
EXPECT_FALSE(IsDisplayingDiagnosticsLink(browser));
}
+// Checks that an error page with information retrieved from the navigation
+// correction service is being displayed, with the specified specified error
+// code.
+void ExpectDisplayingNavigationCorrections(Browser* browser,
+ net::Error error_code) {
+ ExpectDisplayingNavigationCorrections(browser,
+ net::ErrorToShortString(error_code));
+}
+
std::string GetShowSavedButtonLabel() {
return l10n_util::GetStringUTF8(IDS_ERRORPAGES_BUTTON_SHOW_SAVED_COPY);
}
@@ -927,6 +936,30 @@ IN_PROC_BROWSER_TEST_F(ErrorPageTest, Page404) {
EXPECT_EQ(0, link_doctor_interceptor()->num_requests());
}
+// Checks that navigation corrections are loaded in response to a 404 page with
+// no body.
+IN_PROC_BROWSER_TEST_F(ErrorPageTest, Empty404) {
+ // The first navigation should fail and load a blank page, while it fetches
+ // the Link Doctor response. The second navigation is the Link Doctor.
+ ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(
+ browser(),
+ net::URLRequestMockHTTPJob::GetMockUrl("errorpage/empty404.html"), 2);
+ // This depends on the non-internationalized error ID string in
+ // localized_error.cc.
+ ExpectDisplayingNavigationCorrections(browser(), "HTTP ERROR 404");
+ EXPECT_EQ(1, link_doctor_interceptor()->num_requests());
+}
+
+// Checks that a local error page is shown in response to a 500 error page
+// without a body.
+IN_PROC_BROWSER_TEST_F(ErrorPageTest, Empty500) {
+ NavigateToFileURL("errorpage/empty500.html");
+ // This depends on the non-internationalized error ID string in
+ // localized_error.cc.
+ ExpectDisplayingLocalErrorPage(browser(), "HTTP ERROR 500");
+ EXPECT_EQ(0, link_doctor_interceptor()->num_requests());
+}
+
// Checks that when an error occurs, the stale cache status of the page
// is correctly transferred, and that stale cached copied can be loaded
// from the javascript.

Powered by Google App Engine
This is Rietveld 408576698