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

Unified Diff: net/websockets/websocket_stream_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: Update testRunner calls to setBlockThirdPartyCookies() Created 4 years, 5 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_stream_test.cc
diff --git a/net/websockets/websocket_stream_test.cc b/net/websockets/websocket_stream_test.cc
index a7d25d7b7ad282cd61cb071e81894fe805ee4122..f3938b3482014f41d76406205c5943cde08fe53a 100644
--- a/net/websockets/websocket_stream_test.cc
+++ b/net/websockets/websocket_stream_test.cc
@@ -76,10 +76,18 @@ static url::Origin LocalhostOrigin() {
return url::Origin(GURL("http://localhost/"));
}
+static GURL LocalhostUrl() {
+ return GURL("http://localhost/foobar");
+}
+
static url::Origin GoogleOrigin() {
return url::Origin(GURL("http://google.com/"));
}
+static GURL GoogleUrl() {
+ return GURL("http://google.com/foobar");
+}
+
class WebSocketStreamCreateTest : public ::testing::Test,
public WebSocketStreamCreateTestBase {
public:
@@ -96,6 +104,7 @@ class WebSocketStreamCreateTest : public ::testing::Test,
const std::string& socket_path,
const std::vector<std::string>& sub_protocols,
const url::Origin& origin,
+ const GURL& first_party_for_cookies,
const std::string& send_additional_request_headers,
const std::string& extra_request_headers,
const std::string& response_body,
@@ -105,7 +114,8 @@ class WebSocketStreamCreateTest : public ::testing::Test,
send_additional_request_headers,
extra_request_headers),
response_body);
- CreateAndConnectStream(socket_url, sub_protocols, origin,
+ CreateAndConnectStream(GURL(socket_url), sub_protocols, origin,
+ first_party_for_cookies,
send_additional_request_headers, std::move(timer));
}
@@ -117,13 +127,15 @@ class WebSocketStreamCreateTest : public ::testing::Test,
const std::string& socket_path,
const std::vector<std::string>& sub_protocols,
const url::Origin& origin,
+ const GURL& first_party_for_cookies,
const std::string& send_additional_request_headers,
const std::string& extra_request_headers,
const std::string& extra_response_headers,
std::unique_ptr<base::Timer> timer = std::unique_ptr<base::Timer>()) {
CreateAndConnectCustomResponse(
socket_url, socket_host, socket_path, sub_protocols, origin,
- send_additional_request_headers, extra_request_headers,
+ first_party_for_cookies, send_additional_request_headers,
+ extra_request_headers,
WebSocketStandardResponse(extra_response_headers), std::move(timer));
}
@@ -131,11 +143,13 @@ class WebSocketStreamCreateTest : public ::testing::Test,
const std::string& socket_url,
const std::vector<std::string>& sub_protocols,
const url::Origin& origin,
+ const GURL& first_party_for_cookies,
const std::string& send_additional_request_headers,
std::unique_ptr<SequencedSocketData> socket_data,
std::unique_ptr<base::Timer> timer = std::unique_ptr<base::Timer>()) {
AddRawExpectations(std::move(socket_data));
- CreateAndConnectStream(socket_url, sub_protocols, origin,
+ CreateAndConnectStream(GURL(socket_url), sub_protocols, origin,
+ first_party_for_cookies,
send_additional_request_headers, std::move(timer));
}
@@ -156,7 +170,7 @@ class WebSocketStreamCreateExtensionTest : public WebSocketStreamCreateTest {
const std::string& extensions_header_value) {
CreateAndConnectStandard(
"ws://localhost/testing_path", "localhost", "/testing_path",
- NoSubProtocols(), LocalhostOrigin(), "", "",
+ NoSubProtocols(), LocalhostOrigin(), LocalhostUrl(), "", "",
"Sec-WebSocket-Extensions: " + extensions_header_value + "\r\n");
WaitUntilConnectDone();
}
@@ -234,7 +248,7 @@ class WebSocketStreamCreateBasicAuthTest : public WebSocketStreamCreateTest {
const std::string request =
base::StringPrintf(request2format, base64_user_pass.c_str());
CreateAndConnectRawExpectations(
- url, NoSubProtocols(), LocalhostOrigin(), "",
+ url, NoSubProtocols(), LocalhostOrigin(), LocalhostUrl(), "",
helper_.BuildSocketData2(request, response2));
}
@@ -312,7 +326,8 @@ class WebSocketStreamCreateUMATest : public ::testing::Test {
// Confirm that the basic case works as expected.
TEST_F(WebSocketStreamCreateTest, SimpleSuccess) {
CreateAndConnectStandard("ws://localhost/", "localhost", "/",
- NoSubProtocols(), LocalhostOrigin(), "", "", "");
+ NoSubProtocols(), LocalhostOrigin(), LocalhostUrl(),
+ "", "", "");
EXPECT_FALSE(request_info_);
EXPECT_FALSE(response_info_);
WaitUntilConnectDone();
@@ -334,8 +349,8 @@ TEST_F(WebSocketStreamCreateTest, HandshakeInfo) {
"\r\n";
CreateAndConnectCustomResponse("ws://localhost/", "localhost", "/",
- NoSubProtocols(), LocalhostOrigin(), "", "",
- kResponse);
+ NoSubProtocols(), LocalhostOrigin(),
+ LocalhostUrl(), "", "", kResponse);
EXPECT_FALSE(request_info_);
EXPECT_FALSE(response_info_);
WaitUntilConnectDone();
@@ -391,7 +406,7 @@ TEST_F(WebSocketStreamCreateTest, HandshakeOverrideHeaders) {
"User-Agent: OveRrIde\r\n"
"rAnDomHeader: foobar\r\n");
CreateAndConnectStandard("ws://localhost/", "localhost", "/",
- NoSubProtocols(), LocalhostOrigin(),
+ NoSubProtocols(), LocalhostOrigin(), LocalhostUrl(),
additional_headers, additional_headers, "");
EXPECT_FALSE(request_info_);
EXPECT_FALSE(response_info_);
@@ -410,7 +425,8 @@ TEST_F(WebSocketStreamCreateTest, HandshakeOverrideHeaders) {
// Confirm that the stream isn't established until the message loop runs.
TEST_F(WebSocketStreamCreateTest, NeedsToRunLoop) {
CreateAndConnectStandard("ws://localhost/", "localhost", "/",
- NoSubProtocols(), LocalhostOrigin(), "", "", "");
+ NoSubProtocols(), LocalhostOrigin(), LocalhostUrl(),
+ "", "", "");
EXPECT_FALSE(has_failed());
EXPECT_FALSE(stream_);
}
@@ -419,7 +435,7 @@ TEST_F(WebSocketStreamCreateTest, NeedsToRunLoop) {
TEST_F(WebSocketStreamCreateTest, PathIsUsed) {
CreateAndConnectStandard("ws://localhost/testing_path", "localhost",
"/testing_path", NoSubProtocols(), LocalhostOrigin(),
- "", "", "");
+ LocalhostUrl(), "", "", "");
WaitUntilConnectDone();
EXPECT_FALSE(has_failed());
EXPECT_TRUE(stream_);
@@ -429,7 +445,7 @@ TEST_F(WebSocketStreamCreateTest, PathIsUsed) {
TEST_F(WebSocketStreamCreateTest, OriginIsUsed) {
CreateAndConnectStandard("ws://localhost/testing_path", "localhost",
"/testing_path", NoSubProtocols(), GoogleOrigin(),
- "", "", "");
+ GoogleUrl(), "", "", "");
WaitUntilConnectDone();
EXPECT_FALSE(has_failed());
EXPECT_TRUE(stream_);
@@ -441,7 +457,8 @@ TEST_F(WebSocketStreamCreateTest, SubProtocolIsUsed) {
sub_protocols.push_back("chatv11.chromium.org");
sub_protocols.push_back("chatv20.chromium.org");
CreateAndConnectStandard("ws://localhost/testing_path", "localhost",
- "/testing_path", sub_protocols, GoogleOrigin(), "",
+ "/testing_path", sub_protocols, GoogleOrigin(),
+ GoogleUrl(), "",
"Sec-WebSocket-Protocol: chatv11.chromium.org, "
"chatv20.chromium.org\r\n",
"Sec-WebSocket-Protocol: chatv20.chromium.org\r\n");
@@ -455,7 +472,7 @@ TEST_F(WebSocketStreamCreateTest, SubProtocolIsUsed) {
TEST_F(WebSocketStreamCreateTest, UnsolicitedSubProtocol) {
CreateAndConnectStandard("ws://localhost/testing_path", "localhost",
"/testing_path", NoSubProtocols(), GoogleOrigin(),
- "", "",
+ GoogleUrl(), "", "",
"Sec-WebSocket-Protocol: chatv20.chromium.org\r\n");
WaitUntilConnectDone();
EXPECT_FALSE(stream_);
@@ -472,8 +489,8 @@ TEST_F(WebSocketStreamCreateTest, UnacceptedSubProtocol) {
sub_protocols.push_back("chat.example.com");
CreateAndConnectStandard("ws://localhost/testing_path", "localhost",
"/testing_path", sub_protocols, LocalhostOrigin(),
- "", "Sec-WebSocket-Protocol: chat.example.com\r\n",
- "");
+ LocalhostUrl(), "",
+ "Sec-WebSocket-Protocol: chat.example.com\r\n", "");
WaitUntilConnectDone();
EXPECT_FALSE(stream_);
EXPECT_TRUE(has_failed());
@@ -489,7 +506,8 @@ TEST_F(WebSocketStreamCreateTest, MultipleSubProtocolsInResponse) {
sub_protocols.push_back("chatv11.chromium.org");
sub_protocols.push_back("chatv20.chromium.org");
CreateAndConnectStandard("ws://localhost/testing_path", "localhost",
- "/testing_path", sub_protocols, GoogleOrigin(), "",
+ "/testing_path", sub_protocols, GoogleOrigin(),
+ GoogleUrl(), "",
"Sec-WebSocket-Protocol: chatv11.chromium.org, "
"chatv20.chromium.org\r\n",
"Sec-WebSocket-Protocol: chatv11.chromium.org, "
@@ -509,7 +527,8 @@ TEST_F(WebSocketStreamCreateTest, UnmatchedSubProtocolInResponse) {
sub_protocols.push_back("chatv11.chromium.org");
sub_protocols.push_back("chatv20.chromium.org");
CreateAndConnectStandard("ws://localhost/testing_path", "localhost",
- "/testing_path", sub_protocols, GoogleOrigin(), "",
+ "/testing_path", sub_protocols, GoogleOrigin(),
+ GoogleUrl(), "",
"Sec-WebSocket-Protocol: chatv11.chromium.org, "
"chatv20.chromium.org\r\n",
"Sec-WebSocket-Protocol: chatv21.chromium.org\r\n");
@@ -544,7 +563,7 @@ TEST_F(WebSocketStreamCreateExtensionTest, PerMessageDeflateParamsSuccess) {
TEST_F(WebSocketStreamCreateExtensionTest, PerMessageDeflateInflates) {
CreateAndConnectCustomResponse(
"ws://localhost/testing_path", "localhost", "/testing_path",
- NoSubProtocols(), LocalhostOrigin(), "", "",
+ NoSubProtocols(), LocalhostOrigin(), LocalhostUrl(), "", "",
WebSocketStandardResponse(
"Sec-WebSocket-Extensions: permessage-deflate\r\n") +
std::string(
@@ -619,7 +638,8 @@ TEST_F(WebSocketStreamCreateExtensionTest, NoMaxWindowBitsArgument) {
TEST_F(WebSocketStreamCreateTest, DoubleAccept) {
CreateAndConnectStandard(
"ws://localhost/", "localhost", "/", NoSubProtocols(), LocalhostOrigin(),
- "", "", "Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r\n");
+ LocalhostUrl(), "", "",
+ "Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r\n");
WaitUntilConnectDone();
EXPECT_FALSE(stream_);
EXPECT_TRUE(has_failed());
@@ -637,9 +657,9 @@ TEST_F(WebSocketStreamCreateTest, InvalidStatusCode) {
"Connection: Upgrade\r\n"
"Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r\n"
"\r\n";
- CreateAndConnectCustomResponse("ws://localhost/", "localhost", "/",
- NoSubProtocols(), LocalhostOrigin(), "", "",
- kInvalidStatusCodeResponse);
+ CreateAndConnectCustomResponse(
+ "ws://localhost/", "localhost", "/", NoSubProtocols(), LocalhostOrigin(),
+ LocalhostUrl(), "", "", kInvalidStatusCodeResponse);
WaitUntilConnectDone();
EXPECT_TRUE(has_failed());
EXPECT_EQ("Error during WebSocket handshake: Unexpected response code: 200",
@@ -658,8 +678,8 @@ TEST_F(WebSocketStreamCreateTest, RedirectsRejected) {
"\r\n"
"<title>Moved</title><h1>Moved</h1>";
CreateAndConnectCustomResponse("ws://localhost/", "localhost", "/",
- NoSubProtocols(), LocalhostOrigin(), "", "",
- kRedirectResponse);
+ NoSubProtocols(), LocalhostOrigin(),
+ LocalhostUrl(), "", "", kRedirectResponse);
WaitUntilConnectDone();
EXPECT_TRUE(has_failed());
EXPECT_EQ("Error during WebSocket handshake: Unexpected response code: 302",
@@ -679,8 +699,8 @@ TEST_F(WebSocketStreamCreateTest, MalformedResponse) {
"Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r\n"
"\r\n";
CreateAndConnectCustomResponse("ws://localhost/", "localhost", "/",
- NoSubProtocols(), LocalhostOrigin(), "", "",
- kMalformedResponse);
+ NoSubProtocols(), LocalhostOrigin(),
+ LocalhostUrl(), "", "", kMalformedResponse);
WaitUntilConnectDone();
EXPECT_TRUE(has_failed());
EXPECT_EQ("Error during WebSocket handshake: Invalid status line",
@@ -694,9 +714,9 @@ TEST_F(WebSocketStreamCreateTest, MissingUpgradeHeader) {
"Connection: Upgrade\r\n"
"Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r\n"
"\r\n";
- CreateAndConnectCustomResponse("ws://localhost/", "localhost", "/",
- NoSubProtocols(), LocalhostOrigin(), "", "",
- kMissingUpgradeResponse);
+ CreateAndConnectCustomResponse(
+ "ws://localhost/", "localhost", "/", NoSubProtocols(), LocalhostOrigin(),
+ LocalhostUrl(), "", "", kMissingUpgradeResponse);
WaitUntilConnectDone();
EXPECT_TRUE(has_failed());
EXPECT_EQ("Error during WebSocket handshake: 'Upgrade' header is missing",
@@ -706,8 +726,8 @@ TEST_F(WebSocketStreamCreateTest, MissingUpgradeHeader) {
// There must only be one upgrade header.
TEST_F(WebSocketStreamCreateTest, DoubleUpgradeHeader) {
CreateAndConnectStandard("ws://localhost/", "localhost", "/",
- NoSubProtocols(), LocalhostOrigin(), "", "",
- "Upgrade: HTTP/2.0\r\n");
+ NoSubProtocols(), LocalhostOrigin(), LocalhostUrl(),
+ "", "", "Upgrade: HTTP/2.0\r\n");
WaitUntilConnectDone();
EXPECT_TRUE(has_failed());
EXPECT_EQ("Error during WebSocket handshake: "
@@ -723,9 +743,9 @@ TEST_F(WebSocketStreamCreateTest, IncorrectUpgradeHeader) {
"Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r\n"
"Upgrade: hogefuga\r\n"
"\r\n";
- CreateAndConnectCustomResponse("ws://localhost/", "localhost", "/",
- NoSubProtocols(), LocalhostOrigin(), "", "",
- kMissingUpgradeResponse);
+ CreateAndConnectCustomResponse(
+ "ws://localhost/", "localhost", "/", NoSubProtocols(), LocalhostOrigin(),
+ LocalhostUrl(), "", "", kMissingUpgradeResponse);
WaitUntilConnectDone();
EXPECT_TRUE(has_failed());
EXPECT_EQ("Error during WebSocket handshake: "
@@ -740,9 +760,9 @@ TEST_F(WebSocketStreamCreateTest, MissingConnectionHeader) {
"Upgrade: websocket\r\n"
"Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r\n"
"\r\n";
- CreateAndConnectCustomResponse("ws://localhost/", "localhost", "/",
- NoSubProtocols(), LocalhostOrigin(), "", "",
- kMissingConnectionResponse);
+ CreateAndConnectCustomResponse(
+ "ws://localhost/", "localhost", "/", NoSubProtocols(), LocalhostOrigin(),
+ LocalhostUrl(), "", "", kMissingConnectionResponse);
WaitUntilConnectDone();
EXPECT_TRUE(has_failed());
EXPECT_EQ("Error during WebSocket handshake: "
@@ -758,9 +778,9 @@ TEST_F(WebSocketStreamCreateTest, IncorrectConnectionHeader) {
"Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r\n"
"Connection: hogefuga\r\n"
"\r\n";
- CreateAndConnectCustomResponse("ws://localhost/", "localhost", "/",
- NoSubProtocols(), LocalhostOrigin(), "", "",
- kMissingConnectionResponse);
+ CreateAndConnectCustomResponse(
+ "ws://localhost/", "localhost", "/", NoSubProtocols(), LocalhostOrigin(),
+ LocalhostUrl(), "", "", kMissingConnectionResponse);
WaitUntilConnectDone();
EXPECT_TRUE(has_failed());
EXPECT_EQ("Error during WebSocket handshake: "
@@ -776,9 +796,9 @@ TEST_F(WebSocketStreamCreateTest, AdditionalTokenInConnectionHeader) {
"Connection: Upgrade, Keep-Alive\r\n"
"Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=\r\n"
"\r\n";
- CreateAndConnectCustomResponse("ws://localhost/", "localhost", "/",
- NoSubProtocols(), LocalhostOrigin(), "", "",
- kAdditionalConnectionTokenResponse);
+ CreateAndConnectCustomResponse(
+ "ws://localhost/", "localhost", "/", NoSubProtocols(), LocalhostOrigin(),
+ LocalhostUrl(), "", "", kAdditionalConnectionTokenResponse);
WaitUntilConnectDone();
EXPECT_FALSE(has_failed());
EXPECT_TRUE(stream_);
@@ -791,9 +811,9 @@ TEST_F(WebSocketStreamCreateTest, MissingSecWebSocketAccept) {
"Upgrade: websocket\r\n"
"Connection: Upgrade\r\n"
"\r\n";
- CreateAndConnectCustomResponse("ws://localhost/", "localhost", "/",
- NoSubProtocols(), LocalhostOrigin(), "", "",
- kMissingAcceptResponse);
+ CreateAndConnectCustomResponse(
+ "ws://localhost/", "localhost", "/", NoSubProtocols(), LocalhostOrigin(),
+ LocalhostUrl(), "", "", kMissingAcceptResponse);
WaitUntilConnectDone();
EXPECT_TRUE(has_failed());
EXPECT_EQ("Error during WebSocket handshake: "
@@ -809,9 +829,9 @@ TEST_F(WebSocketStreamCreateTest, WrongSecWebSocketAccept) {
"Connection: Upgrade\r\n"
"Sec-WebSocket-Accept: x/byyPZ2tOFvJCGkkugcKvqhhPk=\r\n"
"\r\n";
- CreateAndConnectCustomResponse("ws://localhost/", "localhost", "/",
- NoSubProtocols(), LocalhostOrigin(), "", "",
- kIncorrectAcceptResponse);
+ CreateAndConnectCustomResponse(
+ "ws://localhost/", "localhost", "/", NoSubProtocols(), LocalhostOrigin(),
+ LocalhostUrl(), "", "", kIncorrectAcceptResponse);
WaitUntilConnectDone();
EXPECT_TRUE(has_failed());
EXPECT_EQ("Error during WebSocket handshake: "
@@ -822,7 +842,8 @@ TEST_F(WebSocketStreamCreateTest, WrongSecWebSocketAccept) {
// Cancellation works.
TEST_F(WebSocketStreamCreateTest, Cancellation) {
CreateAndConnectStandard("ws://localhost/", "localhost", "/",
- NoSubProtocols(), LocalhostOrigin(), "", "", "");
+ NoSubProtocols(), LocalhostOrigin(), LocalhostUrl(),
+ "", "", "");
stream_request_.reset();
// WaitUntilConnectDone doesn't work in this case.
base::RunLoop().RunUntilIdle();
@@ -838,7 +859,7 @@ TEST_F(WebSocketStreamCreateTest, ConnectionFailure) {
socket_data->set_connect_data(
MockConnect(SYNCHRONOUS, ERR_CONNECTION_REFUSED));
CreateAndConnectRawExpectations("ws://localhost/", NoSubProtocols(),
- LocalhostOrigin(), "",
+ LocalhostOrigin(), LocalhostUrl(), "",
std::move(socket_data));
WaitUntilConnectDone();
EXPECT_TRUE(has_failed());
@@ -854,7 +875,7 @@ TEST_F(WebSocketStreamCreateTest, ConnectionTimeout) {
socket_data->set_connect_data(
MockConnect(ASYNC, ERR_CONNECTION_TIMED_OUT));
CreateAndConnectRawExpectations("ws://localhost/", NoSubProtocols(),
- LocalhostOrigin(), "",
+ LocalhostOrigin(), LocalhostUrl(), "",
std::move(socket_data));
WaitUntilConnectDone();
EXPECT_TRUE(has_failed());
@@ -869,8 +890,8 @@ TEST_F(WebSocketStreamCreateTest, HandshakeTimeout) {
std::unique_ptr<MockWeakTimer> timer(new MockWeakTimer(false, false));
base::WeakPtr<MockWeakTimer> weak_timer = timer->AsWeakPtr();
CreateAndConnectRawExpectations("ws://localhost/", NoSubProtocols(),
- LocalhostOrigin(), "", std::move(socket_data),
- std::move(timer));
+ LocalhostOrigin(), LocalhostUrl(), "",
+ std::move(socket_data), std::move(timer));
EXPECT_FALSE(has_failed());
ASSERT_TRUE(weak_timer.get());
EXPECT_TRUE(weak_timer->IsRunning());
@@ -890,8 +911,8 @@ TEST_F(WebSocketStreamCreateTest, HandshakeTimerOnSuccess) {
base::WeakPtr<MockWeakTimer> weak_timer = timer->AsWeakPtr();
CreateAndConnectStandard("ws://localhost/", "localhost", "/",
- NoSubProtocols(), LocalhostOrigin(), "", "", "",
- std::move(timer));
+ NoSubProtocols(), LocalhostOrigin(), LocalhostUrl(),
+ "", "", "", std::move(timer));
ASSERT_TRUE(weak_timer);
EXPECT_TRUE(weak_timer->IsRunning());
@@ -910,8 +931,8 @@ TEST_F(WebSocketStreamCreateTest, HandshakeTimerOnFailure) {
std::unique_ptr<MockWeakTimer> timer(new MockWeakTimer(false, false));
base::WeakPtr<MockWeakTimer> weak_timer = timer->AsWeakPtr();
CreateAndConnectRawExpectations("ws://localhost/", NoSubProtocols(),
- LocalhostOrigin(), "", std::move(socket_data),
- std::move(timer));
+ LocalhostOrigin(), LocalhostUrl(), "",
+ std::move(socket_data), std::move(timer));
ASSERT_TRUE(weak_timer.get());
EXPECT_TRUE(weak_timer->IsRunning());
@@ -928,7 +949,7 @@ TEST_F(WebSocketStreamCreateTest, CancellationDuringConnect) {
std::unique_ptr<SequencedSocketData> socket_data(BuildNullSocketData());
socket_data->set_connect_data(MockConnect(SYNCHRONOUS, ERR_IO_PENDING));
CreateAndConnectRawExpectations("ws://localhost/", NoSubProtocols(),
- LocalhostOrigin(), "",
+ LocalhostOrigin(), LocalhostUrl(), "",
std::move(socket_data));
stream_request_.reset();
// WaitUntilConnectDone doesn't work in this case.
@@ -945,7 +966,7 @@ TEST_F(WebSocketStreamCreateTest, CancellationDuringWrite) {
new SequencedSocketData(NULL, 0, writes, arraysize(writes)));
socket_data->set_connect_data(MockConnect(SYNCHRONOUS, OK));
CreateAndConnectRawExpectations("ws://localhost/", NoSubProtocols(),
- LocalhostOrigin(), "",
+ LocalhostOrigin(), LocalhostUrl(), "",
base::WrapUnique(socket_data));
base::RunLoop().RunUntilIdle();
EXPECT_TRUE(socket_data->AllWriteDataConsumed());
@@ -970,7 +991,7 @@ TEST_F(WebSocketStreamCreateTest, CancellationDuringRead) {
BuildSocketData(reads, writes));
SequencedSocketData* socket_data_raw_ptr = socket_data.get();
CreateAndConnectRawExpectations("ws://localhost/", NoSubProtocols(),
- LocalhostOrigin(), "",
+ LocalhostOrigin(), LocalhostUrl(), "",
std::move(socket_data));
base::RunLoop().RunUntilIdle();
EXPECT_TRUE(socket_data_raw_ptr->AllReadDataConsumed());
@@ -994,8 +1015,8 @@ TEST_F(WebSocketStreamCreateTest, VeryLargeResponseHeaders) {
}
ASSERT_GT(set_cookie_headers.size(), 256U * 1024U);
CreateAndConnectStandard("ws://localhost/", "localhost", "/",
- NoSubProtocols(), LocalhostOrigin(), "", "",
- set_cookie_headers);
+ NoSubProtocols(), LocalhostOrigin(), LocalhostUrl(),
+ "", "", set_cookie_headers);
WaitUntilConnectDone();
EXPECT_TRUE(has_failed());
EXPECT_FALSE(response_info_);
@@ -1013,7 +1034,7 @@ TEST_F(WebSocketStreamCreateTest, NoResponse) {
BuildSocketData(reads, writes));
SequencedSocketData* socket_data_raw_ptr = socket_data.get();
CreateAndConnectRawExpectations("ws://localhost/", NoSubProtocols(),
- LocalhostOrigin(), "",
+ LocalhostOrigin(), LocalhostUrl(), "",
std::move(socket_data));
base::RunLoop().RunUntilIdle();
EXPECT_TRUE(socket_data_raw_ptr->AllReadDataConsumed());
@@ -1032,7 +1053,7 @@ TEST_F(WebSocketStreamCreateTest, SelfSignedCertificateFailure) {
ASSERT_TRUE(ssl_data_[0]->cert.get());
std::unique_ptr<SequencedSocketData> raw_socket_data(BuildNullSocketData());
CreateAndConnectRawExpectations("wss://localhost/", NoSubProtocols(),
- LocalhostOrigin(), "",
+ LocalhostOrigin(), LocalhostUrl(), "",
std::move(raw_socket_data));
// WaitUntilConnectDone doesn't work in this case.
base::RunLoop().RunUntilIdle();
@@ -1055,7 +1076,8 @@ TEST_F(WebSocketStreamCreateTest, SelfSignedCertificateSuccess) {
ssl_data_.push_back(std::move(ssl_data));
url_request_context_host_.AddRawExpectations(BuildNullSocketData());
CreateAndConnectStandard("wss://localhost/", "localhost", "/",
- NoSubProtocols(), LocalhostOrigin(), "", "", "");
+ NoSubProtocols(), LocalhostOrigin(), LocalhostUrl(),
+ "", "", "");
// WaitUntilConnectDone doesn't work in this case.
base::RunLoop().RunUntilIdle();
ASSERT_TRUE(ssl_error_callbacks_);
@@ -1069,8 +1091,8 @@ TEST_F(WebSocketStreamCreateTest, SelfSignedCertificateSuccess) {
// connection should fail cleanly.
TEST_F(WebSocketStreamCreateBasicAuthTest, FailureNoCredentials) {
CreateAndConnectCustomResponse("ws://localhost/", "localhost", "/",
- NoSubProtocols(), LocalhostOrigin(), "", "",
- kUnauthorizedResponse);
+ NoSubProtocols(), LocalhostOrigin(),
+ LocalhostUrl(), "", "", kUnauthorizedResponse);
WaitUntilConnectDone();
EXPECT_TRUE(has_failed());
EXPECT_EQ("HTTP Authentication failed; no valid credentials available",
@@ -1104,7 +1126,8 @@ TEST_F(WebSocketStreamCreateDigestAuthTest, DigestPasswordInUrl) {
AddRawExpectations(helper_.BuildSocketData1(kUnauthorizedResponse));
CreateAndConnectRawExpectations(
- "ws://FooBar:pass@localhost/", NoSubProtocols(), LocalhostOrigin(), "",
+ "ws://FooBar:pass@localhost/", NoSubProtocols(), LocalhostOrigin(),
+ LocalhostUrl(), "",
helper_.BuildSocketData2(kAuthorizedRequest,
WebSocketStandardResponse(std::string())));
WaitUntilConnectDone();
@@ -1120,9 +1143,9 @@ TEST_F(WebSocketStreamCreateUMATest, Incomplete) {
{
StreamCreation creation;
- creation.CreateAndConnectStandard("ws://localhost/", "localhost", "/",
- creation.NoSubProtocols(),
- LocalhostOrigin(), "", "", "");
+ creation.CreateAndConnectStandard(
+ "ws://localhost/", "localhost", "/", creation.NoSubProtocols(),
+ LocalhostOrigin(), LocalhostUrl(), "", "", "");
}
std::unique_ptr<base::HistogramSamples> samples(GetSamples(name));
@@ -1141,9 +1164,9 @@ TEST_F(WebSocketStreamCreateUMATest, Connected) {
{
StreamCreation creation;
- creation.CreateAndConnectStandard("ws://localhost/", "localhost", "/",
- creation.NoSubProtocols(),
- LocalhostOrigin(), "", "", "");
+ creation.CreateAndConnectStandard(
+ "ws://localhost/", "localhost", "/", creation.NoSubProtocols(),
+ LocalhostOrigin(), LocalhostUrl(), "", "", "");
creation.WaitUntilConnectDone();
}
@@ -1171,7 +1194,7 @@ TEST_F(WebSocketStreamCreateUMATest, Failed) {
"\r\n";
creation.CreateAndConnectCustomResponse(
"ws://localhost/", "localhost", "/", creation.NoSubProtocols(),
- LocalhostOrigin(), "", "", kInvalidStatusCodeResponse);
+ LocalhostOrigin(), LocalhostUrl(), "", "", kInvalidStatusCodeResponse);
creation.WaitUntilConnectDone();
}
@@ -1204,7 +1227,7 @@ TEST_F(WebSocketStreamCreateTest, HandleErrConnectionClosed) {
BuildSocketData(reads, writes));
socket_data->set_connect_data(MockConnect(SYNCHRONOUS, OK));
CreateAndConnectRawExpectations("ws://localhost/", NoSubProtocols(),
- LocalhostOrigin(), "",
+ LocalhostOrigin(), LocalhostUrl(), "",
std::move(socket_data));
WaitUntilConnectDone();
EXPECT_TRUE(has_failed());
@@ -1231,7 +1254,7 @@ TEST_F(WebSocketStreamCreateTest, HandleErrTunnelConnectionFailed) {
BuildSocketData(reads, writes));
url_request_context_host_.SetProxyConfig("https=proxy:8000");
CreateAndConnectRawExpectations("ws://localhost/", NoSubProtocols(),
- LocalhostOrigin(), "",
+ LocalhostOrigin(), LocalhostUrl(), "",
std::move(socket_data));
WaitUntilConnectDone();
EXPECT_TRUE(has_failed());

Powered by Google App Engine
This is Rietveld 408576698