| 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 530c3e6e117e793ac3ca58f1cbe9783d40f1aa0a..712beeaf64be9329f613f3be7165621d91a8794f 100644
|
| --- a/net/url_request/url_request_unittest.cc
|
| +++ b/net/url_request/url_request_unittest.cc
|
| @@ -2660,6 +2660,7 @@ TEST_F(URLRequestTest, FirstPartyOnlyCookiesEnabled) {
|
| scoped_ptr<URLRequest> req(default_context_.CreateRequest(
|
| test_server.GetURL("echoheader?Cookie"), DEFAULT_PRIORITY, &d));
|
| req->set_first_party_for_cookies(test_server.GetURL(""));
|
| + req->set_initiator(url::Origin(test_server.GetURL("")));
|
| req->Start();
|
| base::RunLoop().Run();
|
|
|
| @@ -2669,7 +2670,7 @@ TEST_F(URLRequestTest, FirstPartyOnlyCookiesEnabled) {
|
| EXPECT_EQ(0, network_delegate.blocked_set_cookie_count());
|
| }
|
|
|
| - // Verify that the cookie is not-sent for non-first-party requests.
|
| + // Verify that the cookie is not sent for non-first-party requests.
|
| {
|
| TestNetworkDelegate network_delegate;
|
| network_delegate.set_experimental_cookie_features_enabled(true);
|
| @@ -2678,6 +2679,48 @@ TEST_F(URLRequestTest, FirstPartyOnlyCookiesEnabled) {
|
| scoped_ptr<URLRequest> req(default_context_.CreateRequest(
|
| test_server.GetURL("echoheader?Cookie"), DEFAULT_PRIORITY, &d));
|
| req->set_first_party_for_cookies(GURL("http://third-party.test/"));
|
| + req->set_initiator(url::Origin(GURL("http://third-party.test/")));
|
| + req->Start();
|
| + base::RunLoop().Run();
|
| +
|
| + EXPECT_TRUE(d.data_received().find("FirstPartyCookieToSet=1") ==
|
| + std::string::npos);
|
| + EXPECT_EQ(0, network_delegate.blocked_get_cookies_count());
|
| + EXPECT_EQ(0, network_delegate.blocked_set_cookie_count());
|
| + }
|
| +
|
| + // Verify that the cookie is sent for non-first-party initiators when the
|
| + // method is "safe"
|
| + {
|
| + TestNetworkDelegate network_delegate;
|
| + network_delegate.set_experimental_cookie_features_enabled(true);
|
| + default_context_.set_network_delegate(&network_delegate);
|
| + TestDelegate d;
|
| + scoped_ptr<URLRequest> req(default_context_.CreateRequest(
|
| + test_server.GetURL("echoheader?Cookie"), DEFAULT_PRIORITY, &d));
|
| + req->set_first_party_for_cookies(test_server.GetURL(""));
|
| + req->set_initiator(url::Origin(GURL("http://third-party.test/")));
|
| + req->Start();
|
| + base::RunLoop().Run();
|
| +
|
| + EXPECT_FALSE(d.data_received().find("FirstPartyCookieToSet=1") ==
|
| + std::string::npos);
|
| + EXPECT_EQ(0, network_delegate.blocked_get_cookies_count());
|
| + EXPECT_EQ(0, network_delegate.blocked_set_cookie_count());
|
| + }
|
| +
|
| + // Verify that the cookie is not sent for non-first-party initiators when the
|
| + // method is unsafe (e.g. POST).
|
| + {
|
| + TestNetworkDelegate network_delegate;
|
| + network_delegate.set_experimental_cookie_features_enabled(true);
|
| + default_context_.set_network_delegate(&network_delegate);
|
| + TestDelegate d;
|
| + scoped_ptr<URLRequest> req(default_context_.CreateRequest(
|
| + test_server.GetURL("echoheader?Cookie"), DEFAULT_PRIORITY, &d));
|
| + req->set_first_party_for_cookies(test_server.GetURL(""));
|
| + req->set_initiator(url::Origin(GURL("http://third-party.test/")));
|
| + req->set_method("POST");
|
| req->Start();
|
| base::RunLoop().Run();
|
|
|
|
|