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

Unified Diff: content/renderer/render_view_browsertest.cc

Issue 1227823010: Handle empty error pages in DidFinishDocumentLoad (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Disable test on android, like the other error page tests Created 5 years, 5 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/renderer/render_frame_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_view_browsertest.cc
diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc
index a1d362d4c7bab21be70679b83a985373395505eb..ebf86521c4486ee83c198349917c025615f8e485 100644
--- a/content/renderer/render_view_browsertest.cc
+++ b/content/renderer/render_view_browsertest.cc
@@ -1971,7 +1971,7 @@ TEST_F(RenderViewImplTest, MessageOrderInDidChangeSelection) {
EXPECT_LT(last_input_type, last_selection);
}
-class SuppressErrorPageTest : public RenderViewImplTest {
+class RendererErrorPageTest : public RenderViewImplTest {
public:
ContentRendererClient* CreateContentRendererClient() override {
return new TestContentRendererClient;
@@ -2002,6 +2002,11 @@ class SuppressErrorPageTest : public RenderViewImplTest {
if (error_html)
*error_html = "A suffusion of yellow.";
}
+
+ bool HasErrorPage(int http_status_code,
+ std::string* error_domain) override {
+ return true;
+ }
};
};
@@ -2012,7 +2017,7 @@ class SuppressErrorPageTest : public RenderViewImplTest {
#define MAYBE_Suppresses Suppresses
#endif
-TEST_F(SuppressErrorPageTest, MAYBE_Suppresses) {
+TEST_F(RendererErrorPageTest, MAYBE_Suppresses) {
WebURLError error;
error.domain = WebString::fromUTF8(net::kErrorDomain);
error.reason = net::ERR_FILE_NOT_FOUND;
@@ -2043,7 +2048,7 @@ TEST_F(SuppressErrorPageTest, MAYBE_Suppresses) {
#define MAYBE_DoesNotSuppress DoesNotSuppress
#endif
-TEST_F(SuppressErrorPageTest, MAYBE_DoesNotSuppress) {
+TEST_F(RendererErrorPageTest, MAYBE_DoesNotSuppress) {
WebURLError error;
error.domain = WebString::fromUTF8(net::kErrorDomain);
error.reason = net::ERR_FILE_NOT_FOUND;
@@ -2070,6 +2075,39 @@ TEST_F(SuppressErrorPageTest, MAYBE_DoesNotSuppress) {
base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters)));
}
+#if defined(OS_ANDROID)
+// Crashing on Android: http://crbug.com/311341
+#define MAYBE_HttpStatusCodeErrorWithEmptyBody \
+ DISABLED_HttpStatusCodeErrorWithEmptyBody
+#else
+#define MAYBE_HttpStatusCodeErrorWithEmptyBody HttpStatusCodeErrorWithEmptyBody
+#endif
+TEST_F(RendererErrorPageTest, MAYBE_HttpStatusCodeErrorWithEmptyBody) {
+ blink::WebURLResponse response;
+ response.initialize();
+ response.setHTTPStatusCode(503);
+ WebLocalFrame* web_frame = GetMainFrame();
+
+ // Start a load that will reach provisional state synchronously,
+ // but won't complete synchronously.
+ CommonNavigationParams common_params;
+ common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
+ common_params.url = GURL("data:text/html,test data");
+ TestRenderFrame* main_frame = static_cast<TestRenderFrame*>(frame());
+ main_frame->Navigate(common_params, StartNavigationParams(),
+ RequestNavigationParams());
+
+ // Emulate a 4xx/5xx main resource response with an empty body.
+ main_frame->didReceiveResponse(web_frame, 1, response);
+ main_frame->didFinishDocumentLoad(web_frame, true);
+
+ // The error page itself is loaded asynchronously.
+ FrameLoadWaiter(main_frame).Wait();
+ const int kMaxOutputCharacters = 22;
+ EXPECT_EQ("A suffusion of yellow.",
+ base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters)));
+}
+
// Ensure the render view sends favicon url update events correctly.
TEST_F(RenderViewImplTest, SendFaviconURLUpdateEvent) {
// An event should be sent when a favicon url exists.
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698