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

Side by Side 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: +test and comment in didFinishDocumentLoad 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 1953 matching lines...) Expand 10 before | Expand all | Expand 10 after
1964 } 1964 }
1965 } 1965 }
1966 1966
1967 EXPECT_TRUE(is_input_type_called); 1967 EXPECT_TRUE(is_input_type_called);
1968 EXPECT_TRUE(is_selection_called); 1968 EXPECT_TRUE(is_selection_called);
1969 1969
1970 // InputTypeChange shold be called earlier than SelectionChanged. 1970 // InputTypeChange shold be called earlier than SelectionChanged.
1971 EXPECT_LT(last_input_type, last_selection); 1971 EXPECT_LT(last_input_type, last_selection);
1972 } 1972 }
1973 1973
1974 class SuppressErrorPageTest : public RenderViewImplTest { 1974 class RendererErrorPageTest : public RenderViewImplTest {
1975 public: 1975 public:
1976 ContentRendererClient* CreateContentRendererClient() override { 1976 ContentRendererClient* CreateContentRendererClient() override {
1977 return new TestContentRendererClient; 1977 return new TestContentRendererClient;
1978 } 1978 }
1979 1979
1980 RenderViewImpl* view() { 1980 RenderViewImpl* view() {
1981 return static_cast<RenderViewImpl*>(view_); 1981 return static_cast<RenderViewImpl*>(view_);
1982 } 1982 }
1983 1983
1984 RenderFrameImpl* frame() { 1984 RenderFrameImpl* frame() {
(...skipping 10 matching lines...) Expand all
1995 1995
1996 void GetNavigationErrorStrings(content::RenderView* render_view, 1996 void GetNavigationErrorStrings(content::RenderView* render_view,
1997 blink::WebFrame* frame, 1997 blink::WebFrame* frame,
1998 const blink::WebURLRequest& failed_request, 1998 const blink::WebURLRequest& failed_request,
1999 const blink::WebURLError& error, 1999 const blink::WebURLError& error,
2000 std::string* error_html, 2000 std::string* error_html,
2001 base::string16* error_description) override { 2001 base::string16* error_description) override {
2002 if (error_html) 2002 if (error_html)
2003 *error_html = "A suffusion of yellow."; 2003 *error_html = "A suffusion of yellow.";
2004 } 2004 }
2005
2006 bool HasErrorPage(int http_status_code,
2007 std::string* error_domain) override {
2008 return true;
2009 }
2005 }; 2010 };
2006 }; 2011 };
2007 2012
2008 #if defined(OS_ANDROID) 2013 #if defined(OS_ANDROID)
2009 // Crashing on Android: http://crbug.com/311341 2014 // Crashing on Android: http://crbug.com/311341
2010 #define MAYBE_Suppresses DISABLED_Suppresses 2015 #define MAYBE_Suppresses DISABLED_Suppresses
2011 #else 2016 #else
2012 #define MAYBE_Suppresses Suppresses 2017 #define MAYBE_Suppresses Suppresses
2013 #endif 2018 #endif
2014 2019
2015 TEST_F(SuppressErrorPageTest, MAYBE_Suppresses) { 2020 TEST_F(RendererErrorPageTest, MAYBE_Suppresses) {
2016 WebURLError error; 2021 WebURLError error;
2017 error.domain = WebString::fromUTF8(net::kErrorDomain); 2022 error.domain = WebString::fromUTF8(net::kErrorDomain);
2018 error.reason = net::ERR_FILE_NOT_FOUND; 2023 error.reason = net::ERR_FILE_NOT_FOUND;
2019 error.unreachableURL = GURL("http://example.com/suppress"); 2024 error.unreachableURL = GURL("http://example.com/suppress");
2020 WebLocalFrame* web_frame = GetMainFrame(); 2025 WebLocalFrame* web_frame = GetMainFrame();
2021 2026
2022 // Start a load that will reach provisional state synchronously, 2027 // Start a load that will reach provisional state synchronously,
2023 // but won't complete synchronously. 2028 // but won't complete synchronously.
2024 CommonNavigationParams common_params; 2029 CommonNavigationParams common_params;
2025 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 2030 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
(...skipping 10 matching lines...) Expand all
2036 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); 2041 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters)));
2037 } 2042 }
2038 2043
2039 #if defined(OS_ANDROID) 2044 #if defined(OS_ANDROID)
2040 // Crashing on Android: http://crbug.com/311341 2045 // Crashing on Android: http://crbug.com/311341
2041 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress 2046 #define MAYBE_DoesNotSuppress DISABLED_DoesNotSuppress
2042 #else 2047 #else
2043 #define MAYBE_DoesNotSuppress DoesNotSuppress 2048 #define MAYBE_DoesNotSuppress DoesNotSuppress
2044 #endif 2049 #endif
2045 2050
2046 TEST_F(SuppressErrorPageTest, MAYBE_DoesNotSuppress) { 2051 TEST_F(RendererErrorPageTest, MAYBE_DoesNotSuppress) {
2047 WebURLError error; 2052 WebURLError error;
2048 error.domain = WebString::fromUTF8(net::kErrorDomain); 2053 error.domain = WebString::fromUTF8(net::kErrorDomain);
2049 error.reason = net::ERR_FILE_NOT_FOUND; 2054 error.reason = net::ERR_FILE_NOT_FOUND;
2050 error.unreachableURL = GURL("http://example.com/dont-suppress"); 2055 error.unreachableURL = GURL("http://example.com/dont-suppress");
2051 WebLocalFrame* web_frame = GetMainFrame(); 2056 WebLocalFrame* web_frame = GetMainFrame();
2052 2057
2053 // Start a load that will reach provisional state synchronously, 2058 // Start a load that will reach provisional state synchronously,
2054 // but won't complete synchronously. 2059 // but won't complete synchronously.
2055 CommonNavigationParams common_params; 2060 CommonNavigationParams common_params;
2056 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL; 2061 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
2057 common_params.url = GURL("data:text/html,test data"); 2062 common_params.url = GURL("data:text/html,test data");
2058 TestRenderFrame* main_frame = static_cast<TestRenderFrame*>(frame()); 2063 TestRenderFrame* main_frame = static_cast<TestRenderFrame*>(frame());
2059 main_frame->Navigate(common_params, StartNavigationParams(), 2064 main_frame->Navigate(common_params, StartNavigationParams(),
2060 RequestNavigationParams()); 2065 RequestNavigationParams());
2061 2066
2062 // An error occurred. 2067 // An error occurred.
2063 main_frame->didFailProvisionalLoad(web_frame, error, 2068 main_frame->didFailProvisionalLoad(web_frame, error,
2064 blink::WebStandardCommit); 2069 blink::WebStandardCommit);
2065 2070
2066 // The error page itself is loaded asynchronously. 2071 // The error page itself is loaded asynchronously.
2067 FrameLoadWaiter(main_frame).Wait(); 2072 FrameLoadWaiter(main_frame).Wait();
2068 const int kMaxOutputCharacters = 22; 2073 const int kMaxOutputCharacters = 22;
2069 EXPECT_EQ("A suffusion of yellow.", 2074 EXPECT_EQ("A suffusion of yellow.",
2070 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); 2075 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters)));
2071 } 2076 }
2072 2077
2078 TEST_F(RendererErrorPageTest, HttpStatusCodeErrorWithEmptyBody) {
2079 blink::WebURLResponse response;
2080 response.initialize();
2081 response.setHTTPStatusCode(503);
2082 WebLocalFrame* web_frame = GetMainFrame();
2083
2084 // Start a load that will reach provisional state synchronously,
2085 // but won't complete synchronously.
2086 CommonNavigationParams common_params;
2087 common_params.navigation_type = FrameMsg_Navigate_Type::NORMAL;
2088 common_params.url = GURL("data:text/html,test data");
2089 TestRenderFrame* main_frame = static_cast<TestRenderFrame*>(frame());
2090 main_frame->Navigate(common_params, StartNavigationParams(),
2091 RequestNavigationParams());
2092
2093 // Emulate a 4xx/5xx main resource response with an empty body.
2094 main_frame->didReceiveResponse(web_frame, 1, response);
2095 main_frame->didFinishDocumentLoad(web_frame, true);
Charlie Reis 2015/07/13 20:42:43 Sanity check: This won't get flaky if the actual d
Nate Chapin 2015/07/13 21:15:26 It shouldn't. didFinishDocumentLoad() should synch
2096
2097 // The error page itself is loaded asynchronously.
2098 FrameLoadWaiter(main_frame).Wait();
2099 const int kMaxOutputCharacters = 22;
2100 EXPECT_EQ("A suffusion of yellow.",
2101 base::UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters)));
2102 }
2103
2073 // Ensure the render view sends favicon url update events correctly. 2104 // Ensure the render view sends favicon url update events correctly.
2074 TEST_F(RenderViewImplTest, SendFaviconURLUpdateEvent) { 2105 TEST_F(RenderViewImplTest, SendFaviconURLUpdateEvent) {
2075 // An event should be sent when a favicon url exists. 2106 // An event should be sent when a favicon url exists.
2076 LoadHTML("<html>" 2107 LoadHTML("<html>"
2077 "<head>" 2108 "<head>"
2078 "<link rel='icon' href='http://www.google.com/favicon.ico'>" 2109 "<link rel='icon' href='http://www.google.com/favicon.ico'>"
2079 "</head>" 2110 "</head>"
2080 "</html>"); 2111 "</html>");
2081 EXPECT_TRUE(render_thread_->sink().GetFirstMessageMatching( 2112 EXPECT_TRUE(render_thread_->sink().GetFirstMessageMatching(
2082 ViewHostMsg_UpdateFaviconURL::ID)); 2113 ViewHostMsg_UpdateFaviconURL::ID));
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
2322 FROM_HERE, 2353 FROM_HERE,
2323 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this))); 2354 base::Bind(&DevToolsAgentTest::CloseWhilePaused, base::Unretained(this)));
2324 ExecuteJavaScript("debugger;"); 2355 ExecuteJavaScript("debugger;");
2325 2356
2326 // CloseWhilePaused should resume execution and continue here. 2357 // CloseWhilePaused should resume execution and continue here.
2327 EXPECT_FALSE(IsPaused()); 2358 EXPECT_FALSE(IsPaused());
2328 Detach(); 2359 Detach();
2329 } 2360 }
2330 2361
2331 } // namespace content 2362 } // namespace content
OLDNEW
« content/renderer/render_frame_impl.cc ('K') | « content/renderer/render_frame_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698