OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // End-to-end tests for WebSocket. | 5 // End-to-end tests for WebSocket. |
6 // | 6 // |
7 // A python server is (re)started for each test, which is moderately | 7 // A python server is (re)started for each test, which is moderately |
8 // inefficient. However, it makes these tests a good fit for scenarios which | 8 // inefficient. However, it makes these tests a good fit for scenarios which |
9 // require special server configurations. | 9 // require special server configurations. |
10 | 10 |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 ASSERT_TRUE(wss_server.Start()); | 428 ASSERT_TRUE(wss_server.Start()); |
429 InitialiseContext(); | 429 InitialiseContext(); |
430 // Set HSTS via https: | 430 // Set HSTS via https: |
431 TestDelegate delegate; | 431 TestDelegate delegate; |
432 GURL https_page = https_server.GetURL("/hsts-headers.html"); | 432 GURL https_page = https_server.GetURL("/hsts-headers.html"); |
433 std::unique_ptr<URLRequest> request( | 433 std::unique_ptr<URLRequest> request( |
434 context_.CreateRequest(https_page, DEFAULT_PRIORITY, &delegate)); | 434 context_.CreateRequest(https_page, DEFAULT_PRIORITY, &delegate)); |
435 request->Start(); | 435 request->Start(); |
436 // TestDelegate exits the message loop when the request completes. | 436 // TestDelegate exits the message loop when the request completes. |
437 base::RunLoop().Run(); | 437 base::RunLoop().Run(); |
438 EXPECT_TRUE(request->status().is_success()); | 438 EXPECT_EQ(OK, delegate.request_status()); |
439 | 439 |
440 // Check HSTS with ws: | 440 // Check HSTS with ws: |
441 // Change the scheme from wss: to ws: to verify that it is switched back. | 441 // Change the scheme from wss: to ws: to verify that it is switched back. |
442 GURL ws_url = ReplaceUrlScheme(wss_server.GetURL(kEchoServer), "ws"); | 442 GURL ws_url = ReplaceUrlScheme(wss_server.GetURL(kEchoServer), "ws"); |
443 EXPECT_TRUE(ConnectAndWait(ws_url)); | 443 EXPECT_TRUE(ConnectAndWait(ws_url)); |
444 } | 444 } |
445 | 445 |
446 TEST_F(WebSocketEndToEndTest, DISABLED_ON_ANDROID(HstsWebSocketToHttps)) { | 446 TEST_F(WebSocketEndToEndTest, DISABLED_ON_ANDROID(HstsWebSocketToHttps)) { |
447 EmbeddedTestServer https_server(net::EmbeddedTestServer::Type::TYPE_HTTPS); | 447 EmbeddedTestServer https_server(net::EmbeddedTestServer::Type::TYPE_HTTPS); |
448 https_server.SetSSLConfig( | 448 https_server.SetSSLConfig( |
(...skipping 13 matching lines...) Expand all Loading... |
462 | 462 |
463 // Verify via http: | 463 // Verify via http: |
464 TestDelegate delegate; | 464 TestDelegate delegate; |
465 GURL http_page = | 465 GURL http_page = |
466 ReplaceUrlScheme(https_server.GetURL("/simple.html"), "http"); | 466 ReplaceUrlScheme(https_server.GetURL("/simple.html"), "http"); |
467 std::unique_ptr<URLRequest> request( | 467 std::unique_ptr<URLRequest> request( |
468 context_.CreateRequest(http_page, DEFAULT_PRIORITY, &delegate)); | 468 context_.CreateRequest(http_page, DEFAULT_PRIORITY, &delegate)); |
469 request->Start(); | 469 request->Start(); |
470 // TestDelegate exits the message loop when the request completes. | 470 // TestDelegate exits the message loop when the request completes. |
471 base::RunLoop().Run(); | 471 base::RunLoop().Run(); |
472 EXPECT_TRUE(request->status().is_success()); | 472 EXPECT_EQ(OK, delegate.request_status()); |
473 EXPECT_TRUE(request->url().SchemeIs("https")); | 473 EXPECT_TRUE(request->url().SchemeIs("https")); |
474 } | 474 } |
475 | 475 |
476 TEST_F(WebSocketEndToEndTest, DISABLED_ON_ANDROID(HstsWebSocketToWebSocket)) { | 476 TEST_F(WebSocketEndToEndTest, DISABLED_ON_ANDROID(HstsWebSocketToWebSocket)) { |
477 SpawnedTestServer::SSLOptions ssl_options( | 477 SpawnedTestServer::SSLOptions ssl_options( |
478 SpawnedTestServer::SSLOptions::CERT_COMMON_NAME_IS_DOMAIN); | 478 SpawnedTestServer::SSLOptions::CERT_COMMON_NAME_IS_DOMAIN); |
479 SpawnedTestServer wss_server(SpawnedTestServer::TYPE_WSS, ssl_options, | 479 SpawnedTestServer wss_server(SpawnedTestServer::TYPE_WSS, ssl_options, |
480 GetWebSocketTestDataDirectory()); | 480 GetWebSocketTestDataDirectory()); |
481 ASSERT_TRUE(wss_server.Start()); | 481 ASSERT_TRUE(wss_server.Start()); |
482 InitialiseContext(); | 482 InitialiseContext(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 GURL ws_url = ws_server.GetURL("header-continuation"); | 517 GURL ws_url = ws_server.GetURL("header-continuation"); |
518 | 518 |
519 EXPECT_TRUE(ConnectAndWait(ws_url)); | 519 EXPECT_TRUE(ConnectAndWait(ws_url)); |
520 EXPECT_EQ("permessage-deflate; server_max_window_bits=10", | 520 EXPECT_EQ("permessage-deflate; server_max_window_bits=10", |
521 event_interface_->extensions()); | 521 event_interface_->extensions()); |
522 } | 522 } |
523 | 523 |
524 } // namespace | 524 } // namespace |
525 | 525 |
526 } // namespace net | 526 } // namespace net |
OLD | NEW |