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

Side by Side Diff: trunk/src/net/url_request/url_request_unittest.cc

Issue 47563006: Revert 232802 "[Net] Assert that URLRequests with LOAD_IGNORE_LI..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 1 month 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
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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shlobj.h> 9 #include <shlobj.h>
10 #endif 10 #endif
(...skipping 1878 matching lines...) Expand 10 before | Expand all | Expand 10 after
1889 1889
1890 req.SetPriority(LOW); 1890 req.SetPriority(LOW);
1891 req.Start(); 1891 req.Start();
1892 EXPECT_EQ(LOW, job->priority()); 1892 EXPECT_EQ(LOW, job->priority());
1893 1893
1894 req.SetPriority(MEDIUM); 1894 req.SetPriority(MEDIUM);
1895 EXPECT_EQ(MEDIUM, req.priority()); 1895 EXPECT_EQ(MEDIUM, req.priority());
1896 EXPECT_EQ(MEDIUM, job->priority()); 1896 EXPECT_EQ(MEDIUM, job->priority());
1897 } 1897 }
1898 1898
1899 // Setting the IGNORE_LIMITS load flag should be okay if the priority
1900 // is MAXIMUM_PRIORITY.
1901 TEST_F(URLRequestTest, PriorityIgnoreLimits) {
1902 TestDelegate d;
1903 URLRequest req(GURL("http://test_intercept/foo"),
1904 MAXIMUM_PRIORITY,
1905 &d,
1906 &default_context_);
1907 EXPECT_EQ(MAXIMUM_PRIORITY, req.priority());
1908
1909 scoped_refptr<URLRequestTestJob> job =
1910 new URLRequestTestJob(&req, &default_network_delegate_);
1911 AddTestInterceptor()->set_main_intercept_job(job.get());
1912
1913 req.SetLoadFlags(LOAD_IGNORE_LIMITS);
1914 EXPECT_EQ(MAXIMUM_PRIORITY, req.priority());
1915
1916 req.SetPriority(MAXIMUM_PRIORITY);
1917 EXPECT_EQ(MAXIMUM_PRIORITY, req.priority());
1918
1919 req.Start();
1920 EXPECT_EQ(MAXIMUM_PRIORITY, req.priority());
1921 EXPECT_EQ(MAXIMUM_PRIORITY, job->priority());
1922 }
1923
1924 // TODO(droger): Support SpawnedTestServer on iOS (see http://crbug.com/148666). 1899 // TODO(droger): Support SpawnedTestServer on iOS (see http://crbug.com/148666).
1925 #if !defined(OS_IOS) 1900 #if !defined(OS_IOS)
1926 // A subclass of SpawnedTestServer that uses a statically-configured hostname. 1901 // A subclass of SpawnedTestServer that uses a statically-configured hostname.
1927 // This is to work around mysterious failures in chrome_frame_net_tests. See: 1902 // This is to work around mysterious failures in chrome_frame_net_tests. See:
1928 // http://crbug.com/114369 1903 // http://crbug.com/114369
1929 class LocalHttpTestServer : public SpawnedTestServer { 1904 class LocalHttpTestServer : public SpawnedTestServer {
1930 public: 1905 public:
1931 explicit LocalHttpTestServer(const base::FilePath& document_root) 1906 explicit LocalHttpTestServer(const base::FilePath& document_root)
1932 : SpawnedTestServer(SpawnedTestServer::TYPE_HTTP, 1907 : SpawnedTestServer(SpawnedTestServer::TYPE_HTTP,
1933 ScopedCustomUrlRequestTestHttpHost::value(), 1908 ScopedCustomUrlRequestTestHttpHost::value(),
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
2022 1997
2023 // Verify that the cookie isn't sent when LOAD_DO_NOT_SEND_COOKIES is set. 1998 // Verify that the cookie isn't sent when LOAD_DO_NOT_SEND_COOKIES is set.
2024 { 1999 {
2025 TestNetworkDelegate network_delegate; 2000 TestNetworkDelegate network_delegate;
2026 default_context_.set_network_delegate(&network_delegate); 2001 default_context_.set_network_delegate(&network_delegate);
2027 TestDelegate d; 2002 TestDelegate d;
2028 URLRequest req(test_server.GetURL("echoheader?Cookie"), 2003 URLRequest req(test_server.GetURL("echoheader?Cookie"),
2029 DEFAULT_PRIORITY, 2004 DEFAULT_PRIORITY,
2030 &d, 2005 &d,
2031 &default_context_); 2006 &default_context_);
2032 req.SetLoadFlags(LOAD_DO_NOT_SEND_COOKIES); 2007 req.set_load_flags(LOAD_DO_NOT_SEND_COOKIES);
2033 req.Start(); 2008 req.Start();
2034 base::RunLoop().Run(); 2009 base::RunLoop().Run();
2035 2010
2036 EXPECT_TRUE(d.data_received().find("Cookie: CookieToNotSend=1") 2011 EXPECT_TRUE(d.data_received().find("Cookie: CookieToNotSend=1")
2037 == std::string::npos); 2012 == std::string::npos);
2038 2013
2039 // LOAD_DO_NOT_SEND_COOKIES does not trigger OnGetCookies. 2014 // LOAD_DO_NOT_SEND_COOKIES does not trigger OnGetCookies.
2040 EXPECT_EQ(0, network_delegate.blocked_get_cookies_count()); 2015 EXPECT_EQ(0, network_delegate.blocked_get_cookies_count());
2041 EXPECT_EQ(0, network_delegate.blocked_set_cookie_count()); 2016 EXPECT_EQ(0, network_delegate.blocked_set_cookie_count());
2042 } 2017 }
(...skipping 23 matching lines...) Expand all
2066 // Try to set-up another cookie and update the previous cookie. 2041 // Try to set-up another cookie and update the previous cookie.
2067 { 2042 {
2068 TestNetworkDelegate network_delegate; 2043 TestNetworkDelegate network_delegate;
2069 default_context_.set_network_delegate(&network_delegate); 2044 default_context_.set_network_delegate(&network_delegate);
2070 TestDelegate d; 2045 TestDelegate d;
2071 URLRequest req( 2046 URLRequest req(
2072 test_server.GetURL("set-cookie?CookieToNotSave=1&CookieToNotUpdate=1"), 2047 test_server.GetURL("set-cookie?CookieToNotSave=1&CookieToNotUpdate=1"),
2073 DEFAULT_PRIORITY, 2048 DEFAULT_PRIORITY,
2074 &d, 2049 &d,
2075 &default_context_); 2050 &default_context_);
2076 req.SetLoadFlags(LOAD_DO_NOT_SAVE_COOKIES); 2051 req.set_load_flags(LOAD_DO_NOT_SAVE_COOKIES);
2077 req.Start(); 2052 req.Start();
2078 2053
2079 base::RunLoop().Run(); 2054 base::RunLoop().Run();
2080 2055
2081 // LOAD_DO_NOT_SAVE_COOKIES does not trigger OnSetCookie. 2056 // LOAD_DO_NOT_SAVE_COOKIES does not trigger OnSetCookie.
2082 EXPECT_EQ(0, network_delegate.blocked_get_cookies_count()); 2057 EXPECT_EQ(0, network_delegate.blocked_get_cookies_count());
2083 EXPECT_EQ(0, network_delegate.blocked_set_cookie_count()); 2058 EXPECT_EQ(0, network_delegate.blocked_set_cookie_count());
2084 EXPECT_EQ(0, network_delegate.set_cookie_count()); 2059 EXPECT_EQ(0, network_delegate.set_cookie_count());
2085 } 2060 }
2086 2061
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
2508 { 2483 {
2509 TestDelegate d; 2484 TestDelegate d;
2510 URLRequest req(test_server.GetURL("echoheader?Referer"), 2485 URLRequest req(test_server.GetURL("echoheader?Referer"),
2511 DEFAULT_PRIORITY, 2486 DEFAULT_PRIORITY,
2512 &d, 2487 &d,
2513 &default_context_); 2488 &default_context_);
2514 2489
2515 HttpRequestHeaders headers; 2490 HttpRequestHeaders headers;
2516 headers.SetHeader(HttpRequestHeaders::kReferer, "http://bar.com/"); 2491 headers.SetHeader(HttpRequestHeaders::kReferer, "http://bar.com/");
2517 req.SetExtraRequestHeaders(headers); 2492 req.SetExtraRequestHeaders(headers);
2518 req.SetLoadFlags(LOAD_VALIDATE_CACHE); 2493 req.set_load_flags(LOAD_VALIDATE_CACHE);
2519 2494
2520 req.Start(); 2495 req.Start();
2521 base::RunLoop().Run(); 2496 base::RunLoop().Run();
2522 2497
2523 EXPECT_EQ("None", d.data_received()); 2498 EXPECT_EQ("None", d.data_received());
2524 } 2499 }
2525 } 2500 }
2526 2501
2527 class URLRequestTestHTTP : public URLRequestTest { 2502 class URLRequestTestHTTP : public URLRequestTest {
2528 public: 2503 public:
(...skipping 2790 matching lines...) Expand 10 before | Expand all | Expand 10 after
5319 // cachable page, we expect this test to result in a 304. in which case, the 5294 // cachable page, we expect this test to result in a 304. in which case, the
5320 // response should be fetched from the cache. 5295 // response should be fetched from the cache.
5321 { 5296 {
5322 TestDelegate d; 5297 TestDelegate d;
5323 d.set_credentials(AuthCredentials(kUser, kSecret)); 5298 d.set_credentials(AuthCredentials(kUser, kSecret));
5324 5299
5325 URLRequest r(test_server_.GetURL("auth-basic"), 5300 URLRequest r(test_server_.GetURL("auth-basic"),
5326 DEFAULT_PRIORITY, 5301 DEFAULT_PRIORITY,
5327 &d, 5302 &d,
5328 &default_context_); 5303 &default_context_);
5329 r.SetLoadFlags(LOAD_VALIDATE_CACHE); 5304 r.set_load_flags(LOAD_VALIDATE_CACHE);
5330 r.Start(); 5305 r.Start();
5331 5306
5332 base::RunLoop().Run(); 5307 base::RunLoop().Run();
5333 5308
5334 EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos); 5309 EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos);
5335 5310
5336 // Should be the same cached document. 5311 // Should be the same cached document.
5337 EXPECT_TRUE(r.was_cached()); 5312 EXPECT_TRUE(r.was_cached());
5338 } 5313 }
5339 } 5314 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
5439 // cachable page, we expect this test to result in a 304. In which case, the 5414 // cachable page, we expect this test to result in a 304. In which case, the
5440 // response should be fetched from the cache. 5415 // response should be fetched from the cache.
5441 { 5416 {
5442 TestDelegate d; 5417 TestDelegate d;
5443 d.set_credentials(AuthCredentials(kUser, kSecret)); 5418 d.set_credentials(AuthCredentials(kUser, kSecret));
5444 5419
5445 URLRequest r(test_server_.GetURL("auth-basic"), 5420 URLRequest r(test_server_.GetURL("auth-basic"),
5446 DEFAULT_PRIORITY, 5421 DEFAULT_PRIORITY,
5447 &d, 5422 &d,
5448 &default_context_); 5423 &default_context_);
5449 r.SetLoadFlags(LOAD_VALIDATE_CACHE); 5424 r.set_load_flags(LOAD_VALIDATE_CACHE);
5450 r.Start(); 5425 r.Start();
5451 5426
5452 base::RunLoop().Run(); 5427 base::RunLoop().Run();
5453 5428
5454 EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos); 5429 EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos);
5455 5430
5456 // Should be the same cached document. 5431 // Should be the same cached document.
5457 EXPECT_TRUE(r.was_cached()); 5432 EXPECT_TRUE(r.was_cached());
5458 5433
5459 // Since there was a request that went over the wire, the load timing 5434 // Since there was a request that went over the wire, the load timing
(...skipping 1811 matching lines...) Expand 10 before | Expand all | Expand 10 after
7271 7246
7272 EXPECT_FALSE(r.is_pending()); 7247 EXPECT_FALSE(r.is_pending());
7273 EXPECT_EQ(1, d->response_started_count()); 7248 EXPECT_EQ(1, d->response_started_count());
7274 EXPECT_FALSE(d->received_data_before_response()); 7249 EXPECT_FALSE(d->received_data_before_response());
7275 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); 7250 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size));
7276 } 7251 }
7277 } 7252 }
7278 #endif // !defined(DISABLE_FTP_SUPPORT) 7253 #endif // !defined(DISABLE_FTP_SUPPORT)
7279 7254
7280 } // namespace net 7255 } // namespace net
OLDNEW
« no previous file with comments | « trunk/src/net/url_request/url_request_throttler_unittest.cc ('k') | trunk/src/webkit/browser/appcache/appcache_update_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698