| 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 3396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3407 EXPECT_TRUE(d.data_received().find("CookieToNotSave=1") | 3407 EXPECT_TRUE(d.data_received().find("CookieToNotSave=1") |
| 3408 == std::string::npos); | 3408 == std::string::npos); |
| 3409 EXPECT_TRUE(d.data_received().find("CookieToNotUpdate=2") | 3409 EXPECT_TRUE(d.data_received().find("CookieToNotUpdate=2") |
| 3410 != std::string::npos); | 3410 != std::string::npos); |
| 3411 | 3411 |
| 3412 EXPECT_EQ(0, network_delegate.blocked_get_cookies_count()); | 3412 EXPECT_EQ(0, network_delegate.blocked_get_cookies_count()); |
| 3413 EXPECT_EQ(0, network_delegate.blocked_set_cookie_count()); | 3413 EXPECT_EQ(0, network_delegate.blocked_set_cookie_count()); |
| 3414 } | 3414 } |
| 3415 } | 3415 } |
| 3416 | 3416 |
| 3417 void CheckCookiePolicyCallback(bool* was_run, const CookieList& cookies) { | |
| 3418 EXPECT_EQ(1U, cookies.size()); | |
| 3419 EXPECT_FALSE(cookies[0].IsPersistent()); | |
| 3420 *was_run = true; | |
| 3421 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | |
| 3422 } | |
| 3423 | |
| 3424 TEST_F(URLRequestTest, CookiePolicy_ForceSession) { | |
| 3425 LocalHttpTestServer test_server; | |
| 3426 ASSERT_TRUE(test_server.Start()); | |
| 3427 | |
| 3428 // Set up a cookie. | |
| 3429 { | |
| 3430 TestNetworkDelegate network_delegate; | |
| 3431 default_context_.set_network_delegate(&network_delegate); | |
| 3432 TestDelegate d; | |
| 3433 network_delegate.set_cookie_options(TestNetworkDelegate::FORCE_SESSION); | |
| 3434 URLRequest req( | |
| 3435 test_server.GetURL( | |
| 3436 "set-cookie?A=1;expires=\"Fri, 05 Feb 2010 23:42:01 GMT\""), | |
| 3437 &d, | |
| 3438 &default_context_); | |
| 3439 req.Start(); // Triggers an asynchronous cookie policy check. | |
| 3440 | |
| 3441 MessageLoop::current()->Run(); | |
| 3442 | |
| 3443 EXPECT_EQ(0, network_delegate.blocked_get_cookies_count()); | |
| 3444 EXPECT_EQ(0, network_delegate.blocked_set_cookie_count()); | |
| 3445 } | |
| 3446 default_context_.set_network_delegate(&default_network_delegate_); | |
| 3447 | |
| 3448 // Now, check the cookie store. | |
| 3449 bool was_run = false; | |
| 3450 default_context_.cookie_store()->GetCookieMonster()->GetAllCookiesAsync( | |
| 3451 base::Bind(&CheckCookiePolicyCallback, &was_run)); | |
| 3452 MessageLoop::current()->RunAllPending(); | |
| 3453 DCHECK(was_run); | |
| 3454 } | |
| 3455 | |
| 3456 // In this test, we do a POST which the server will 302 redirect. | 3417 // In this test, we do a POST which the server will 302 redirect. |
| 3457 // The subsequent transaction should use GET, and should not send the | 3418 // The subsequent transaction should use GET, and should not send the |
| 3458 // Content-Type header. | 3419 // Content-Type header. |
| 3459 // http://code.google.com/p/chromium/issues/detail?id=843 | 3420 // http://code.google.com/p/chromium/issues/detail?id=843 |
| 3460 TEST_F(URLRequestTestHTTP, Post302RedirectGet) { | 3421 TEST_F(URLRequestTestHTTP, Post302RedirectGet) { |
| 3461 ASSERT_TRUE(test_server_.Start()); | 3422 ASSERT_TRUE(test_server_.Start()); |
| 3462 | 3423 |
| 3463 const char kData[] = "hello world"; | 3424 const char kData[] = "hello world"; |
| 3464 | 3425 |
| 3465 TestDelegate d; | 3426 TestDelegate d; |
| (...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4638 req.SetExtraRequestHeaders(headers); | 4599 req.SetExtraRequestHeaders(headers); |
| 4639 req.Start(); | 4600 req.Start(); |
| 4640 MessageLoop::current()->Run(); | 4601 MessageLoop::current()->Run(); |
| 4641 // If the net tests are being run with ChromeFrame then we need to allow for | 4602 // If the net tests are being run with ChromeFrame then we need to allow for |
| 4642 // the 'chromeframe' suffix which is added to the user agent before the | 4603 // the 'chromeframe' suffix which is added to the user agent before the |
| 4643 // closing parentheses. | 4604 // closing parentheses. |
| 4644 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); | 4605 EXPECT_TRUE(StartsWithASCII(d.data_received(), "Lynx (textmode", true)); |
| 4645 } | 4606 } |
| 4646 | 4607 |
| 4647 } // namespace net | 4608 } // namespace net |
| OLD | NEW |