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

Side by Side Diff: content/renderer/render_view_browsertest.cc

Issue 23455047: InstantExtended: Send search URLs to renderers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More browsertest fixes Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « content/public/test/mock_render_thread.cc ('k') | content/renderer/render_view_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6
7 #include "base/memory/shared_memory.h" 7 #include "base/memory/shared_memory.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/common/ssl_status_serialization.h" 10 #include "content/common/ssl_status_serialization.h"
(...skipping 1932 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 SSLStatus ssl_status = view()->GetSSLStatusOfFrame(frame); 1943 SSLStatus ssl_status = view()->GetSSLStatusOfFrame(frame);
1944 EXPECT_FALSE(net::IsCertStatusError(ssl_status.cert_status)); 1944 EXPECT_FALSE(net::IsCertStatusError(ssl_status.cert_status));
1945 1945
1946 const_cast<WebKit::WebURLResponse&>(frame->dataSource()->response()). 1946 const_cast<WebKit::WebURLResponse&>(frame->dataSource()->response()).
1947 setSecurityInfo( 1947 setSecurityInfo(
1948 SerializeSecurityInfo(0, net::CERT_STATUS_ALL_ERRORS, 0, 0)); 1948 SerializeSecurityInfo(0, net::CERT_STATUS_ALL_ERRORS, 0, 0));
1949 ssl_status = view()->GetSSLStatusOfFrame(frame); 1949 ssl_status = view()->GetSSLStatusOfFrame(frame);
1950 EXPECT_TRUE(net::IsCertStatusError(ssl_status.cert_status)); 1950 EXPECT_TRUE(net::IsCertStatusError(ssl_status.cert_status));
1951 } 1951 }
1952 1952
1953 class SuppressErrorPageTest : public RenderViewTest {
1954 public:
1955 virtual void SetUp() OVERRIDE {
1956 SetRendererClientForTesting(&client_);
1957 RenderViewTest::SetUp();
1958 }
1959
1960 RenderViewImpl* view() {
1961 return static_cast<RenderViewImpl*>(view_);
1962 }
1963
1964 private:
1965 class TestContentRendererClient : public ContentRendererClient {
1966 public:
1967 virtual bool ShouldSuppressErrorPage(const GURL& url) OVERRIDE {
1968 return url == GURL("http://example.com/suppress");
1969 }
1970
1971 virtual void GetNavigationErrorStrings(
1972 WebKit::WebFrame* frame,
1973 const WebKit::WebURLRequest& failed_request,
1974 const WebKit::WebURLError& error,
1975 std::string* error_html,
1976 string16* error_description) OVERRIDE {
1977 if (error_html)
1978 *error_html = "A suffusion of yellow.";
1979 }
1980 };
1981
1982 TestContentRendererClient client_;
1983 };
1984
1985 TEST_F(SuppressErrorPageTest, Suppresses) {
1986 WebURLError error;
1987 error.domain = WebString::fromUTF8(net::kErrorDomain);
1988 error.reason = net::ERR_FILE_NOT_FOUND;
1989 error.unreachableURL = GURL("http://example.com/suppress");
1990 WebFrame* web_frame = GetMainFrame();
1991
1992 // Start a load that will reach provisional state synchronously,
1993 // but won't complete synchronously.
1994 ViewMsg_Navigate_Params params;
1995 params.page_id = -1;
1996 params.navigation_type = ViewMsg_Navigate_Type::NORMAL;
1997 params.url = GURL("data:text/html,test data");
1998 view()->OnNavigate(params);
1999
2000 // An error occurred.
2001 view()->didFailProvisionalLoad(web_frame, error);
2002 const int kMaxOutputCharacters = 22;
2003 EXPECT_EQ("", UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters)));
2004 }
2005
2006 TEST_F(SuppressErrorPageTest, DoesNotSuppress) {
2007 WebURLError error;
2008 error.domain = WebString::fromUTF8(net::kErrorDomain);
2009 error.reason = net::ERR_FILE_NOT_FOUND;
2010 error.unreachableURL = GURL("http://example.com/dont-suppress");
2011 WebFrame* web_frame = GetMainFrame();
2012
2013 // Start a load that will reach provisional state synchronously,
2014 // but won't complete synchronously.
2015 ViewMsg_Navigate_Params params;
2016 params.page_id = -1;
2017 params.navigation_type = ViewMsg_Navigate_Type::NORMAL;
2018 params.url = GURL("data:text/html,test data");
2019 view()->OnNavigate(params);
2020
2021 // An error occurred.
2022 view()->didFailProvisionalLoad(web_frame, error);
2023 ProcessPendingMessages();
2024 const int kMaxOutputCharacters = 22;
2025 EXPECT_EQ("A suffusion of yellow.",
2026 UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters)));
2027 }
2028
1953 } // namespace content 2029 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/mock_render_thread.cc ('k') | content/renderer/render_view_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698