| OLD | NEW |
| 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 Loading... |
| 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.Start(); |
| 1917 EXPECT_EQ(MAXIMUM_PRIORITY, req.priority()); |
| 1918 EXPECT_EQ(MAXIMUM_PRIORITY, job->priority()); |
| 1919 } |
| 1920 |
| 1899 // TODO(droger): Support SpawnedTestServer on iOS (see http://crbug.com/148666). | 1921 // TODO(droger): Support SpawnedTestServer on iOS (see http://crbug.com/148666). |
| 1900 #if !defined(OS_IOS) | 1922 #if !defined(OS_IOS) |
| 1901 // A subclass of SpawnedTestServer that uses a statically-configured hostname. | 1923 // A subclass of SpawnedTestServer that uses a statically-configured hostname. |
| 1902 // This is to work around mysterious failures in chrome_frame_net_tests. See: | 1924 // This is to work around mysterious failures in chrome_frame_net_tests. See: |
| 1903 // http://crbug.com/114369 | 1925 // http://crbug.com/114369 |
| 1904 class LocalHttpTestServer : public SpawnedTestServer { | 1926 class LocalHttpTestServer : public SpawnedTestServer { |
| 1905 public: | 1927 public: |
| 1906 explicit LocalHttpTestServer(const base::FilePath& document_root) | 1928 explicit LocalHttpTestServer(const base::FilePath& document_root) |
| 1907 : SpawnedTestServer(SpawnedTestServer::TYPE_HTTP, | 1929 : SpawnedTestServer(SpawnedTestServer::TYPE_HTTP, |
| 1908 ScopedCustomUrlRequestTestHttpHost::value(), | 1930 ScopedCustomUrlRequestTestHttpHost::value(), |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1997 | 2019 |
| 1998 // Verify that the cookie isn't sent when LOAD_DO_NOT_SEND_COOKIES is set. | 2020 // Verify that the cookie isn't sent when LOAD_DO_NOT_SEND_COOKIES is set. |
| 1999 { | 2021 { |
| 2000 TestNetworkDelegate network_delegate; | 2022 TestNetworkDelegate network_delegate; |
| 2001 default_context_.set_network_delegate(&network_delegate); | 2023 default_context_.set_network_delegate(&network_delegate); |
| 2002 TestDelegate d; | 2024 TestDelegate d; |
| 2003 URLRequest req(test_server.GetURL("echoheader?Cookie"), | 2025 URLRequest req(test_server.GetURL("echoheader?Cookie"), |
| 2004 DEFAULT_PRIORITY, | 2026 DEFAULT_PRIORITY, |
| 2005 &d, | 2027 &d, |
| 2006 &default_context_); | 2028 &default_context_); |
| 2007 req.set_load_flags(LOAD_DO_NOT_SEND_COOKIES); | 2029 req.SetLoadFlags(LOAD_DO_NOT_SEND_COOKIES); |
| 2008 req.Start(); | 2030 req.Start(); |
| 2009 base::RunLoop().Run(); | 2031 base::RunLoop().Run(); |
| 2010 | 2032 |
| 2011 EXPECT_TRUE(d.data_received().find("Cookie: CookieToNotSend=1") | 2033 EXPECT_TRUE(d.data_received().find("Cookie: CookieToNotSend=1") |
| 2012 == std::string::npos); | 2034 == std::string::npos); |
| 2013 | 2035 |
| 2014 // LOAD_DO_NOT_SEND_COOKIES does not trigger OnGetCookies. | 2036 // LOAD_DO_NOT_SEND_COOKIES does not trigger OnGetCookies. |
| 2015 EXPECT_EQ(0, network_delegate.blocked_get_cookies_count()); | 2037 EXPECT_EQ(0, network_delegate.blocked_get_cookies_count()); |
| 2016 EXPECT_EQ(0, network_delegate.blocked_set_cookie_count()); | 2038 EXPECT_EQ(0, network_delegate.blocked_set_cookie_count()); |
| 2017 } | 2039 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2041 // Try to set-up another cookie and update the previous cookie. | 2063 // Try to set-up another cookie and update the previous cookie. |
| 2042 { | 2064 { |
| 2043 TestNetworkDelegate network_delegate; | 2065 TestNetworkDelegate network_delegate; |
| 2044 default_context_.set_network_delegate(&network_delegate); | 2066 default_context_.set_network_delegate(&network_delegate); |
| 2045 TestDelegate d; | 2067 TestDelegate d; |
| 2046 URLRequest req( | 2068 URLRequest req( |
| 2047 test_server.GetURL("set-cookie?CookieToNotSave=1&CookieToNotUpdate=1"), | 2069 test_server.GetURL("set-cookie?CookieToNotSave=1&CookieToNotUpdate=1"), |
| 2048 DEFAULT_PRIORITY, | 2070 DEFAULT_PRIORITY, |
| 2049 &d, | 2071 &d, |
| 2050 &default_context_); | 2072 &default_context_); |
| 2051 req.set_load_flags(LOAD_DO_NOT_SAVE_COOKIES); | 2073 req.SetLoadFlags(LOAD_DO_NOT_SAVE_COOKIES); |
| 2052 req.Start(); | 2074 req.Start(); |
| 2053 | 2075 |
| 2054 base::RunLoop().Run(); | 2076 base::RunLoop().Run(); |
| 2055 | 2077 |
| 2056 // LOAD_DO_NOT_SAVE_COOKIES does not trigger OnSetCookie. | 2078 // LOAD_DO_NOT_SAVE_COOKIES does not trigger OnSetCookie. |
| 2057 EXPECT_EQ(0, network_delegate.blocked_get_cookies_count()); | 2079 EXPECT_EQ(0, network_delegate.blocked_get_cookies_count()); |
| 2058 EXPECT_EQ(0, network_delegate.blocked_set_cookie_count()); | 2080 EXPECT_EQ(0, network_delegate.blocked_set_cookie_count()); |
| 2059 EXPECT_EQ(0, network_delegate.set_cookie_count()); | 2081 EXPECT_EQ(0, network_delegate.set_cookie_count()); |
| 2060 } | 2082 } |
| 2061 | 2083 |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2483 { | 2505 { |
| 2484 TestDelegate d; | 2506 TestDelegate d; |
| 2485 URLRequest req(test_server.GetURL("echoheader?Referer"), | 2507 URLRequest req(test_server.GetURL("echoheader?Referer"), |
| 2486 DEFAULT_PRIORITY, | 2508 DEFAULT_PRIORITY, |
| 2487 &d, | 2509 &d, |
| 2488 &default_context_); | 2510 &default_context_); |
| 2489 | 2511 |
| 2490 HttpRequestHeaders headers; | 2512 HttpRequestHeaders headers; |
| 2491 headers.SetHeader(HttpRequestHeaders::kReferer, "http://bar.com/"); | 2513 headers.SetHeader(HttpRequestHeaders::kReferer, "http://bar.com/"); |
| 2492 req.SetExtraRequestHeaders(headers); | 2514 req.SetExtraRequestHeaders(headers); |
| 2493 req.set_load_flags(LOAD_VALIDATE_CACHE); | 2515 req.SetLoadFlags(LOAD_VALIDATE_CACHE); |
| 2494 | 2516 |
| 2495 req.Start(); | 2517 req.Start(); |
| 2496 base::RunLoop().Run(); | 2518 base::RunLoop().Run(); |
| 2497 | 2519 |
| 2498 EXPECT_EQ("None", d.data_received()); | 2520 EXPECT_EQ("None", d.data_received()); |
| 2499 } | 2521 } |
| 2500 } | 2522 } |
| 2501 | 2523 |
| 2502 class URLRequestTestHTTP : public URLRequestTest { | 2524 class URLRequestTestHTTP : public URLRequestTest { |
| 2503 public: | 2525 public: |
| (...skipping 2790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5294 // cachable page, we expect this test to result in a 304. in which case, the | 5316 // cachable page, we expect this test to result in a 304. in which case, the |
| 5295 // response should be fetched from the cache. | 5317 // response should be fetched from the cache. |
| 5296 { | 5318 { |
| 5297 TestDelegate d; | 5319 TestDelegate d; |
| 5298 d.set_credentials(AuthCredentials(kUser, kSecret)); | 5320 d.set_credentials(AuthCredentials(kUser, kSecret)); |
| 5299 | 5321 |
| 5300 URLRequest r(test_server_.GetURL("auth-basic"), | 5322 URLRequest r(test_server_.GetURL("auth-basic"), |
| 5301 DEFAULT_PRIORITY, | 5323 DEFAULT_PRIORITY, |
| 5302 &d, | 5324 &d, |
| 5303 &default_context_); | 5325 &default_context_); |
| 5304 r.set_load_flags(LOAD_VALIDATE_CACHE); | 5326 r.SetLoadFlags(LOAD_VALIDATE_CACHE); |
| 5305 r.Start(); | 5327 r.Start(); |
| 5306 | 5328 |
| 5307 base::RunLoop().Run(); | 5329 base::RunLoop().Run(); |
| 5308 | 5330 |
| 5309 EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos); | 5331 EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos); |
| 5310 | 5332 |
| 5311 // Should be the same cached document. | 5333 // Should be the same cached document. |
| 5312 EXPECT_TRUE(r.was_cached()); | 5334 EXPECT_TRUE(r.was_cached()); |
| 5313 } | 5335 } |
| 5314 } | 5336 } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5414 // cachable page, we expect this test to result in a 304. In which case, the | 5436 // cachable page, we expect this test to result in a 304. In which case, the |
| 5415 // response should be fetched from the cache. | 5437 // response should be fetched from the cache. |
| 5416 { | 5438 { |
| 5417 TestDelegate d; | 5439 TestDelegate d; |
| 5418 d.set_credentials(AuthCredentials(kUser, kSecret)); | 5440 d.set_credentials(AuthCredentials(kUser, kSecret)); |
| 5419 | 5441 |
| 5420 URLRequest r(test_server_.GetURL("auth-basic"), | 5442 URLRequest r(test_server_.GetURL("auth-basic"), |
| 5421 DEFAULT_PRIORITY, | 5443 DEFAULT_PRIORITY, |
| 5422 &d, | 5444 &d, |
| 5423 &default_context_); | 5445 &default_context_); |
| 5424 r.set_load_flags(LOAD_VALIDATE_CACHE); | 5446 r.SetLoadFlags(LOAD_VALIDATE_CACHE); |
| 5425 r.Start(); | 5447 r.Start(); |
| 5426 | 5448 |
| 5427 base::RunLoop().Run(); | 5449 base::RunLoop().Run(); |
| 5428 | 5450 |
| 5429 EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos); | 5451 EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos); |
| 5430 | 5452 |
| 5431 // Should be the same cached document. | 5453 // Should be the same cached document. |
| 5432 EXPECT_TRUE(r.was_cached()); | 5454 EXPECT_TRUE(r.was_cached()); |
| 5433 | 5455 |
| 5434 // Since there was a request that went over the wire, the load timing | 5456 // 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 Loading... |
| 7246 | 7268 |
| 7247 EXPECT_FALSE(r.is_pending()); | 7269 EXPECT_FALSE(r.is_pending()); |
| 7248 EXPECT_EQ(1, d->response_started_count()); | 7270 EXPECT_EQ(1, d->response_started_count()); |
| 7249 EXPECT_FALSE(d->received_data_before_response()); | 7271 EXPECT_FALSE(d->received_data_before_response()); |
| 7250 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); | 7272 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); |
| 7251 } | 7273 } |
| 7252 } | 7274 } |
| 7253 #endif // !defined(DISABLE_FTP_SUPPORT) | 7275 #endif // !defined(DISABLE_FTP_SUPPORT) |
| 7254 | 7276 |
| 7255 } // namespace net | 7277 } // namespace net |
| OLD | NEW |