| Index: content/renderer/render_view_browsertest.cc
|
| diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc
|
| index 4d6560668657ec39078339c6b8a7bcf4794f2c48..62ccd9d2336105aae50d0927c31ec03d3ed02a83 100644
|
| --- a/content/renderer/render_view_browsertest.cc
|
| +++ b/content/renderer/render_view_browsertest.cc
|
| @@ -1950,4 +1950,80 @@ TEST_F(RenderViewImplTest, GetSSLStatusOfFrame) {
|
| EXPECT_TRUE(net::IsCertStatusError(ssl_status.cert_status));
|
| }
|
|
|
| +class SuppressErrorPageTest : public RenderViewTest {
|
| + public:
|
| + virtual void SetUp() OVERRIDE {
|
| + SetRendererClientForTesting(&client_);
|
| + RenderViewTest::SetUp();
|
| + }
|
| +
|
| + RenderViewImpl* view() {
|
| + return static_cast<RenderViewImpl*>(view_);
|
| + }
|
| +
|
| + private:
|
| + class TestContentRendererClient : public ContentRendererClient {
|
| + public:
|
| + virtual bool ShouldSuppressErrorPage(const GURL& url) OVERRIDE {
|
| + return url == GURL("http://example.com/suppress");
|
| + }
|
| +
|
| + virtual void GetNavigationErrorStrings(
|
| + WebKit::WebFrame* frame,
|
| + const WebKit::WebURLRequest& failed_request,
|
| + const WebKit::WebURLError& error,
|
| + std::string* error_html,
|
| + string16* error_description) OVERRIDE {
|
| + if (error_html)
|
| + *error_html = "A suffusion of yellow.";
|
| + }
|
| + };
|
| +
|
| + TestContentRendererClient client_;
|
| +};
|
| +
|
| +TEST_F(SuppressErrorPageTest, Suppresses) {
|
| + WebURLError error;
|
| + error.domain = WebString::fromUTF8(net::kErrorDomain);
|
| + error.reason = net::ERR_FILE_NOT_FOUND;
|
| + error.unreachableURL = GURL("http://example.com/suppress");
|
| + WebFrame* web_frame = GetMainFrame();
|
| +
|
| + // Start a load that will reach provisional state synchronously,
|
| + // but won't complete synchronously.
|
| + ViewMsg_Navigate_Params params;
|
| + params.page_id = -1;
|
| + params.navigation_type = ViewMsg_Navigate_Type::NORMAL;
|
| + params.url = GURL("data:text/html,test data");
|
| + view()->OnNavigate(params);
|
| +
|
| + // An error occurred.
|
| + view()->didFailProvisionalLoad(web_frame, error);
|
| + const int kMaxOutputCharacters = 22;
|
| + EXPECT_EQ("", UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters)));
|
| +}
|
| +
|
| +TEST_F(SuppressErrorPageTest, DoesNotSuppress) {
|
| + WebURLError error;
|
| + error.domain = WebString::fromUTF8(net::kErrorDomain);
|
| + error.reason = net::ERR_FILE_NOT_FOUND;
|
| + error.unreachableURL = GURL("http://example.com/dont-suppress");
|
| + WebFrame* web_frame = GetMainFrame();
|
| +
|
| + // Start a load that will reach provisional state synchronously,
|
| + // but won't complete synchronously.
|
| + ViewMsg_Navigate_Params params;
|
| + params.page_id = -1;
|
| + params.navigation_type = ViewMsg_Navigate_Type::NORMAL;
|
| + params.url = GURL("data:text/html,test data");
|
| + view()->OnNavigate(params);
|
| +
|
| + // An error occurred.
|
| + view()->didFailProvisionalLoad(web_frame, error);
|
| + ProcessPendingMessages();
|
| + const int kMaxOutputCharacters = 22;
|
| + EXPECT_EQ("A suffusion of yellow.",
|
| + UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters)));
|
| +}
|
| +
|
| } // namespace content
|
|
|