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

Unified 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: Handle TemplateURL change Created 7 years, 3 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: content/renderer/render_view_browsertest.cc
diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc
index fc13ec0f7036962fc7232f6ebb5d44b64d10c44d..a66e041ce9d62419b3a4285ff9cb4da2dc4f8ae6 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

Powered by Google App Engine
This is Rietveld 408576698