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

Unified Diff: net/websockets/websocket_channel_test.cc

Issue 2102993002: Fix WebSocket to set first party for cookies (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: a Created 4 years, 6 months 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 side-by-side diff with in-line comments
Download patch
Index: net/websockets/websocket_channel_test.cc
diff --git a/net/websockets/websocket_channel_test.cc b/net/websockets/websocket_channel_test.cc
index dd2fa354b2c59f0b17e5e8d67d4992990b66a71a..b7835a0b4b7a9f24d373909719b74d13b73b15c0 100644
--- a/net/websockets/websocket_channel_test.cc
+++ b/net/websockets/websocket_channel_test.cc
@@ -700,12 +700,14 @@ struct ArgumentCopyingWebSocketStreamCreator {
const GURL& socket_url,
const std::vector<std::string>& requested_subprotocols,
const url::Origin& origin,
+ const GURL& first_party_for_cookies,
URLRequestContext* url_request_context,
const BoundNetLog& net_log,
std::unique_ptr<WebSocketStream::ConnectDelegate> connect_delegate) {
this->socket_url = socket_url;
this->requested_subprotocols = requested_subprotocols;
this->origin = origin;
+ this->first_party_for_cookies = first_party_for_cookies;
this->url_request_context = url_request_context;
this->net_log = net_log;
this->connect_delegate = std::move(connect_delegate);
@@ -714,6 +716,7 @@ struct ArgumentCopyingWebSocketStreamCreator {
GURL socket_url;
url::Origin origin;
+ GURL first_party_for_cookies;
std::vector<std::string> requested_subprotocols;
URLRequestContext* url_request_context;
BoundNetLog net_log;
@@ -745,9 +748,8 @@ class WebSocketChannelTest : public ::testing::Test {
channel_.reset(new WebSocketChannel(CreateEventInterface(),
&connect_data_.url_request_context));
channel_->SendAddChannelRequestForTesting(
- connect_data_.socket_url,
- connect_data_.requested_subprotocols,
- connect_data_.origin,
+ connect_data_.socket_url, connect_data_.requested_subprotocols,
+ connect_data_.origin, connect_data_.first_party_for_cookies,
base::Bind(&ArgumentCopyingWebSocketStreamCreator::Create,
base::Unretained(&connect_data_.creator)));
}
@@ -780,7 +782,10 @@ class WebSocketChannelTest : public ::testing::Test {
// A struct containing the data that will be used to connect the channel.
// Grouped for readability.
struct ConnectData {
- ConnectData() : socket_url("ws://ws/"), origin(GURL("http://ws")) {}
+ ConnectData()
+ : socket_url("ws://ws/"),
+ origin(GURL("http://ws")),
+ first_party_for_cookies("http://ws/") {}
// URLRequestContext object.
URLRequestContext url_request_context;
@@ -791,6 +796,8 @@ class WebSocketChannelTest : public ::testing::Test {
std::vector<std::string> requested_subprotocols;
// Origin of the request
url::Origin origin;
+ // First party for cookies for the request.
+ GURL first_party_for_cookies;
// A fake WebSocketStreamCreator that just records its arguments.
ArgumentCopyingWebSocketStreamCreator creator;
@@ -1005,6 +1012,7 @@ class WebSocketChannelReceiveUtf8Test : public WebSocketChannelStreamTest {
TEST_F(WebSocketChannelTest, EverythingIsPassedToTheCreatorFunction) {
connect_data_.socket_url = GURL("ws://example.com/test");
connect_data_.origin = url::Origin(GURL("http://example.com"));
+ connect_data_.first_party_for_cookies = GURL("http://example.com/");
connect_data_.requested_subprotocols.push_back("Sinbad");
CreateChannelAndConnect();
@@ -1017,6 +1025,8 @@ TEST_F(WebSocketChannelTest, EverythingIsPassedToTheCreatorFunction) {
EXPECT_EQ(connect_data_.requested_subprotocols,
actual.requested_subprotocols);
EXPECT_EQ(connect_data_.origin.Serialize(), actual.origin.Serialize());
+ EXPECT_EQ(connect_data_.first_party_for_cookies,
+ actual.first_party_for_cookies);
}
// Verify that calling SendFlowControl before the connection is established does

Powered by Google App Engine
This is Rietveld 408576698