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 "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 10 matching lines...) Expand all Loading... |
21 #include "net/base/net_errors.h" | 21 #include "net/base/net_errors.h" |
22 #include "net/base/ssl_config_service.h" | 22 #include "net/base/ssl_config_service.h" |
23 #include "net/base/sys_addrinfo.h" | 23 #include "net/base/sys_addrinfo.h" |
24 #include "net/base/test_completion_callback.h" | 24 #include "net/base/test_completion_callback.h" |
25 #include "net/base/transport_security_state.h" | 25 #include "net/base/transport_security_state.h" |
26 #include "net/http/http_transaction_factory.h" | 26 #include "net/http/http_transaction_factory.h" |
27 #include "net/proxy/proxy_service.h" | 27 #include "net/proxy/proxy_service.h" |
28 #include "net/socket/socket_test_util.h" | 28 #include "net/socket/socket_test_util.h" |
29 #include "net/socket_stream/socket_stream.h" | 29 #include "net/socket_stream/socket_stream.h" |
30 #include "net/spdy/spdy_session.h" | 30 #include "net/spdy/spdy_session.h" |
31 #include "net/spdy/spdy_test_util.h" | 31 #include "net/spdy/spdy_test_util_spdy3.h" |
32 #include "net/spdy/spdy_websocket_test_util.h" | 32 #include "net/spdy/spdy_websocket_test_util_spdy3.h" |
33 #include "net/url_request/url_request_context.h" | 33 #include "net/url_request/url_request_context.h" |
34 #include "net/websockets/websocket_throttle.h" | 34 #include "net/websockets/websocket_throttle.h" |
35 #include "testing/gtest/include/gtest/gtest.h" | 35 #include "testing/gtest/include/gtest/gtest.h" |
36 #include "testing/gmock/include/gmock/gmock.h" | 36 #include "testing/gmock/include/gmock/gmock.h" |
37 #include "testing/platform_test.h" | 37 #include "testing/platform_test.h" |
38 | 38 |
| 39 using namespace net::test_spdy3; |
| 40 |
39 namespace { | 41 namespace { |
40 | 42 |
41 class MockSocketStream : public net::SocketStream { | 43 class MockSocketStream : public net::SocketStream { |
42 public: | 44 public: |
43 MockSocketStream(const GURL& url, net::SocketStream::Delegate* delegate) | 45 MockSocketStream(const GURL& url, net::SocketStream::Delegate* delegate) |
44 : SocketStream(url, delegate) {} | 46 : SocketStream(url, delegate) {} |
45 virtual ~MockSocketStream() {} | 47 virtual ~MockSocketStream() {} |
46 | 48 |
47 virtual void Connect() OVERRIDE {} | 49 virtual void Connect() OVERRIDE {} |
48 virtual bool SendData(const char* data, int len) OVERRIDE { | 50 virtual bool SendData(const char* data, int len) OVERRIDE { |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 | 255 |
254 net::TransportSecurityState transport_security_state_; | 256 net::TransportSecurityState transport_security_state_; |
255 }; | 257 }; |
256 | 258 |
257 class MockHttpTransactionFactory : public net::HttpTransactionFactory { | 259 class MockHttpTransactionFactory : public net::HttpTransactionFactory { |
258 public: | 260 public: |
259 MockHttpTransactionFactory(net::OrderedSocketData* data) { | 261 MockHttpTransactionFactory(net::OrderedSocketData* data) { |
260 data_ = data; | 262 data_ = data; |
261 net::MockConnect connect_data(net::SYNCHRONOUS, net::OK); | 263 net::MockConnect connect_data(net::SYNCHRONOUS, net::OK); |
262 data_->set_connect_data(connect_data); | 264 data_->set_connect_data(connect_data); |
263 session_deps_.reset(new net::SpdySessionDependencies); | 265 session_deps_.reset(new SpdySessionDependencies); |
264 session_deps_->socket_factory->AddSocketDataProvider(data_); | 266 session_deps_->socket_factory->AddSocketDataProvider(data_); |
265 http_session_ = | 267 http_session_ = |
266 net::SpdySessionDependencies::SpdyCreateSession(session_deps_.get()); | 268 SpdySessionDependencies::SpdyCreateSession(session_deps_.get()); |
267 host_port_pair_.set_host("example.com"); | 269 host_port_pair_.set_host("example.com"); |
268 host_port_pair_.set_port(80); | 270 host_port_pair_.set_port(80); |
269 host_port_proxy_pair_.first = host_port_pair_; | 271 host_port_proxy_pair_.first = host_port_pair_; |
270 host_port_proxy_pair_.second = net::ProxyServer::Direct(); | 272 host_port_proxy_pair_.second = net::ProxyServer::Direct(); |
271 net::SpdySessionPool* spdy_session_pool = | 273 net::SpdySessionPool* spdy_session_pool = |
272 http_session_->spdy_session_pool(); | 274 http_session_->spdy_session_pool(); |
273 DCHECK(spdy_session_pool); | 275 DCHECK(spdy_session_pool); |
274 EXPECT_FALSE(spdy_session_pool->HasSession(host_port_proxy_pair_)); | 276 EXPECT_FALSE(spdy_session_pool->HasSession(host_port_proxy_pair_)); |
275 session_ = | 277 session_ = |
276 spdy_session_pool->Get(host_port_proxy_pair_, net::BoundNetLog()); | 278 spdy_session_pool->Get(host_port_proxy_pair_, net::BoundNetLog()); |
(...skipping 18 matching lines...) Expand all Loading... |
295 } | 297 } |
296 virtual net::HttpCache* GetCache() { | 298 virtual net::HttpCache* GetCache() { |
297 NOTREACHED(); | 299 NOTREACHED(); |
298 return NULL; | 300 return NULL; |
299 } | 301 } |
300 virtual net::HttpNetworkSession* GetSession() { | 302 virtual net::HttpNetworkSession* GetSession() { |
301 return http_session_.get(); | 303 return http_session_.get(); |
302 } | 304 } |
303 private: | 305 private: |
304 net::OrderedSocketData* data_; | 306 net::OrderedSocketData* data_; |
305 scoped_ptr<net::SpdySessionDependencies> session_deps_; | 307 scoped_ptr<SpdySessionDependencies> session_deps_; |
306 scoped_refptr<net::HttpNetworkSession> http_session_; | 308 scoped_refptr<net::HttpNetworkSession> http_session_; |
307 scoped_refptr<net::TransportSocketParams> transport_params_; | 309 scoped_refptr<net::TransportSocketParams> transport_params_; |
308 scoped_refptr<net::SpdySession> session_; | 310 scoped_refptr<net::SpdySession> session_; |
309 net::HostPortPair host_port_pair_; | 311 net::HostPortPair host_port_pair_; |
310 net::HostPortProxyPair host_port_proxy_pair_; | 312 net::HostPortProxyPair host_port_proxy_pair_; |
311 }; | 313 }; |
312 } | 314 } // namespace |
313 | 315 |
314 namespace net { | 316 namespace net { |
315 | 317 |
316 class WebSocketJobTest : public PlatformTest { | 318 class WebSocketJobSpdy3Test : public PlatformTest { |
317 public: | 319 public: |
318 virtual void SetUp() { | 320 virtual void SetUp() { |
319 spdy::SpdyFramer::set_enable_compression_default(false); | 321 spdy::SpdyFramer::set_enable_compression_default(false); |
320 stream_type_ = STREAM_INVALID; | 322 stream_type_ = STREAM_INVALID; |
321 cookie_store_ = new MockCookieStore; | 323 cookie_store_ = new MockCookieStore; |
322 context_ = new MockURLRequestContext(cookie_store_.get()); | 324 context_ = new MockURLRequestContext(cookie_store_.get()); |
323 } | 325 } |
324 virtual void TearDown() { | 326 virtual void TearDown() { |
325 cookie_store_ = NULL; | 327 cookie_store_ = NULL; |
326 context_ = NULL; | 328 context_ = NULL; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 static const char* const kHandshakeResponseForSpdy[]; | 468 static const char* const kHandshakeResponseForSpdy[]; |
467 static const size_t kHandshakeRequestWithoutCookieLength; | 469 static const size_t kHandshakeRequestWithoutCookieLength; |
468 static const size_t kHandshakeRequestWithCookieLength; | 470 static const size_t kHandshakeRequestWithCookieLength; |
469 static const size_t kHandshakeRequestWithFilteredCookieLength; | 471 static const size_t kHandshakeRequestWithFilteredCookieLength; |
470 static const size_t kHandshakeResponseWithoutCookieLength; | 472 static const size_t kHandshakeResponseWithoutCookieLength; |
471 static const size_t kHandshakeResponseWithCookieLength; | 473 static const size_t kHandshakeResponseWithCookieLength; |
472 static const size_t kDataHelloLength; | 474 static const size_t kDataHelloLength; |
473 static const size_t kDataWorldLength; | 475 static const size_t kDataWorldLength; |
474 }; | 476 }; |
475 | 477 |
476 const char WebSocketJobTest::kHandshakeRequestWithoutCookie[] = | 478 const char WebSocketJobSpdy3Test::kHandshakeRequestWithoutCookie[] = |
477 "GET /demo HTTP/1.1\r\n" | 479 "GET /demo HTTP/1.1\r\n" |
478 "Host: example.com\r\n" | 480 "Host: example.com\r\n" |
479 "Connection: Upgrade\r\n" | 481 "Connection: Upgrade\r\n" |
480 "Sec-WebSocket-Key2: 12998 5 Y3 1 .P00\r\n" | 482 "Sec-WebSocket-Key2: 12998 5 Y3 1 .P00\r\n" |
481 "Sec-WebSocket-Protocol: sample\r\n" | 483 "Sec-WebSocket-Protocol: sample\r\n" |
482 "Upgrade: WebSocket\r\n" | 484 "Upgrade: WebSocket\r\n" |
483 "Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5\r\n" | 485 "Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5\r\n" |
484 "Origin: http://example.com\r\n" | 486 "Origin: http://example.com\r\n" |
485 "\r\n" | 487 "\r\n" |
486 "^n:ds[4U"; | 488 "^n:ds[4U"; |
487 | 489 |
488 const char WebSocketJobTest::kHandshakeRequestWithCookie[] = | 490 const char WebSocketJobSpdy3Test::kHandshakeRequestWithCookie[] = |
489 "GET /demo HTTP/1.1\r\n" | 491 "GET /demo HTTP/1.1\r\n" |
490 "Host: example.com\r\n" | 492 "Host: example.com\r\n" |
491 "Connection: Upgrade\r\n" | 493 "Connection: Upgrade\r\n" |
492 "Sec-WebSocket-Key2: 12998 5 Y3 1 .P00\r\n" | 494 "Sec-WebSocket-Key2: 12998 5 Y3 1 .P00\r\n" |
493 "Sec-WebSocket-Protocol: sample\r\n" | 495 "Sec-WebSocket-Protocol: sample\r\n" |
494 "Upgrade: WebSocket\r\n" | 496 "Upgrade: WebSocket\r\n" |
495 "Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5\r\n" | 497 "Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5\r\n" |
496 "Origin: http://example.com\r\n" | 498 "Origin: http://example.com\r\n" |
497 "Cookie: WK-test=1\r\n" | 499 "Cookie: WK-test=1\r\n" |
498 "\r\n" | 500 "\r\n" |
499 "^n:ds[4U"; | 501 "^n:ds[4U"; |
500 | 502 |
501 const char WebSocketJobTest::kHandshakeRequestWithFilteredCookie[] = | 503 const char WebSocketJobSpdy3Test::kHandshakeRequestWithFilteredCookie[] = |
502 "GET /demo HTTP/1.1\r\n" | 504 "GET /demo HTTP/1.1\r\n" |
503 "Host: example.com\r\n" | 505 "Host: example.com\r\n" |
504 "Connection: Upgrade\r\n" | 506 "Connection: Upgrade\r\n" |
505 "Sec-WebSocket-Key2: 12998 5 Y3 1 .P00\r\n" | 507 "Sec-WebSocket-Key2: 12998 5 Y3 1 .P00\r\n" |
506 "Sec-WebSocket-Protocol: sample\r\n" | 508 "Sec-WebSocket-Protocol: sample\r\n" |
507 "Upgrade: WebSocket\r\n" | 509 "Upgrade: WebSocket\r\n" |
508 "Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5\r\n" | 510 "Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5\r\n" |
509 "Origin: http://example.com\r\n" | 511 "Origin: http://example.com\r\n" |
510 "Cookie: CR-test=1; CR-test-httponly=1\r\n" | 512 "Cookie: CR-test=1; CR-test-httponly=1\r\n" |
511 "\r\n" | 513 "\r\n" |
512 "^n:ds[4U"; | 514 "^n:ds[4U"; |
513 | 515 |
514 const char WebSocketJobTest::kHandshakeResponseWithoutCookie[] = | 516 const char WebSocketJobSpdy3Test::kHandshakeResponseWithoutCookie[] = |
515 "HTTP/1.1 101 WebSocket Protocol Handshake\r\n" | 517 "HTTP/1.1 101 WebSocket Protocol Handshake\r\n" |
516 "Upgrade: WebSocket\r\n" | 518 "Upgrade: WebSocket\r\n" |
517 "Connection: Upgrade\r\n" | 519 "Connection: Upgrade\r\n" |
518 "Sec-WebSocket-Origin: http://example.com\r\n" | 520 "Sec-WebSocket-Origin: http://example.com\r\n" |
519 "Sec-WebSocket-Location: ws://example.com/demo\r\n" | 521 "Sec-WebSocket-Location: ws://example.com/demo\r\n" |
520 "Sec-WebSocket-Protocol: sample\r\n" | 522 "Sec-WebSocket-Protocol: sample\r\n" |
521 "\r\n" | 523 "\r\n" |
522 "8jKS'y:G*Co,Wxa-"; | 524 "8jKS'y:G*Co,Wxa-"; |
523 | 525 |
524 const char WebSocketJobTest::kHandshakeResponseWithCookie[] = | 526 const char WebSocketJobSpdy3Test::kHandshakeResponseWithCookie[] = |
525 "HTTP/1.1 101 WebSocket Protocol Handshake\r\n" | 527 "HTTP/1.1 101 WebSocket Protocol Handshake\r\n" |
526 "Upgrade: WebSocket\r\n" | 528 "Upgrade: WebSocket\r\n" |
527 "Connection: Upgrade\r\n" | 529 "Connection: Upgrade\r\n" |
528 "Sec-WebSocket-Origin: http://example.com\r\n" | 530 "Sec-WebSocket-Origin: http://example.com\r\n" |
529 "Sec-WebSocket-Location: ws://example.com/demo\r\n" | 531 "Sec-WebSocket-Location: ws://example.com/demo\r\n" |
530 "Sec-WebSocket-Protocol: sample\r\n" | 532 "Sec-WebSocket-Protocol: sample\r\n" |
531 "Set-Cookie: CR-set-test=1\r\n" | 533 "Set-Cookie: CR-set-test=1\r\n" |
532 "\r\n" | 534 "\r\n" |
533 "8jKS'y:G*Co,Wxa-"; | 535 "8jKS'y:G*Co,Wxa-"; |
534 | 536 |
535 const char WebSocketJobTest::kDataHello[] = "Hello, "; | 537 const char WebSocketJobSpdy3Test::kDataHello[] = "Hello, "; |
536 | 538 |
537 const char WebSocketJobTest::kDataWorld[] = "World!\n"; | 539 const char WebSocketJobSpdy3Test::kDataWorld[] = "World!\n"; |
538 | 540 |
539 // TODO(toyoshim): I should clarify which WebSocket headers for handshake must | 541 // TODO(toyoshim): I should clarify which WebSocket headers for handshake must |
540 // be exported to SPDY SYN_STREAM and SYN_REPLY. | 542 // be exported to SPDY SYN_STREAM and SYN_REPLY. |
541 // Because it depends on HyBi versions, just define it as follow for now. | 543 // Because it depends on HyBi versions, just define it as follow for now. |
542 const char* const WebSocketJobTest::kHandshakeRequestForSpdy[] = { | 544 const char* const WebSocketJobSpdy3Test::kHandshakeRequestForSpdy[] = { |
543 "host", "example.com", | 545 "host", "example.com", |
544 "origin", "http://example.com", | 546 "origin", "http://example.com", |
545 "sec-websocket-protocol", "sample", | 547 "sec-websocket-protocol", "sample", |
546 "url", "ws://example.com/demo" | 548 "url", "ws://example.com/demo" |
547 }; | 549 }; |
548 | 550 |
549 const char* const WebSocketJobTest::kHandshakeResponseForSpdy[] = { | 551 const char* const WebSocketJobSpdy3Test::kHandshakeResponseForSpdy[] = { |
550 "sec-websocket-origin", "http://example.com", | 552 "sec-websocket-origin", "http://example.com", |
551 "sec-websocket-location", "ws://example.com/demo", | 553 "sec-websocket-location", "ws://example.com/demo", |
552 "sec-websocket-protocol", "sample", | 554 "sec-websocket-protocol", "sample", |
553 }; | 555 }; |
554 | 556 |
555 const size_t WebSocketJobTest::kHandshakeRequestWithoutCookieLength = | 557 const size_t WebSocketJobSpdy3Test::kHandshakeRequestWithoutCookieLength = |
556 arraysize(kHandshakeRequestWithoutCookie) - 1; | 558 arraysize(kHandshakeRequestWithoutCookie) - 1; |
557 const size_t WebSocketJobTest::kHandshakeRequestWithCookieLength = | 559 const size_t WebSocketJobSpdy3Test::kHandshakeRequestWithCookieLength = |
558 arraysize(kHandshakeRequestWithCookie) - 1; | 560 arraysize(kHandshakeRequestWithCookie) - 1; |
559 const size_t WebSocketJobTest::kHandshakeRequestWithFilteredCookieLength = | 561 const size_t WebSocketJobSpdy3Test::kHandshakeRequestWithFilteredCookieLength = |
560 arraysize(kHandshakeRequestWithFilteredCookie) - 1; | 562 arraysize(kHandshakeRequestWithFilteredCookie) - 1; |
561 const size_t WebSocketJobTest::kHandshakeResponseWithoutCookieLength = | 563 const size_t WebSocketJobSpdy3Test::kHandshakeResponseWithoutCookieLength = |
562 arraysize(kHandshakeResponseWithoutCookie) - 1; | 564 arraysize(kHandshakeResponseWithoutCookie) - 1; |
563 const size_t WebSocketJobTest::kHandshakeResponseWithCookieLength = | 565 const size_t WebSocketJobSpdy3Test::kHandshakeResponseWithCookieLength = |
564 arraysize(kHandshakeResponseWithCookie) - 1; | 566 arraysize(kHandshakeResponseWithCookie) - 1; |
565 const size_t WebSocketJobTest::kDataHelloLength = | 567 const size_t WebSocketJobSpdy3Test::kDataHelloLength = |
566 arraysize(kDataHello) - 1; | 568 arraysize(kDataHello) - 1; |
567 const size_t WebSocketJobTest::kDataWorldLength = | 569 const size_t WebSocketJobSpdy3Test::kDataWorldLength = |
568 arraysize(kDataWorld) - 1; | 570 arraysize(kDataWorld) - 1; |
569 | 571 |
570 void WebSocketJobTest::TestSimpleHandshake() { | 572 void WebSocketJobSpdy3Test::TestSimpleHandshake() { |
571 GURL url("ws://example.com/demo"); | 573 GURL url("ws://example.com/demo"); |
572 MockSocketStreamDelegate delegate; | 574 MockSocketStreamDelegate delegate; |
573 InitWebSocketJob(url, &delegate, STREAM_MOCK_SOCKET); | 575 InitWebSocketJob(url, &delegate, STREAM_MOCK_SOCKET); |
574 SkipToConnecting(); | 576 SkipToConnecting(); |
575 | 577 |
576 DoSendRequest(); | 578 DoSendRequest(); |
577 MessageLoop::current()->RunAllPending(); | 579 MessageLoop::current()->RunAllPending(); |
578 EXPECT_EQ(kHandshakeRequestWithoutCookie, sent_data()); | 580 EXPECT_EQ(kHandshakeRequestWithoutCookie, sent_data()); |
579 EXPECT_EQ(WebSocketJob::CONNECTING, GetWebSocketJobState()); | 581 EXPECT_EQ(WebSocketJob::CONNECTING, GetWebSocketJobState()); |
580 websocket_->OnSentData(socket_.get(), | 582 websocket_->OnSentData(socket_.get(), |
581 kHandshakeRequestWithoutCookieLength); | 583 kHandshakeRequestWithoutCookieLength); |
582 EXPECT_EQ(kHandshakeRequestWithoutCookieLength, delegate.amount_sent()); | 584 EXPECT_EQ(kHandshakeRequestWithoutCookieLength, delegate.amount_sent()); |
583 | 585 |
584 websocket_->OnReceivedData(socket_.get(), | 586 websocket_->OnReceivedData(socket_.get(), |
585 kHandshakeResponseWithoutCookie, | 587 kHandshakeResponseWithoutCookie, |
586 kHandshakeResponseWithoutCookieLength); | 588 kHandshakeResponseWithoutCookieLength); |
587 MessageLoop::current()->RunAllPending(); | 589 MessageLoop::current()->RunAllPending(); |
588 EXPECT_EQ(kHandshakeResponseWithoutCookie, delegate.received_data()); | 590 EXPECT_EQ(kHandshakeResponseWithoutCookie, delegate.received_data()); |
589 EXPECT_EQ(WebSocketJob::OPEN, GetWebSocketJobState()); | 591 EXPECT_EQ(WebSocketJob::OPEN, GetWebSocketJobState()); |
590 CloseWebSocketJob(); | 592 CloseWebSocketJob(); |
591 } | 593 } |
592 | 594 |
593 void WebSocketJobTest::TestSlowHandshake() { | 595 void WebSocketJobSpdy3Test::TestSlowHandshake() { |
594 GURL url("ws://example.com/demo"); | 596 GURL url("ws://example.com/demo"); |
595 MockSocketStreamDelegate delegate; | 597 MockSocketStreamDelegate delegate; |
596 InitWebSocketJob(url, &delegate, STREAM_MOCK_SOCKET); | 598 InitWebSocketJob(url, &delegate, STREAM_MOCK_SOCKET); |
597 SkipToConnecting(); | 599 SkipToConnecting(); |
598 | 600 |
599 DoSendRequest(); | 601 DoSendRequest(); |
600 // We assume request is sent in one data chunk (from WebKit) | 602 // We assume request is sent in one data chunk (from WebKit) |
601 // We don't support streaming request. | 603 // We don't support streaming request. |
602 MessageLoop::current()->RunAllPending(); | 604 MessageLoop::current()->RunAllPending(); |
603 EXPECT_EQ(kHandshakeRequestWithoutCookie, sent_data()); | 605 EXPECT_EQ(kHandshakeRequestWithoutCookie, sent_data()); |
(...skipping 17 matching lines...) Expand all Loading... |
621 websocket_->OnReceivedData(socket_.get(), "\r\n", 2); | 623 websocket_->OnReceivedData(socket_.get(), "\r\n", 2); |
622 MessageLoop::current()->RunAllPending(); | 624 MessageLoop::current()->RunAllPending(); |
623 EXPECT_TRUE(delegate.received_data().empty()); | 625 EXPECT_TRUE(delegate.received_data().empty()); |
624 EXPECT_EQ(WebSocketJob::CONNECTING, GetWebSocketJobState()); | 626 EXPECT_EQ(WebSocketJob::CONNECTING, GetWebSocketJobState()); |
625 websocket_->OnReceivedData(socket_.get(), "8jKS'y:G*Co,Wxa-", 16); | 627 websocket_->OnReceivedData(socket_.get(), "8jKS'y:G*Co,Wxa-", 16); |
626 EXPECT_EQ(kHandshakeResponseWithoutCookie, delegate.received_data()); | 628 EXPECT_EQ(kHandshakeResponseWithoutCookie, delegate.received_data()); |
627 EXPECT_EQ(WebSocketJob::OPEN, GetWebSocketJobState()); | 629 EXPECT_EQ(WebSocketJob::OPEN, GetWebSocketJobState()); |
628 CloseWebSocketJob(); | 630 CloseWebSocketJob(); |
629 } | 631 } |
630 | 632 |
631 TEST_F(WebSocketJobTest, DelayedCookies) { | 633 TEST_F(WebSocketJobSpdy3Test, DelayedCookies) { |
632 WebSocketJob::set_websocket_over_spdy_enabled(true); | 634 WebSocketJob::set_websocket_over_spdy_enabled(true); |
633 GURL url("ws://example.com/demo"); | 635 GURL url("ws://example.com/demo"); |
634 GURL cookieUrl("http://example.com/demo"); | 636 GURL cookieUrl("http://example.com/demo"); |
635 CookieOptions cookie_options; | 637 CookieOptions cookie_options; |
636 scoped_refptr<DelayedCookieMonster> cookie_store = new DelayedCookieMonster(); | 638 scoped_refptr<DelayedCookieMonster> cookie_store = new DelayedCookieMonster(); |
637 context_->set_cookie_store(cookie_store); | 639 context_->set_cookie_store(cookie_store); |
638 cookie_store->SetCookieWithOptionsAsync( | 640 cookie_store->SetCookieWithOptionsAsync( |
639 cookieUrl, "CR-test=1", cookie_options, | 641 cookieUrl, "CR-test=1", cookie_options, |
640 net::CookieMonster::SetCookiesCallback()); | 642 net::CookieMonster::SetCookiesCallback()); |
641 cookie_options.set_include_httponly(); | 643 cookie_options.set_include_httponly(); |
(...skipping 19 matching lines...) Expand all Loading... |
661 websocket_->OnReceivedData(socket_.get(), | 663 websocket_->OnReceivedData(socket_.get(), |
662 kHandshakeResponseWithCookie, | 664 kHandshakeResponseWithCookie, |
663 kHandshakeResponseWithCookieLength); | 665 kHandshakeResponseWithCookieLength); |
664 MessageLoop::current()->RunAllPending(); | 666 MessageLoop::current()->RunAllPending(); |
665 EXPECT_EQ(kHandshakeResponseWithoutCookie, delegate.received_data()); | 667 EXPECT_EQ(kHandshakeResponseWithoutCookie, delegate.received_data()); |
666 EXPECT_EQ(WebSocketJob::OPEN, GetWebSocketJobState()); | 668 EXPECT_EQ(WebSocketJob::OPEN, GetWebSocketJobState()); |
667 | 669 |
668 CloseWebSocketJob(); | 670 CloseWebSocketJob(); |
669 } | 671 } |
670 | 672 |
671 void WebSocketJobTest::TestHandshakeWithCookie() { | 673 void WebSocketJobSpdy3Test::TestHandshakeWithCookie() { |
672 GURL url("ws://example.com/demo"); | 674 GURL url("ws://example.com/demo"); |
673 GURL cookieUrl("http://example.com/demo"); | 675 GURL cookieUrl("http://example.com/demo"); |
674 CookieOptions cookie_options; | 676 CookieOptions cookie_options; |
675 cookie_store_->SetCookieWithOptions( | 677 cookie_store_->SetCookieWithOptions( |
676 cookieUrl, "CR-test=1", cookie_options); | 678 cookieUrl, "CR-test=1", cookie_options); |
677 cookie_options.set_include_httponly(); | 679 cookie_options.set_include_httponly(); |
678 cookie_store_->SetCookieWithOptions( | 680 cookie_store_->SetCookieWithOptions( |
679 cookieUrl, "CR-test-httponly=1", cookie_options); | 681 cookieUrl, "CR-test-httponly=1", cookie_options); |
680 | 682 |
681 MockSocketStreamDelegate delegate; | 683 MockSocketStreamDelegate delegate; |
(...skipping 22 matching lines...) Expand all Loading... |
704 EXPECT_EQ(cookieUrl, cookie_store_->entries()[0].url); | 706 EXPECT_EQ(cookieUrl, cookie_store_->entries()[0].url); |
705 EXPECT_EQ("CR-test=1", cookie_store_->entries()[0].cookie_line); | 707 EXPECT_EQ("CR-test=1", cookie_store_->entries()[0].cookie_line); |
706 EXPECT_EQ(cookieUrl, cookie_store_->entries()[1].url); | 708 EXPECT_EQ(cookieUrl, cookie_store_->entries()[1].url); |
707 EXPECT_EQ("CR-test-httponly=1", cookie_store_->entries()[1].cookie_line); | 709 EXPECT_EQ("CR-test-httponly=1", cookie_store_->entries()[1].cookie_line); |
708 EXPECT_EQ(cookieUrl, cookie_store_->entries()[2].url); | 710 EXPECT_EQ(cookieUrl, cookie_store_->entries()[2].url); |
709 EXPECT_EQ("CR-set-test=1", cookie_store_->entries()[2].cookie_line); | 711 EXPECT_EQ("CR-set-test=1", cookie_store_->entries()[2].cookie_line); |
710 | 712 |
711 CloseWebSocketJob(); | 713 CloseWebSocketJob(); |
712 } | 714 } |
713 | 715 |
714 void WebSocketJobTest::TestHandshakeWithCookieButNotAllowed() { | 716 void WebSocketJobSpdy3Test::TestHandshakeWithCookieButNotAllowed() { |
715 GURL url("ws://example.com/demo"); | 717 GURL url("ws://example.com/demo"); |
716 GURL cookieUrl("http://example.com/demo"); | 718 GURL cookieUrl("http://example.com/demo"); |
717 CookieOptions cookie_options; | 719 CookieOptions cookie_options; |
718 cookie_store_->SetCookieWithOptions( | 720 cookie_store_->SetCookieWithOptions( |
719 cookieUrl, "CR-test=1", cookie_options); | 721 cookieUrl, "CR-test=1", cookie_options); |
720 cookie_options.set_include_httponly(); | 722 cookie_options.set_include_httponly(); |
721 cookie_store_->SetCookieWithOptions( | 723 cookie_store_->SetCookieWithOptions( |
722 cookieUrl, "CR-test-httponly=1", cookie_options); | 724 cookieUrl, "CR-test-httponly=1", cookie_options); |
723 | 725 |
724 MockSocketStreamDelegate delegate; | 726 MockSocketStreamDelegate delegate; |
(...skipping 20 matching lines...) Expand all Loading... |
745 | 747 |
746 EXPECT_EQ(2U, cookie_store_->entries().size()); | 748 EXPECT_EQ(2U, cookie_store_->entries().size()); |
747 EXPECT_EQ(cookieUrl, cookie_store_->entries()[0].url); | 749 EXPECT_EQ(cookieUrl, cookie_store_->entries()[0].url); |
748 EXPECT_EQ("CR-test=1", cookie_store_->entries()[0].cookie_line); | 750 EXPECT_EQ("CR-test=1", cookie_store_->entries()[0].cookie_line); |
749 EXPECT_EQ(cookieUrl, cookie_store_->entries()[1].url); | 751 EXPECT_EQ(cookieUrl, cookie_store_->entries()[1].url); |
750 EXPECT_EQ("CR-test-httponly=1", cookie_store_->entries()[1].cookie_line); | 752 EXPECT_EQ("CR-test-httponly=1", cookie_store_->entries()[1].cookie_line); |
751 | 753 |
752 CloseWebSocketJob(); | 754 CloseWebSocketJob(); |
753 } | 755 } |
754 | 756 |
755 void WebSocketJobTest::TestHSTSUpgrade() { | 757 void WebSocketJobSpdy3Test::TestHSTSUpgrade() { |
756 GURL url("ws://upgrademe.com/"); | 758 GURL url("ws://upgrademe.com/"); |
757 MockSocketStreamDelegate delegate; | 759 MockSocketStreamDelegate delegate; |
758 scoped_refptr<SocketStreamJob> job = | 760 scoped_refptr<SocketStreamJob> job = |
759 SocketStreamJob::CreateSocketStreamJob( | 761 SocketStreamJob::CreateSocketStreamJob( |
760 url, &delegate, context_->transport_security_state(), | 762 url, &delegate, context_->transport_security_state(), |
761 context_->ssl_config_service()); | 763 context_->ssl_config_service()); |
762 EXPECT_TRUE(GetSocket(job.get())->is_secure()); | 764 EXPECT_TRUE(GetSocket(job.get())->is_secure()); |
763 job->DetachDelegate(); | 765 job->DetachDelegate(); |
764 | 766 |
765 url = GURL("ws://donotupgrademe.com/"); | 767 url = GURL("ws://donotupgrademe.com/"); |
766 job = SocketStreamJob::CreateSocketStreamJob( | 768 job = SocketStreamJob::CreateSocketStreamJob( |
767 url, &delegate, context_->transport_security_state(), | 769 url, &delegate, context_->transport_security_state(), |
768 context_->ssl_config_service()); | 770 context_->ssl_config_service()); |
769 EXPECT_FALSE(GetSocket(job.get())->is_secure()); | 771 EXPECT_FALSE(GetSocket(job.get())->is_secure()); |
770 job->DetachDelegate(); | 772 job->DetachDelegate(); |
771 } | 773 } |
772 | 774 |
773 void WebSocketJobTest::TestInvalidSendData() { | 775 void WebSocketJobSpdy3Test::TestInvalidSendData() { |
774 GURL url("ws://example.com/demo"); | 776 GURL url("ws://example.com/demo"); |
775 MockSocketStreamDelegate delegate; | 777 MockSocketStreamDelegate delegate; |
776 InitWebSocketJob(url, &delegate, STREAM_MOCK_SOCKET); | 778 InitWebSocketJob(url, &delegate, STREAM_MOCK_SOCKET); |
777 SkipToConnecting(); | 779 SkipToConnecting(); |
778 | 780 |
779 DoSendRequest(); | 781 DoSendRequest(); |
780 // We assume request is sent in one data chunk (from WebKit) | 782 // We assume request is sent in one data chunk (from WebKit) |
781 // We don't support streaming request. | 783 // We don't support streaming request. |
782 MessageLoop::current()->RunAllPending(); | 784 MessageLoop::current()->RunAllPending(); |
783 EXPECT_EQ(kHandshakeRequestWithoutCookie, sent_data()); | 785 EXPECT_EQ(kHandshakeRequestWithoutCookie, sent_data()); |
(...skipping 10 matching lines...) Expand all Loading... |
794 CloseWebSocketJob(); | 796 CloseWebSocketJob(); |
795 } | 797 } |
796 | 798 |
797 // Following tests verify cooperation between WebSocketJob and SocketStream. | 799 // Following tests verify cooperation between WebSocketJob and SocketStream. |
798 // Other former tests use MockSocketStream as SocketStream, so we could not | 800 // Other former tests use MockSocketStream as SocketStream, so we could not |
799 // check SocketStream behavior. | 801 // check SocketStream behavior. |
800 // OrderedSocketData provide socket level verifiation by checking out-going | 802 // OrderedSocketData provide socket level verifiation by checking out-going |
801 // packets in comparison with the MockWrite array and emulating in-coming | 803 // packets in comparison with the MockWrite array and emulating in-coming |
802 // packets with MockRead array. | 804 // packets with MockRead array. |
803 | 805 |
804 void WebSocketJobTest::TestConnectByWebSocket(ThrottlingOption throttling) { | 806 void WebSocketJobSpdy3Test::TestConnectByWebSocket( |
| 807 ThrottlingOption throttling) { |
805 // This is a test for verifying cooperation between WebSocketJob and | 808 // This is a test for verifying cooperation between WebSocketJob and |
806 // SocketStream. If |throttling| was |THROTTLING_OFF|, it test basic | 809 // SocketStream. If |throttling| was |THROTTLING_OFF|, it test basic |
807 // situation. If |throttling| was |THROTTLING_ON|, throttling limits the | 810 // situation. If |throttling| was |THROTTLING_ON|, throttling limits the |
808 // latter connection. | 811 // latter connection. |
809 MockWrite writes[] = { | 812 MockWrite writes[] = { |
810 MockWrite(ASYNC, | 813 MockWrite(ASYNC, |
811 kHandshakeRequestWithoutCookie, | 814 kHandshakeRequestWithoutCookie, |
812 kHandshakeRequestWithoutCookieLength, | 815 kHandshakeRequestWithoutCookieLength, |
813 1), | 816 1), |
814 MockWrite(ASYNC, | 817 MockWrite(ASYNC, |
(...skipping 10 matching lines...) Expand all Loading... |
825 kDataWorld, | 828 kDataWorld, |
826 kDataWorldLength, | 829 kDataWorldLength, |
827 4), | 830 4), |
828 MockRead(SYNCHRONOUS, 0, 5) // EOF | 831 MockRead(SYNCHRONOUS, 0, 5) // EOF |
829 }; | 832 }; |
830 data_.reset(new OrderedSocketData( | 833 data_.reset(new OrderedSocketData( |
831 reads, arraysize(reads), writes, arraysize(writes))); | 834 reads, arraysize(reads), writes, arraysize(writes))); |
832 | 835 |
833 GURL url("ws://example.com/demo"); | 836 GURL url("ws://example.com/demo"); |
834 MockSocketStreamDelegate delegate; | 837 MockSocketStreamDelegate delegate; |
835 WebSocketJobTest* test = this; | 838 WebSocketJobSpdy3Test* test = this; |
836 if (throttling == THROTTLING_ON) | 839 if (throttling == THROTTLING_ON) |
837 delegate.SetOnStartOpenConnection( | 840 delegate.SetOnStartOpenConnection( |
838 base::Bind(&WebSocketJobTest::DoSync, base::Unretained(test))); | 841 base::Bind(&WebSocketJobSpdy3Test::DoSync, base::Unretained(test))); |
839 delegate.SetOnConnected( | 842 delegate.SetOnConnected( |
840 base::Bind(&WebSocketJobTest::DoSendRequest, base::Unretained(test))); | 843 base::Bind(&WebSocketJobSpdy3Test::DoSendRequest, |
| 844 base::Unretained(test))); |
841 delegate.SetOnReceivedData( | 845 delegate.SetOnReceivedData( |
842 base::Bind(&WebSocketJobTest::DoSendData, base::Unretained(test))); | 846 base::Bind(&WebSocketJobSpdy3Test::DoSendData, base::Unretained(test))); |
843 delegate.SetOnClose( | 847 delegate.SetOnClose( |
844 base::Bind(&WebSocketJobTest::DoSync, base::Unretained(test))); | 848 base::Bind(&WebSocketJobSpdy3Test::DoSync, base::Unretained(test))); |
845 InitWebSocketJob(url, &delegate, STREAM_SOCKET); | 849 InitWebSocketJob(url, &delegate, STREAM_SOCKET); |
846 | 850 |
847 scoped_refptr<WebSocketJob> block_websocket; | 851 scoped_refptr<WebSocketJob> block_websocket; |
848 if (throttling == THROTTLING_ON) { | 852 if (throttling == THROTTLING_ON) { |
849 // Create former WebSocket object which obstructs the latter one. | 853 // Create former WebSocket object which obstructs the latter one. |
850 block_websocket = new WebSocketJob(NULL); | 854 block_websocket = new WebSocketJob(NULL); |
851 block_websocket->addresses_ = AddressList(websocket_->address_list()); | 855 block_websocket->addresses_ = AddressList(websocket_->address_list()); |
852 WebSocketThrottle::GetInstance()->PutInQueue(block_websocket.get()); | 856 WebSocketThrottle::GetInstance()->PutInQueue(block_websocket.get()); |
853 } | 857 } |
854 | 858 |
(...skipping 10 matching lines...) Expand all Loading... |
865 block_websocket = NULL; | 869 block_websocket = NULL; |
866 WebSocketThrottle::GetInstance()->WakeupSocketIfNecessary(); | 870 WebSocketThrottle::GetInstance()->WakeupSocketIfNecessary(); |
867 } | 871 } |
868 | 872 |
869 EXPECT_EQ(OK, WaitForResult()); | 873 EXPECT_EQ(OK, WaitForResult()); |
870 EXPECT_TRUE(data_->at_read_eof()); | 874 EXPECT_TRUE(data_->at_read_eof()); |
871 EXPECT_TRUE(data_->at_write_eof()); | 875 EXPECT_TRUE(data_->at_write_eof()); |
872 EXPECT_EQ(WebSocketJob::CLOSED, GetWebSocketJobState()); | 876 EXPECT_EQ(WebSocketJob::CLOSED, GetWebSocketJobState()); |
873 } | 877 } |
874 | 878 |
875 void WebSocketJobTest::TestConnectBySpdy( | 879 void WebSocketJobSpdy3Test::TestConnectBySpdy( |
876 SpdyOption spdy, ThrottlingOption throttling) { | 880 SpdyOption spdy, ThrottlingOption throttling) { |
877 // This is a test for verifying cooperation between WebSocketJob and | 881 // This is a test for verifying cooperation between WebSocketJob and |
878 // SocketStream in the situation we have SPDY session to the server. If | 882 // SocketStream in the situation we have SPDY session to the server. If |
879 // |throttling| was |THROTTLING_ON|, throttling limits the latter connection. | 883 // |throttling| was |THROTTLING_ON|, throttling limits the latter connection. |
880 // If you enabled spdy, you should specify |spdy| as |SPDY_ON|. Expected | 884 // If you enabled spdy, you should specify |spdy| as |SPDY_ON|. Expected |
881 // results depend on its configuration. | 885 // results depend on its configuration. |
882 MockWrite writes_websocket[] = { | 886 MockWrite writes_websocket[] = { |
883 MockWrite(ASYNC, | 887 MockWrite(ASYNC, |
884 kHandshakeRequestWithoutCookie, | 888 kHandshakeRequestWithoutCookie, |
885 kHandshakeRequestWithoutCookieLength, | 889 kHandshakeRequestWithoutCookieLength, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 data_.reset(new OrderedSocketData( | 944 data_.reset(new OrderedSocketData( |
941 reads_spdy, arraysize(reads_spdy), | 945 reads_spdy, arraysize(reads_spdy), |
942 writes_spdy, arraysize(writes_spdy))); | 946 writes_spdy, arraysize(writes_spdy))); |
943 else | 947 else |
944 data_.reset(new OrderedSocketData( | 948 data_.reset(new OrderedSocketData( |
945 reads_websocket, arraysize(reads_websocket), | 949 reads_websocket, arraysize(reads_websocket), |
946 writes_websocket, arraysize(writes_websocket))); | 950 writes_websocket, arraysize(writes_websocket))); |
947 | 951 |
948 GURL url("ws://example.com/demo"); | 952 GURL url("ws://example.com/demo"); |
949 MockSocketStreamDelegate delegate; | 953 MockSocketStreamDelegate delegate; |
950 WebSocketJobTest* test = this; | 954 WebSocketJobSpdy3Test* test = this; |
951 if (throttling == THROTTLING_ON) | 955 if (throttling == THROTTLING_ON) |
952 delegate.SetOnStartOpenConnection( | 956 delegate.SetOnStartOpenConnection( |
953 base::Bind(&WebSocketJobTest::DoSync, base::Unretained(test))); | 957 base::Bind(&WebSocketJobSpdy3Test::DoSync, base::Unretained(test))); |
954 delegate.SetOnConnected( | 958 delegate.SetOnConnected( |
955 base::Bind(&WebSocketJobTest::DoSendRequest, base::Unretained(test))); | 959 base::Bind(&WebSocketJobSpdy3Test::DoSendRequest, |
| 960 base::Unretained(test))); |
956 delegate.SetOnReceivedData( | 961 delegate.SetOnReceivedData( |
957 base::Bind(&WebSocketJobTest::DoSendData, base::Unretained(test))); | 962 base::Bind(&WebSocketJobSpdy3Test::DoSendData, base::Unretained(test))); |
958 delegate.SetOnClose( | 963 delegate.SetOnClose( |
959 base::Bind(&WebSocketJobTest::DoSync, base::Unretained(test))); | 964 base::Bind(&WebSocketJobSpdy3Test::DoSync, base::Unretained(test))); |
960 InitWebSocketJob(url, &delegate, STREAM_SPDY_WEBSOCKET); | 965 InitWebSocketJob(url, &delegate, STREAM_SPDY_WEBSOCKET); |
961 | 966 |
962 scoped_refptr<WebSocketJob> block_websocket; | 967 scoped_refptr<WebSocketJob> block_websocket; |
963 if (throttling == THROTTLING_ON) { | 968 if (throttling == THROTTLING_ON) { |
964 // Create former WebSocket object which obstructs the latter one. | 969 // Create former WebSocket object which obstructs the latter one. |
965 block_websocket = new WebSocketJob(NULL); | 970 block_websocket = new WebSocketJob(NULL); |
966 block_websocket->addresses_ = AddressList(websocket_->address_list()); | 971 block_websocket->addresses_ = AddressList(websocket_->address_list()); |
967 WebSocketThrottle::GetInstance()->PutInQueue(block_websocket.get()); | 972 WebSocketThrottle::GetInstance()->PutInQueue(block_websocket.get()); |
968 } | 973 } |
969 | 974 |
(...skipping 11 matching lines...) Expand all Loading... |
981 WebSocketThrottle::GetInstance()->WakeupSocketIfNecessary(); | 986 WebSocketThrottle::GetInstance()->WakeupSocketIfNecessary(); |
982 } | 987 } |
983 | 988 |
984 EXPECT_EQ(OK, WaitForResult()); | 989 EXPECT_EQ(OK, WaitForResult()); |
985 EXPECT_TRUE(data_->at_read_eof()); | 990 EXPECT_TRUE(data_->at_read_eof()); |
986 EXPECT_TRUE(data_->at_write_eof()); | 991 EXPECT_TRUE(data_->at_write_eof()); |
987 EXPECT_EQ(WebSocketJob::CLOSED, GetWebSocketJobState()); | 992 EXPECT_EQ(WebSocketJob::CLOSED, GetWebSocketJobState()); |
988 } | 993 } |
989 | 994 |
990 // Execute tests in both spdy-disabled mode and spdy-enabled mode. | 995 // Execute tests in both spdy-disabled mode and spdy-enabled mode. |
991 TEST_F(WebSocketJobTest, SimpleHandshake) { | 996 TEST_F(WebSocketJobSpdy3Test, SimpleHandshake) { |
992 WebSocketJob::set_websocket_over_spdy_enabled(false); | 997 WebSocketJob::set_websocket_over_spdy_enabled(false); |
993 TestSimpleHandshake(); | 998 TestSimpleHandshake(); |
994 } | 999 } |
995 | 1000 |
996 TEST_F(WebSocketJobTest, SlowHandshake) { | 1001 TEST_F(WebSocketJobSpdy3Test, SlowHandshake) { |
997 WebSocketJob::set_websocket_over_spdy_enabled(false); | 1002 WebSocketJob::set_websocket_over_spdy_enabled(false); |
998 TestSlowHandshake(); | 1003 TestSlowHandshake(); |
999 } | 1004 } |
1000 | 1005 |
1001 TEST_F(WebSocketJobTest, HandshakeWithCookie) { | 1006 TEST_F(WebSocketJobSpdy3Test, HandshakeWithCookie) { |
1002 WebSocketJob::set_websocket_over_spdy_enabled(false); | 1007 WebSocketJob::set_websocket_over_spdy_enabled(false); |
1003 TestHandshakeWithCookie(); | 1008 TestHandshakeWithCookie(); |
1004 } | 1009 } |
1005 | 1010 |
1006 TEST_F(WebSocketJobTest, HandshakeWithCookieButNotAllowed) { | 1011 TEST_F(WebSocketJobSpdy3Test, HandshakeWithCookieButNotAllowed) { |
1007 WebSocketJob::set_websocket_over_spdy_enabled(false); | 1012 WebSocketJob::set_websocket_over_spdy_enabled(false); |
1008 TestHandshakeWithCookieButNotAllowed(); | 1013 TestHandshakeWithCookieButNotAllowed(); |
1009 } | 1014 } |
1010 | 1015 |
1011 TEST_F(WebSocketJobTest, HSTSUpgrade) { | 1016 TEST_F(WebSocketJobSpdy3Test, HSTSUpgrade) { |
1012 WebSocketJob::set_websocket_over_spdy_enabled(false); | 1017 WebSocketJob::set_websocket_over_spdy_enabled(false); |
1013 TestHSTSUpgrade(); | 1018 TestHSTSUpgrade(); |
1014 } | 1019 } |
1015 | 1020 |
1016 TEST_F(WebSocketJobTest, InvalidSendData) { | 1021 TEST_F(WebSocketJobSpdy3Test, InvalidSendData) { |
1017 WebSocketJob::set_websocket_over_spdy_enabled(false); | 1022 WebSocketJob::set_websocket_over_spdy_enabled(false); |
1018 TestInvalidSendData(); | 1023 TestInvalidSendData(); |
1019 } | 1024 } |
1020 | 1025 |
1021 TEST_F(WebSocketJobTest, SimpleHandshakeSpdyEnabled) { | 1026 TEST_F(WebSocketJobSpdy3Test, SimpleHandshakeSpdyEnabled) { |
1022 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1027 WebSocketJob::set_websocket_over_spdy_enabled(true); |
1023 TestSimpleHandshake(); | 1028 TestSimpleHandshake(); |
1024 } | 1029 } |
1025 | 1030 |
1026 TEST_F(WebSocketJobTest, SlowHandshakeSpdyEnabled) { | 1031 TEST_F(WebSocketJobSpdy3Test, SlowHandshakeSpdyEnabled) { |
1027 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1032 WebSocketJob::set_websocket_over_spdy_enabled(true); |
1028 TestSlowHandshake(); | 1033 TestSlowHandshake(); |
1029 } | 1034 } |
1030 | 1035 |
1031 TEST_F(WebSocketJobTest, HandshakeWithCookieSpdyEnabled) { | 1036 TEST_F(WebSocketJobSpdy3Test, HandshakeWithCookieSpdyEnabled) { |
1032 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1037 WebSocketJob::set_websocket_over_spdy_enabled(true); |
1033 TestHandshakeWithCookie(); | 1038 TestHandshakeWithCookie(); |
1034 } | 1039 } |
1035 | 1040 |
1036 TEST_F(WebSocketJobTest, HandshakeWithCookieButNotAllowedSpdyEnabled) { | 1041 TEST_F(WebSocketJobSpdy3Test, HandshakeWithCookieButNotAllowedSpdyEnabled) { |
1037 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1042 WebSocketJob::set_websocket_over_spdy_enabled(true); |
1038 TestHandshakeWithCookieButNotAllowed(); | 1043 TestHandshakeWithCookieButNotAllowed(); |
1039 } | 1044 } |
1040 | 1045 |
1041 TEST_F(WebSocketJobTest, HSTSUpgradeSpdyEnabled) { | 1046 TEST_F(WebSocketJobSpdy3Test, HSTSUpgradeSpdyEnabled) { |
1042 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1047 WebSocketJob::set_websocket_over_spdy_enabled(true); |
1043 TestHSTSUpgrade(); | 1048 TestHSTSUpgrade(); |
1044 } | 1049 } |
1045 | 1050 |
1046 TEST_F(WebSocketJobTest, InvalidSendDataSpdyEnabled) { | 1051 TEST_F(WebSocketJobSpdy3Test, InvalidSendDataSpdyEnabled) { |
1047 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1052 WebSocketJob::set_websocket_over_spdy_enabled(true); |
1048 TestInvalidSendData(); | 1053 TestInvalidSendData(); |
1049 } | 1054 } |
1050 | 1055 |
1051 TEST_F(WebSocketJobTest, ConnectByWebSocket) { | 1056 TEST_F(WebSocketJobSpdy3Test, ConnectByWebSocket) { |
1052 WebSocketJob::set_websocket_over_spdy_enabled(false); | 1057 WebSocketJob::set_websocket_over_spdy_enabled(false); |
1053 TestConnectByWebSocket(THROTTLING_OFF); | 1058 TestConnectByWebSocket(THROTTLING_OFF); |
1054 } | 1059 } |
1055 | 1060 |
1056 TEST_F(WebSocketJobTest, ConnectByWebSocketSpdyEnabled) { | 1061 TEST_F(WebSocketJobSpdy3Test, ConnectByWebSocketSpdyEnabled) { |
1057 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1062 WebSocketJob::set_websocket_over_spdy_enabled(true); |
1058 TestConnectByWebSocket(THROTTLING_OFF); | 1063 TestConnectByWebSocket(THROTTLING_OFF); |
1059 } | 1064 } |
1060 | 1065 |
1061 TEST_F(WebSocketJobTest, ConnectBySpdy) { | 1066 TEST_F(WebSocketJobSpdy3Test, ConnectBySpdy) { |
1062 WebSocketJob::set_websocket_over_spdy_enabled(false); | 1067 WebSocketJob::set_websocket_over_spdy_enabled(false); |
1063 TestConnectBySpdy(SPDY_OFF, THROTTLING_OFF); | 1068 TestConnectBySpdy(SPDY_OFF, THROTTLING_OFF); |
1064 } | 1069 } |
1065 | 1070 |
1066 TEST_F(WebSocketJobTest, ConnectBySpdySpdyEnabled) { | 1071 TEST_F(WebSocketJobSpdy3Test, ConnectBySpdySpdyEnabled) { |
1067 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1072 WebSocketJob::set_websocket_over_spdy_enabled(true); |
1068 TestConnectBySpdy(SPDY_ON, THROTTLING_OFF); | 1073 TestConnectBySpdy(SPDY_ON, THROTTLING_OFF); |
1069 } | 1074 } |
1070 | 1075 |
1071 TEST_F(WebSocketJobTest, ThrottlingWebSocket) { | 1076 TEST_F(WebSocketJobSpdy3Test, ThrottlingWebSocket) { |
1072 WebSocketJob::set_websocket_over_spdy_enabled(false); | 1077 WebSocketJob::set_websocket_over_spdy_enabled(false); |
1073 TestConnectByWebSocket(THROTTLING_ON); | 1078 TestConnectByWebSocket(THROTTLING_ON); |
1074 } | 1079 } |
1075 | 1080 |
1076 TEST_F(WebSocketJobTest, ThrottlingWebSocketSpdyEnabled) { | 1081 TEST_F(WebSocketJobSpdy3Test, ThrottlingWebSocketSpdyEnabled) { |
1077 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1082 WebSocketJob::set_websocket_over_spdy_enabled(true); |
1078 TestConnectByWebSocket(THROTTLING_ON); | 1083 TestConnectByWebSocket(THROTTLING_ON); |
1079 } | 1084 } |
1080 | 1085 |
1081 TEST_F(WebSocketJobTest, ThrottlingSpdy) { | 1086 TEST_F(WebSocketJobSpdy3Test, ThrottlingSpdy) { |
1082 WebSocketJob::set_websocket_over_spdy_enabled(false); | 1087 WebSocketJob::set_websocket_over_spdy_enabled(false); |
1083 TestConnectBySpdy(SPDY_OFF, THROTTLING_ON); | 1088 TestConnectBySpdy(SPDY_OFF, THROTTLING_ON); |
1084 } | 1089 } |
1085 | 1090 |
1086 TEST_F(WebSocketJobTest, ThrottlingSpdySpdyEnabled) { | 1091 TEST_F(WebSocketJobSpdy3Test, ThrottlingSpdySpdyEnabled) { |
1087 WebSocketJob::set_websocket_over_spdy_enabled(true); | 1092 WebSocketJob::set_websocket_over_spdy_enabled(true); |
1088 TestConnectBySpdy(SPDY_ON, THROTTLING_ON); | 1093 TestConnectBySpdy(SPDY_ON, THROTTLING_ON); |
1089 } | 1094 } |
1090 | 1095 |
1091 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation. | 1096 // TODO(toyoshim): Add tests to verify throttling, SPDY stream limitation. |
1092 // TODO(toyoshim,yutak): Add tests to verify closing handshake. | 1097 // TODO(toyoshim,yutak): Add tests to verify closing handshake. |
1093 | 1098 |
1094 } // namespace net | 1099 } // namespace net |
OLD | NEW |