| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "net/websockets/websocket_job.h" | 5 #include "net/websockets/websocket_job.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 } | 267 } |
| 268 | 268 |
| 269 virtual ~MockURLRequestContext() {} | 269 virtual ~MockURLRequestContext() {} |
| 270 | 270 |
| 271 private: | 271 private: |
| 272 TransportSecurityState transport_security_state_; | 272 TransportSecurityState transport_security_state_; |
| 273 }; | 273 }; |
| 274 | 274 |
| 275 class MockHttpTransactionFactory : public HttpTransactionFactory { | 275 class MockHttpTransactionFactory : public HttpTransactionFactory { |
| 276 public: | 276 public: |
| 277 MockHttpTransactionFactory(NextProto next_proto, OrderedSocketData* data) { | 277 MockHttpTransactionFactory(NextProto next_proto, |
| 278 OrderedSocketData* data, |
| 279 bool enable_websocket_over_spdy) { |
| 278 data_ = data; | 280 data_ = data; |
| 279 MockConnect connect_data(SYNCHRONOUS, OK); | 281 MockConnect connect_data(SYNCHRONOUS, OK); |
| 280 data_->set_connect_data(connect_data); | 282 data_->set_connect_data(connect_data); |
| 281 session_deps_.reset(new SpdySessionDependencies(next_proto)); | 283 session_deps_.reset(new SpdySessionDependencies(next_proto)); |
| 284 session_deps_->enable_websocket_over_spdy = enable_websocket_over_spdy; |
| 282 session_deps_->socket_factory->AddSocketDataProvider(data_); | 285 session_deps_->socket_factory->AddSocketDataProvider(data_); |
| 283 http_session_ = | 286 http_session_ = |
| 284 SpdySessionDependencies::SpdyCreateSession(session_deps_.get()); | 287 SpdySessionDependencies::SpdyCreateSession(session_deps_.get()); |
| 285 host_port_pair_.set_host("example.com"); | 288 host_port_pair_.set_host("example.com"); |
| 286 host_port_pair_.set_port(80); | 289 host_port_pair_.set_port(80); |
| 287 spdy_session_key_ = SpdySessionKey(host_port_pair_, | 290 spdy_session_key_ = SpdySessionKey(host_port_pair_, |
| 288 ProxyServer::Direct(), | 291 ProxyServer::Direct(), |
| 289 PRIVACY_MODE_DISABLED); | 292 PRIVACY_MODE_DISABLED); |
| 290 session_ = CreateInsecureSpdySession( | 293 session_ = CreateInsecureSpdySession( |
| 291 http_session_, spdy_session_key_, BoundNetLog()); | 294 http_session_, spdy_session_key_, BoundNetLog()); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 private: | 385 private: |
| 383 scoped_refptr<WebSocketJob> job_; | 386 scoped_refptr<WebSocketJob> job_; |
| 384 bool delete_next_; | 387 bool delete_next_; |
| 385 }; | 388 }; |
| 386 | 389 |
| 387 } // namespace | 390 } // namespace |
| 388 | 391 |
| 389 class WebSocketJobTest : public PlatformTest, | 392 class WebSocketJobTest : public PlatformTest, |
| 390 public ::testing::WithParamInterface<NextProto> { | 393 public ::testing::WithParamInterface<NextProto> { |
| 391 public: | 394 public: |
| 392 WebSocketJobTest() : spdy_util_(GetParam()) {} | 395 WebSocketJobTest() |
| 396 : spdy_util_(GetParam()), |
| 397 enable_websocket_over_spdy_(false) {} |
| 393 | 398 |
| 394 virtual void SetUp() OVERRIDE { | 399 virtual void SetUp() OVERRIDE { |
| 395 stream_type_ = STREAM_INVALID; | 400 stream_type_ = STREAM_INVALID; |
| 396 cookie_store_ = new MockCookieStore; | 401 cookie_store_ = new MockCookieStore; |
| 397 context_.reset(new MockURLRequestContext(cookie_store_.get())); | 402 context_.reset(new MockURLRequestContext(cookie_store_.get())); |
| 398 } | 403 } |
| 399 virtual void TearDown() OVERRIDE { | 404 virtual void TearDown() OVERRIDE { |
| 400 cookie_store_ = NULL; | 405 cookie_store_ = NULL; |
| 401 context_.reset(); | 406 context_.reset(); |
| 402 websocket_ = NULL; | 407 websocket_ = NULL; |
| 403 socket_ = NULL; | 408 socket_ = NULL; |
| 404 } | 409 } |
| 405 void DoSendRequest() { | 410 void DoSendRequest() { |
| 406 EXPECT_TRUE(websocket_->SendData(kHandshakeRequestWithoutCookie, | 411 EXPECT_TRUE(websocket_->SendData(kHandshakeRequestWithoutCookie, |
| 407 kHandshakeRequestWithoutCookieLength)); | 412 kHandshakeRequestWithoutCookieLength)); |
| 408 } | 413 } |
| 409 void DoSendData() { | 414 void DoSendData() { |
| 410 if (received_data().size() == kHandshakeResponseWithoutCookieLength) | 415 if (received_data().size() == kHandshakeResponseWithoutCookieLength) |
| 411 websocket_->SendData(kDataHello, kDataHelloLength); | 416 websocket_->SendData(kDataHello, kDataHelloLength); |
| 412 } | 417 } |
| 413 void DoSync() { | 418 void DoSync() { |
| 414 sync_test_callback_.callback().Run(OK); | 419 sync_test_callback_.callback().Run(OK); |
| 415 } | 420 } |
| 416 int WaitForResult() { | 421 int WaitForResult() { |
| 417 return sync_test_callback_.WaitForResult(); | 422 return sync_test_callback_.WaitForResult(); |
| 418 } | 423 } |
| 424 |
| 419 protected: | 425 protected: |
| 420 enum StreamType { | 426 enum StreamType { |
| 421 STREAM_INVALID, | 427 STREAM_INVALID, |
| 422 STREAM_MOCK_SOCKET, | 428 STREAM_MOCK_SOCKET, |
| 423 STREAM_SOCKET, | 429 STREAM_SOCKET, |
| 424 STREAM_SPDY_WEBSOCKET, | 430 STREAM_SPDY_WEBSOCKET, |
| 425 }; | 431 }; |
| 426 enum ThrottlingOption { | 432 enum ThrottlingOption { |
| 427 THROTTLING_OFF, | 433 THROTTLING_OFF, |
| 428 THROTTLING_ON, | 434 THROTTLING_ON, |
| 429 }; | 435 }; |
| 430 enum SpdyOption { | 436 enum SpdyOption { |
| 431 SPDY_OFF, | 437 SPDY_OFF, |
| 432 SPDY_ON, | 438 SPDY_ON, |
| 433 }; | 439 }; |
| 434 void InitWebSocketJob(const GURL& url, | 440 void InitWebSocketJob(const GURL& url, |
| 435 MockSocketStreamDelegate* delegate, | 441 MockSocketStreamDelegate* delegate, |
| 436 StreamType stream_type) { | 442 StreamType stream_type) { |
| 437 DCHECK_NE(STREAM_INVALID, stream_type); | 443 DCHECK_NE(STREAM_INVALID, stream_type); |
| 438 stream_type_ = stream_type; | 444 stream_type_ = stream_type; |
| 439 websocket_ = new WebSocketJob(delegate); | 445 websocket_ = new WebSocketJob(delegate); |
| 440 | 446 |
| 441 if (stream_type == STREAM_MOCK_SOCKET) | 447 if (stream_type == STREAM_MOCK_SOCKET) |
| 442 socket_ = new MockSocketStream(url, websocket_.get(), context_.get(), | 448 socket_ = new MockSocketStream(url, websocket_.get(), context_.get(), |
| 443 NULL); | 449 NULL); |
| 444 | 450 |
| 445 if (stream_type == STREAM_SOCKET || stream_type == STREAM_SPDY_WEBSOCKET) { | 451 if (stream_type == STREAM_SOCKET || stream_type == STREAM_SPDY_WEBSOCKET) { |
| 446 if (stream_type == STREAM_SPDY_WEBSOCKET) { | 452 if (stream_type == STREAM_SPDY_WEBSOCKET) { |
| 447 http_factory_.reset( | 453 http_factory_.reset(new MockHttpTransactionFactory( |
| 448 new MockHttpTransactionFactory(GetParam(), data_.get())); | 454 GetParam(), data_.get(), enable_websocket_over_spdy_)); |
| 449 context_->set_http_transaction_factory(http_factory_.get()); | 455 context_->set_http_transaction_factory(http_factory_.get()); |
| 450 } | 456 } |
| 451 | 457 |
| 452 ssl_config_service_ = new MockSSLConfigService(); | 458 ssl_config_service_ = new MockSSLConfigService(); |
| 453 context_->set_ssl_config_service(ssl_config_service_.get()); | 459 context_->set_ssl_config_service(ssl_config_service_.get()); |
| 454 proxy_service_.reset(ProxyService::CreateDirect()); | 460 proxy_service_.reset(ProxyService::CreateDirect()); |
| 455 context_->set_proxy_service(proxy_service_.get()); | 461 context_->set_proxy_service(proxy_service_.get()); |
| 456 host_resolver_.reset(new MockHostResolver); | 462 host_resolver_.reset(new MockHostResolver); |
| 457 context_->set_host_resolver(host_resolver_.get()); | 463 context_->set_host_resolver(host_resolver_.get()); |
| 458 | 464 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 scoped_refptr<WebSocketJob> websocket_; | 529 scoped_refptr<WebSocketJob> websocket_; |
| 524 scoped_refptr<SocketStream> socket_; | 530 scoped_refptr<SocketStream> socket_; |
| 525 scoped_ptr<MockClientSocketFactory> socket_factory_; | 531 scoped_ptr<MockClientSocketFactory> socket_factory_; |
| 526 scoped_ptr<OrderedSocketData> data_; | 532 scoped_ptr<OrderedSocketData> data_; |
| 527 TestCompletionCallback sync_test_callback_; | 533 TestCompletionCallback sync_test_callback_; |
| 528 scoped_refptr<MockSSLConfigService> ssl_config_service_; | 534 scoped_refptr<MockSSLConfigService> ssl_config_service_; |
| 529 scoped_ptr<ProxyService> proxy_service_; | 535 scoped_ptr<ProxyService> proxy_service_; |
| 530 scoped_ptr<MockHostResolver> host_resolver_; | 536 scoped_ptr<MockHostResolver> host_resolver_; |
| 531 scoped_ptr<MockHttpTransactionFactory> http_factory_; | 537 scoped_ptr<MockHttpTransactionFactory> http_factory_; |
| 532 | 538 |
| 539 // Must be set before call to enable_websocket_over_spdy, defaults to false. |
| 540 bool enable_websocket_over_spdy_; |
| 541 |
| 533 static const char kHandshakeRequestWithoutCookie[]; | 542 static const char kHandshakeRequestWithoutCookie[]; |
| 534 static const char kHandshakeRequestWithCookie[]; | 543 static const char kHandshakeRequestWithCookie[]; |
| 535 static const char kHandshakeRequestWithFilteredCookie[]; | 544 static const char kHandshakeRequestWithFilteredCookie[]; |
| 536 static const char kHandshakeResponseWithoutCookie[]; | 545 static const char kHandshakeResponseWithoutCookie[]; |
| 537 static const char kHandshakeResponseWithCookie[]; | 546 static const char kHandshakeResponseWithCookie[]; |
| 538 static const char kDataHello[]; | 547 static const char kDataHello[]; |
| 539 static const char kDataWorld[]; | 548 static const char kDataWorld[]; |
| 540 static const char* const kHandshakeRequestForSpdy[]; | 549 static const char* const kHandshakeRequestForSpdy[]; |
| 541 static const char* const kHandshakeResponseForSpdy[]; | 550 static const char* const kHandshakeResponseForSpdy[]; |
| 542 static const size_t kHandshakeRequestWithoutCookieLength; | 551 static const size_t kHandshakeRequestWithoutCookieLength; |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 CloseWebSocketJob(); | 713 CloseWebSocketJob(); |
| 705 } | 714 } |
| 706 | 715 |
| 707 INSTANTIATE_TEST_CASE_P( | 716 INSTANTIATE_TEST_CASE_P( |
| 708 NextProto, | 717 NextProto, |
| 709 WebSocketJobTest, | 718 WebSocketJobTest, |
| 710 testing::Values(kProtoDeprecatedSPDY2, | 719 testing::Values(kProtoDeprecatedSPDY2, |
| 711 kProtoSPDY3, kProtoSPDY31, kProtoSPDY4)); | 720 kProtoSPDY3, kProtoSPDY31, kProtoSPDY4)); |
| 712 | 721 |
| 713 TEST_P(WebSocketJobTest, DelayedCookies) { | 722 TEST_P(WebSocketJobTest, DelayedCookies) { |
| 714 WebSocketJob::set_websocket_over_spdy_enabled(true); | 723 enable_websocket_over_spdy_ = true; |
| 715 GURL url("ws://example.com/demo"); | 724 GURL url("ws://example.com/demo"); |
| 716 GURL cookieUrl("http://example.com/demo"); | 725 GURL cookieUrl("http://example.com/demo"); |
| 717 CookieOptions cookie_options; | 726 CookieOptions cookie_options; |
| 718 scoped_refptr<DelayedCookieMonster> cookie_store = new DelayedCookieMonster(); | 727 scoped_refptr<DelayedCookieMonster> cookie_store = new DelayedCookieMonster(); |
| 719 context_->set_cookie_store(cookie_store.get()); | 728 context_->set_cookie_store(cookie_store.get()); |
| 720 cookie_store->SetCookieWithOptionsAsync(cookieUrl, | 729 cookie_store->SetCookieWithOptionsAsync(cookieUrl, |
| 721 "CR-test=1", | 730 "CR-test=1", |
| 722 cookie_options, | 731 cookie_options, |
| 723 CookieMonster::SetCookiesCallback()); | 732 CookieMonster::SetCookiesCallback()); |
| 724 cookie_options.set_include_httponly(); | 733 cookie_options.set_include_httponly(); |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1107 iter != jobs.rend(); | 1116 iter != jobs.rend(); |
| 1108 ++iter) { | 1117 ++iter) { |
| 1109 WebSocketJob* job = (*iter).get(); | 1118 WebSocketJob* job = (*iter).get(); |
| 1110 job->state_ = WebSocketJob::CLOSED; | 1119 job->state_ = WebSocketJob::CLOSED; |
| 1111 WebSocketThrottle::GetInstance()->RemoveFromQueue(job); | 1120 WebSocketThrottle::GetInstance()->RemoveFromQueue(job); |
| 1112 } | 1121 } |
| 1113 } | 1122 } |
| 1114 | 1123 |
| 1115 // Execute tests in both spdy-disabled mode and spdy-enabled mode. | 1124 // Execute tests in both spdy-disabled mode and spdy-enabled mode. |
| 1116 TEST_P(WebSocketJobTest, SimpleHandshake) { | 1125 TEST_P(WebSocketJobTest, SimpleHandshake) { |
| 1117 WebSocketJob::set_websocket_over_spdy_enabled(false); | |
| 1118 TestSimpleHandshake(); | 1126 TestSimpleHandshake(); |
| 1119 } | 1127 } |
| 1120 | 1128 |
| 1121 TEST_P(WebSocketJobTest, SlowHandshake) { | 1129 TEST_P(WebSocketJobTest, SlowHandshake) { |
| 1122 WebSocketJob::set_websocket_over_spdy_enabled(false); | |
| 1123 TestSlowHandshake(); | 1130 TestSlowHandshake(); |
| 1124 } | 1131 } |
| 1125 | 1132 |
| 1126 TEST_P(WebSocketJobTest, HandshakeWithCookie) { | 1133 TEST_P(WebSocketJobTest, HandshakeWithCookie) { |
| 1127 WebSocketJob::set_websocket_over_spdy_enabled(false); | |
| 1128 TestHandshakeWithCookie(); | 1134 TestHandshakeWithCookie(); |
| 1129 } | 1135 } |
| 1130 | 1136 |
| 1131 TEST_P(WebSocketJobTest, HandshakeWithCookieButNotAllowed) { | 1137 TEST_P(WebSocketJobTest, HandshakeWithCookieButNotAllowed) { |
| 1132 WebSocketJob::set_websocket_over_spdy_enabled(false); | |
| 1133 TestHandshakeWithCookieButNotAllowed(); | 1138 TestHandshakeWithCookieButNotAllowed(); |
| 1134 } | 1139 } |
| 1135 | 1140 |
| 1136 TEST_P(WebSocketJobTest, HSTSUpgrade) { | 1141 TEST_P(WebSocketJobTest, HSTSUpgrade) { |
| 1137 WebSocketJob::set_websocket_over_spdy_enabled(false); | |
| 1138 TestHSTSUpgrade(); | 1142 TestHSTSUpgrade(); |
| 1139 } | 1143 } |
| 1140 | 1144 |
| 1141 TEST_P(WebSocketJobTest, InvalidSendData) { | 1145 TEST_P(WebSocketJobTest, InvalidSendData) { |
| 1142 WebSocketJob::set_websocket_over_spdy_enabled(false); | |
| 1143 TestInvalidSendData(); | 1146 TestInvalidSendData(); |
| 1144 } | 1147 } |
| 1145 | 1148 |
| 1146 TEST_P(WebSocketJobTest, SimpleHandshakeSpdyEnabled) { | 1149 TEST_P(WebSocketJobTest, SimpleHandshakeSpdyEnabled) { |
| 1147 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1150 enable_websocket_over_spdy_ = true; |
| 1148 TestSimpleHandshake(); | 1151 TestSimpleHandshake(); |
| 1149 } | 1152 } |
| 1150 | 1153 |
| 1151 TEST_P(WebSocketJobTest, SlowHandshakeSpdyEnabled) { | 1154 TEST_P(WebSocketJobTest, SlowHandshakeSpdyEnabled) { |
| 1152 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1155 enable_websocket_over_spdy_ = true; |
| 1153 TestSlowHandshake(); | 1156 TestSlowHandshake(); |
| 1154 } | 1157 } |
| 1155 | 1158 |
| 1156 TEST_P(WebSocketJobTest, HandshakeWithCookieSpdyEnabled) { | 1159 TEST_P(WebSocketJobTest, HandshakeWithCookieSpdyEnabled) { |
| 1157 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1160 enable_websocket_over_spdy_ = true; |
| 1158 TestHandshakeWithCookie(); | 1161 TestHandshakeWithCookie(); |
| 1159 } | 1162 } |
| 1160 | 1163 |
| 1161 TEST_P(WebSocketJobTest, HandshakeWithCookieButNotAllowedSpdyEnabled) { | 1164 TEST_P(WebSocketJobTest, HandshakeWithCookieButNotAllowedSpdyEnabled) { |
| 1162 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1165 enable_websocket_over_spdy_ = true; |
| 1163 TestHandshakeWithCookieButNotAllowed(); | 1166 TestHandshakeWithCookieButNotAllowed(); |
| 1164 } | 1167 } |
| 1165 | 1168 |
| 1166 TEST_P(WebSocketJobTest, HSTSUpgradeSpdyEnabled) { | 1169 TEST_P(WebSocketJobTest, HSTSUpgradeSpdyEnabled) { |
| 1167 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1170 enable_websocket_over_spdy_ = true; |
| 1168 TestHSTSUpgrade(); | 1171 TestHSTSUpgrade(); |
| 1169 } | 1172 } |
| 1170 | 1173 |
| 1171 TEST_P(WebSocketJobTest, InvalidSendDataSpdyEnabled) { | 1174 TEST_P(WebSocketJobTest, InvalidSendDataSpdyEnabled) { |
| 1172 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1175 enable_websocket_over_spdy_ = true; |
| 1173 TestInvalidSendData(); | 1176 TestInvalidSendData(); |
| 1174 } | 1177 } |
| 1175 | 1178 |
| 1176 TEST_P(WebSocketJobTest, ConnectByWebSocket) { | 1179 TEST_P(WebSocketJobTest, ConnectByWebSocket) { |
| 1177 WebSocketJob::set_websocket_over_spdy_enabled(false); | 1180 enable_websocket_over_spdy_ = true; |
| 1178 TestConnectByWebSocket(THROTTLING_OFF); | 1181 TestConnectByWebSocket(THROTTLING_OFF); |
| 1179 } | 1182 } |
| 1180 | 1183 |
| 1181 TEST_P(WebSocketJobTest, ConnectByWebSocketSpdyEnabled) { | 1184 TEST_P(WebSocketJobTest, ConnectByWebSocketSpdyEnabled) { |
| 1182 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1185 enable_websocket_over_spdy_ = true; |
| 1183 TestConnectByWebSocket(THROTTLING_OFF); | 1186 TestConnectByWebSocket(THROTTLING_OFF); |
| 1184 } | 1187 } |
| 1185 | 1188 |
| 1186 TEST_P(WebSocketJobTest, ConnectBySpdy) { | 1189 TEST_P(WebSocketJobTest, ConnectBySpdy) { |
| 1187 WebSocketJob::set_websocket_over_spdy_enabled(false); | |
| 1188 TestConnectBySpdy(SPDY_OFF, THROTTLING_OFF); | 1190 TestConnectBySpdy(SPDY_OFF, THROTTLING_OFF); |
| 1189 } | 1191 } |
| 1190 | 1192 |
| 1191 TEST_P(WebSocketJobTest, ConnectBySpdySpdyEnabled) { | 1193 TEST_P(WebSocketJobTest, ConnectBySpdySpdyEnabled) { |
| 1192 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1194 enable_websocket_over_spdy_ = true; |
| 1193 TestConnectBySpdy(SPDY_ON, THROTTLING_OFF); | 1195 TestConnectBySpdy(SPDY_ON, THROTTLING_OFF); |
| 1194 } | 1196 } |
| 1195 | 1197 |
| 1196 TEST_P(WebSocketJobTest, ThrottlingWebSocket) { | 1198 TEST_P(WebSocketJobTest, ThrottlingWebSocket) { |
| 1197 WebSocketJob::set_websocket_over_spdy_enabled(false); | |
| 1198 TestConnectByWebSocket(THROTTLING_ON); | 1199 TestConnectByWebSocket(THROTTLING_ON); |
| 1199 } | 1200 } |
| 1200 | 1201 |
| 1201 TEST_P(WebSocketJobTest, ThrottlingMaxNumberOfThrottledJobLimit) { | 1202 TEST_P(WebSocketJobTest, ThrottlingMaxNumberOfThrottledJobLimit) { |
| 1202 TestThrottlingLimit(); | 1203 TestThrottlingLimit(); |
| 1203 } | 1204 } |
| 1204 | 1205 |
| 1205 TEST_P(WebSocketJobTest, ThrottlingWebSocketSpdyEnabled) { | 1206 TEST_P(WebSocketJobTest, ThrottlingWebSocketSpdyEnabled) { |
| 1206 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1207 enable_websocket_over_spdy_ = true; |
| 1207 TestConnectByWebSocket(THROTTLING_ON); | 1208 TestConnectByWebSocket(THROTTLING_ON); |
| 1208 } | 1209 } |
| 1209 | 1210 |
| 1210 TEST_P(WebSocketJobTest, ThrottlingSpdy) { | 1211 TEST_P(WebSocketJobTest, ThrottlingSpdy) { |
| 1211 WebSocketJob::set_websocket_over_spdy_enabled(false); | |
| 1212 TestConnectBySpdy(SPDY_OFF, THROTTLING_ON); | 1212 TestConnectBySpdy(SPDY_OFF, THROTTLING_ON); |
| 1213 } | 1213 } |
| 1214 | 1214 |
| 1215 TEST_P(WebSocketJobTest, ThrottlingSpdySpdyEnabled) { | 1215 TEST_P(WebSocketJobTest, ThrottlingSpdySpdyEnabled) { |
| 1216 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1216 enable_websocket_over_spdy_ = true; |
| 1217 TestConnectBySpdy(SPDY_ON, THROTTLING_ON); | 1217 TestConnectBySpdy(SPDY_ON, THROTTLING_ON); |
| 1218 } | 1218 } |
| 1219 | 1219 |
| 1220 TEST_F(WebSocketJobDeleteTest, OnClose) { | 1220 TEST_F(WebSocketJobDeleteTest, OnClose) { |
| 1221 SetDeleteNext(); | 1221 SetDeleteNext(); |
| 1222 job()->OnClose(socket_.get()); | 1222 job()->OnClose(socket_.get()); |
| 1223 // OnClose() sets WebSocketJob::_socket to NULL before we can detach it, so | 1223 // OnClose() sets WebSocketJob::_socket to NULL before we can detach it, so |
| 1224 // socket_->delegate is still set at this point. Clear it to avoid hitting | 1224 // socket_->delegate is still set at this point. Clear it to avoid hitting |
| 1225 // DCHECK(!delegate_) in the SocketStream destructor. SocketStream::Finish() | 1225 // DCHECK(!delegate_) in the SocketStream destructor. SocketStream::Finish() |
| 1226 // is the only caller of this method in real code, and it also sets delegate_ | 1226 // is the only caller of this method in real code, and it also sets delegate_ |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1283 job()->Connect(); | 1283 job()->Connect(); |
| 1284 SetDeleteNext(); | 1284 SetDeleteNext(); |
| 1285 job()->OnReceivedData( | 1285 job()->OnReceivedData( |
| 1286 socket_.get(), kMinimalResponse, arraysize(kMinimalResponse) - 1); | 1286 socket_.get(), kMinimalResponse, arraysize(kMinimalResponse) - 1); |
| 1287 EXPECT_FALSE(job()); | 1287 EXPECT_FALSE(job()); |
| 1288 } | 1288 } |
| 1289 | 1289 |
| 1290 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation. | 1290 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation. |
| 1291 // TODO(toyoshim,yutak): Add tests to verify closing handshake. | 1291 // TODO(toyoshim,yutak): Add tests to verify closing handshake. |
| 1292 } // namespace net | 1292 } // namespace net |
| OLD | NEW |