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

Unified Diff: net/url_request/url_request_unittest.cc

Issue 11931024: Removed static factories for data, ftp, file, and about jobs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync (r198785) Created 7 years, 7 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 | « net/url_request/url_request_test_util.cc ('k') | webkit/tools/test_shell/test_shell_request_context.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_unittest.cc
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc
index dec3ba269d22eb6c5614d7d7413f661a94739eaa..8f7864fe0b42fb4e52bbf508e9f2666a631cc13b 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -58,6 +58,8 @@
#include "net/ssl/ssl_connection_status_flags.h"
#include "net/test/cert_test_util.h"
#include "net/test/spawned_test_server/spawned_test_server.h"
+#include "net/url_request/data_protocol_handler.h"
+#include "net/url_request/file_protocol_handler.h"
#include "net/url_request/ftp_protocol_handler.h"
#include "net/url_request/static_http_user_agent_settings.h"
#include "net/url_request/url_request.h"
@@ -558,6 +560,9 @@ class URLRequestTest : public PlatformTest {
URLRequestTest() : default_context_(true) {
default_context_.set_network_delegate(&default_network_delegate_);
default_context_.set_net_log(&net_log_);
+ job_factory_.SetProtocolHandler("data", new DataProtocolHandler);
+ job_factory_.SetProtocolHandler("file", new FileProtocolHandler);
+ default_context_.set_job_factory(&job_factory_);
default_context_.Init();
}
virtual ~URLRequestTest() {}
@@ -565,16 +570,15 @@ class URLRequestTest : public PlatformTest {
// Adds the TestJobInterceptor to the default context.
TestJobInterceptor* AddTestInterceptor() {
TestJobInterceptor* protocol_handler_ = new TestJobInterceptor();
- job_factory_.reset(new URLRequestJobFactoryImpl);
- job_factory_->SetProtocolHandler("http", protocol_handler_);
- default_context_.set_job_factory(job_factory_.get());
+ job_factory_.SetProtocolHandler("http", NULL);
+ job_factory_.SetProtocolHandler("http", protocol_handler_);
return protocol_handler_;
}
protected:
CapturingNetLog net_log_;
TestNetworkDelegate default_network_delegate_; // Must outlive URLRequest.
- scoped_ptr<URLRequestJobFactoryImpl> job_factory_;
+ URLRequestJobFactoryImpl job_factory_;
TestURLRequestContext default_context_;
};
@@ -3862,6 +3866,20 @@ TEST_F(URLRequestTestHTTP, ContentTypeNormalizationTest) {
req.Cancel();
}
+TEST_F(URLRequestTestHTTP, ProtocolHandlerAndFactoryRestrictRedirects) {
+ // Test URLRequestJobFactory::ProtocolHandler::IsSafeRedirectTarget().
+ GURL file_url("file:///foo.txt");
+ GURL data_url("data:,foo");
+ FileProtocolHandler file_protocol_handler;
+ EXPECT_FALSE(file_protocol_handler.IsSafeRedirectTarget(file_url));
+ DataProtocolHandler data_protocol_handler;
+ EXPECT_TRUE(data_protocol_handler.IsSafeRedirectTarget(data_url));
+
+ // Test URLRequestJobFactoryImpl::IsSafeRedirectTarget().
+ EXPECT_FALSE(job_factory_.IsSafeRedirectTarget(file_url));
+ EXPECT_TRUE(job_factory_.IsSafeRedirectTarget(data_url));
+}
+
TEST_F(URLRequestTestHTTP, RestrictRedirects) {
ASSERT_TRUE(test_server_.Start());
@@ -5452,15 +5470,12 @@ TEST_F(URLRequestTestFTP, UnsafePort) {
ASSERT_TRUE(test_server_.Start());
URLRequestJobFactoryImpl job_factory;
+ FtpNetworkLayer ftp_transaction_factory(default_context_.host_resolver());
GURL url("ftp://127.0.0.1:7");
- FtpProtocolHandler ftp_protocol_handler(
- default_context_.ftp_transaction_factory(),
- default_context_.ftp_auth_cache());
job_factory.SetProtocolHandler(
"ftp",
- new FtpProtocolHandler(default_context_.ftp_transaction_factory(),
- default_context_.ftp_auth_cache()));
+ new FtpProtocolHandler(&ftp_transaction_factory));
default_context_.set_job_factory(&job_factory);
TestDelegate d;
« no previous file with comments | « net/url_request/url_request_test_util.cc ('k') | webkit/tools/test_shell/test_shell_request_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698