| 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 1913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1924 | 1924 |
| 1925 req.SetPriority(LOW); | 1925 req.SetPriority(LOW); |
| 1926 req.Start(); | 1926 req.Start(); |
| 1927 EXPECT_EQ(LOW, job->priority()); | 1927 EXPECT_EQ(LOW, job->priority()); |
| 1928 | 1928 |
| 1929 req.SetPriority(MEDIUM); | 1929 req.SetPriority(MEDIUM); |
| 1930 EXPECT_EQ(MEDIUM, req.priority()); | 1930 EXPECT_EQ(MEDIUM, req.priority()); |
| 1931 EXPECT_EQ(MEDIUM, job->priority()); | 1931 EXPECT_EQ(MEDIUM, job->priority()); |
| 1932 } | 1932 } |
| 1933 | 1933 |
| 1934 // Setting the IGNORE_LIMITS load flag should be okay if the priority |
| 1935 // is MAXIMUM_PRIORITY. |
| 1936 TEST_F(URLRequestTest, PriorityIgnoreLimits) { |
| 1937 TestDelegate d; |
| 1938 URLRequest req(GURL("http://test_intercept/foo"), |
| 1939 MAXIMUM_PRIORITY, |
| 1940 &d, |
| 1941 &default_context_); |
| 1942 EXPECT_EQ(MAXIMUM_PRIORITY, req.priority()); |
| 1943 |
| 1944 scoped_refptr<URLRequestTestJob> job = |
| 1945 new URLRequestTestJob(&req, &default_network_delegate_); |
| 1946 AddTestInterceptor()->set_main_intercept_job(job.get()); |
| 1947 |
| 1948 req.SetLoadFlags(LOAD_IGNORE_LIMITS); |
| 1949 EXPECT_EQ(MAXIMUM_PRIORITY, req.priority()); |
| 1950 |
| 1951 req.SetPriority(MAXIMUM_PRIORITY); |
| 1952 EXPECT_EQ(MAXIMUM_PRIORITY, req.priority()); |
| 1953 |
| 1954 req.Start(); |
| 1955 EXPECT_EQ(MAXIMUM_PRIORITY, req.priority()); |
| 1956 EXPECT_EQ(MAXIMUM_PRIORITY, job->priority()); |
| 1957 } |
| 1958 |
| 1934 // TODO(droger): Support SpawnedTestServer on iOS (see http://crbug.com/148666). | 1959 // TODO(droger): Support SpawnedTestServer on iOS (see http://crbug.com/148666). |
| 1935 #if !defined(OS_IOS) | 1960 #if !defined(OS_IOS) |
| 1936 // A subclass of SpawnedTestServer that uses a statically-configured hostname. | 1961 // A subclass of SpawnedTestServer that uses a statically-configured hostname. |
| 1937 // This is to work around mysterious failures in chrome_frame_net_tests. See: | 1962 // This is to work around mysterious failures in chrome_frame_net_tests. See: |
| 1938 // http://crbug.com/114369 | 1963 // http://crbug.com/114369 |
| 1939 class LocalHttpTestServer : public SpawnedTestServer { | 1964 class LocalHttpTestServer : public SpawnedTestServer { |
| 1940 public: | 1965 public: |
| 1941 explicit LocalHttpTestServer(const base::FilePath& document_root) | 1966 explicit LocalHttpTestServer(const base::FilePath& document_root) |
| 1942 : SpawnedTestServer(SpawnedTestServer::TYPE_HTTP, | 1967 : SpawnedTestServer(SpawnedTestServer::TYPE_HTTP, |
| 1943 ScopedCustomUrlRequestTestHttpHost::value(), | 1968 ScopedCustomUrlRequestTestHttpHost::value(), |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2032 | 2057 |
| 2033 // Verify that the cookie isn't sent when LOAD_DO_NOT_SEND_COOKIES is set. | 2058 // Verify that the cookie isn't sent when LOAD_DO_NOT_SEND_COOKIES is set. |
| 2034 { | 2059 { |
| 2035 TestNetworkDelegate network_delegate; | 2060 TestNetworkDelegate network_delegate; |
| 2036 default_context_.set_network_delegate(&network_delegate); | 2061 default_context_.set_network_delegate(&network_delegate); |
| 2037 TestDelegate d; | 2062 TestDelegate d; |
| 2038 URLRequest req(test_server.GetURL("echoheader?Cookie"), | 2063 URLRequest req(test_server.GetURL("echoheader?Cookie"), |
| 2039 DEFAULT_PRIORITY, | 2064 DEFAULT_PRIORITY, |
| 2040 &d, | 2065 &d, |
| 2041 &default_context_); | 2066 &default_context_); |
| 2042 req.set_load_flags(LOAD_DO_NOT_SEND_COOKIES); | 2067 req.SetLoadFlags(LOAD_DO_NOT_SEND_COOKIES); |
| 2043 req.Start(); | 2068 req.Start(); |
| 2044 base::RunLoop().Run(); | 2069 base::RunLoop().Run(); |
| 2045 | 2070 |
| 2046 EXPECT_TRUE(d.data_received().find("Cookie: CookieToNotSend=1") | 2071 EXPECT_TRUE(d.data_received().find("Cookie: CookieToNotSend=1") |
| 2047 == std::string::npos); | 2072 == std::string::npos); |
| 2048 | 2073 |
| 2049 // LOAD_DO_NOT_SEND_COOKIES does not trigger OnGetCookies. | 2074 // LOAD_DO_NOT_SEND_COOKIES does not trigger OnGetCookies. |
| 2050 EXPECT_EQ(0, network_delegate.blocked_get_cookies_count()); | 2075 EXPECT_EQ(0, network_delegate.blocked_get_cookies_count()); |
| 2051 EXPECT_EQ(0, network_delegate.blocked_set_cookie_count()); | 2076 EXPECT_EQ(0, network_delegate.blocked_set_cookie_count()); |
| 2052 } | 2077 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2076 // Try to set-up another cookie and update the previous cookie. | 2101 // Try to set-up another cookie and update the previous cookie. |
| 2077 { | 2102 { |
| 2078 TestNetworkDelegate network_delegate; | 2103 TestNetworkDelegate network_delegate; |
| 2079 default_context_.set_network_delegate(&network_delegate); | 2104 default_context_.set_network_delegate(&network_delegate); |
| 2080 TestDelegate d; | 2105 TestDelegate d; |
| 2081 URLRequest req( | 2106 URLRequest req( |
| 2082 test_server.GetURL("set-cookie?CookieToNotSave=1&CookieToNotUpdate=1"), | 2107 test_server.GetURL("set-cookie?CookieToNotSave=1&CookieToNotUpdate=1"), |
| 2083 DEFAULT_PRIORITY, | 2108 DEFAULT_PRIORITY, |
| 2084 &d, | 2109 &d, |
| 2085 &default_context_); | 2110 &default_context_); |
| 2086 req.set_load_flags(LOAD_DO_NOT_SAVE_COOKIES); | 2111 req.SetLoadFlags(LOAD_DO_NOT_SAVE_COOKIES); |
| 2087 req.Start(); | 2112 req.Start(); |
| 2088 | 2113 |
| 2089 base::RunLoop().Run(); | 2114 base::RunLoop().Run(); |
| 2090 | 2115 |
| 2091 // LOAD_DO_NOT_SAVE_COOKIES does not trigger OnSetCookie. | 2116 // LOAD_DO_NOT_SAVE_COOKIES does not trigger OnSetCookie. |
| 2092 EXPECT_EQ(0, network_delegate.blocked_get_cookies_count()); | 2117 EXPECT_EQ(0, network_delegate.blocked_get_cookies_count()); |
| 2093 EXPECT_EQ(0, network_delegate.blocked_set_cookie_count()); | 2118 EXPECT_EQ(0, network_delegate.blocked_set_cookie_count()); |
| 2094 EXPECT_EQ(0, network_delegate.set_cookie_count()); | 2119 EXPECT_EQ(0, network_delegate.set_cookie_count()); |
| 2095 } | 2120 } |
| 2096 | 2121 |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2518 { | 2543 { |
| 2519 TestDelegate d; | 2544 TestDelegate d; |
| 2520 URLRequest req(test_server.GetURL("echoheader?Referer"), | 2545 URLRequest req(test_server.GetURL("echoheader?Referer"), |
| 2521 DEFAULT_PRIORITY, | 2546 DEFAULT_PRIORITY, |
| 2522 &d, | 2547 &d, |
| 2523 &default_context_); | 2548 &default_context_); |
| 2524 | 2549 |
| 2525 HttpRequestHeaders headers; | 2550 HttpRequestHeaders headers; |
| 2526 headers.SetHeader(HttpRequestHeaders::kReferer, "http://bar.com/"); | 2551 headers.SetHeader(HttpRequestHeaders::kReferer, "http://bar.com/"); |
| 2527 req.SetExtraRequestHeaders(headers); | 2552 req.SetExtraRequestHeaders(headers); |
| 2528 req.set_load_flags(LOAD_VALIDATE_CACHE); | 2553 req.SetLoadFlags(LOAD_VALIDATE_CACHE); |
| 2529 | 2554 |
| 2530 req.Start(); | 2555 req.Start(); |
| 2531 base::RunLoop().Run(); | 2556 base::RunLoop().Run(); |
| 2532 | 2557 |
| 2533 EXPECT_EQ("None", d.data_received()); | 2558 EXPECT_EQ("None", d.data_received()); |
| 2534 } | 2559 } |
| 2535 } | 2560 } |
| 2536 | 2561 |
| 2537 class URLRequestTestHTTP : public URLRequestTest { | 2562 class URLRequestTestHTTP : public URLRequestTest { |
| 2538 public: | 2563 public: |
| (...skipping 2825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5364 // cachable page, we expect this test to result in a 304. in which case, the | 5389 // cachable page, we expect this test to result in a 304. in which case, the |
| 5365 // response should be fetched from the cache. | 5390 // response should be fetched from the cache. |
| 5366 { | 5391 { |
| 5367 TestDelegate d; | 5392 TestDelegate d; |
| 5368 d.set_credentials(AuthCredentials(kUser, kSecret)); | 5393 d.set_credentials(AuthCredentials(kUser, kSecret)); |
| 5369 | 5394 |
| 5370 URLRequest r(test_server_.GetURL("auth-basic"), | 5395 URLRequest r(test_server_.GetURL("auth-basic"), |
| 5371 DEFAULT_PRIORITY, | 5396 DEFAULT_PRIORITY, |
| 5372 &d, | 5397 &d, |
| 5373 &default_context_); | 5398 &default_context_); |
| 5374 r.set_load_flags(LOAD_VALIDATE_CACHE); | 5399 r.SetLoadFlags(LOAD_VALIDATE_CACHE); |
| 5375 r.Start(); | 5400 r.Start(); |
| 5376 | 5401 |
| 5377 base::RunLoop().Run(); | 5402 base::RunLoop().Run(); |
| 5378 | 5403 |
| 5379 EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos); | 5404 EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos); |
| 5380 | 5405 |
| 5381 // Should be the same cached document. | 5406 // Should be the same cached document. |
| 5382 EXPECT_TRUE(r.was_cached()); | 5407 EXPECT_TRUE(r.was_cached()); |
| 5383 } | 5408 } |
| 5384 } | 5409 } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5484 // cachable page, we expect this test to result in a 304. In which case, the | 5509 // cachable page, we expect this test to result in a 304. In which case, the |
| 5485 // response should be fetched from the cache. | 5510 // response should be fetched from the cache. |
| 5486 { | 5511 { |
| 5487 TestDelegate d; | 5512 TestDelegate d; |
| 5488 d.set_credentials(AuthCredentials(kUser, kSecret)); | 5513 d.set_credentials(AuthCredentials(kUser, kSecret)); |
| 5489 | 5514 |
| 5490 URLRequest r(test_server_.GetURL("auth-basic"), | 5515 URLRequest r(test_server_.GetURL("auth-basic"), |
| 5491 DEFAULT_PRIORITY, | 5516 DEFAULT_PRIORITY, |
| 5492 &d, | 5517 &d, |
| 5493 &default_context_); | 5518 &default_context_); |
| 5494 r.set_load_flags(LOAD_VALIDATE_CACHE); | 5519 r.SetLoadFlags(LOAD_VALIDATE_CACHE); |
| 5495 r.Start(); | 5520 r.Start(); |
| 5496 | 5521 |
| 5497 base::RunLoop().Run(); | 5522 base::RunLoop().Run(); |
| 5498 | 5523 |
| 5499 EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos); | 5524 EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos); |
| 5500 | 5525 |
| 5501 // Should be the same cached document. | 5526 // Should be the same cached document. |
| 5502 EXPECT_TRUE(r.was_cached()); | 5527 EXPECT_TRUE(r.was_cached()); |
| 5503 | 5528 |
| 5504 // Since there was a request that went over the wire, the load timing | 5529 // 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... |
| 7316 | 7341 |
| 7317 EXPECT_FALSE(r.is_pending()); | 7342 EXPECT_FALSE(r.is_pending()); |
| 7318 EXPECT_EQ(1, d->response_started_count()); | 7343 EXPECT_EQ(1, d->response_started_count()); |
| 7319 EXPECT_FALSE(d->received_data_before_response()); | 7344 EXPECT_FALSE(d->received_data_before_response()); |
| 7320 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); | 7345 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); |
| 7321 } | 7346 } |
| 7322 } | 7347 } |
| 7323 #endif // !defined(DISABLE_FTP_SUPPORT) | 7348 #endif // !defined(DISABLE_FTP_SUPPORT) |
| 7324 | 7349 |
| 7325 } // namespace net | 7350 } // namespace net |
| OLD | NEW |