| 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 initialised_context_ = true; | 258 initialised_context_ = true; |
| 259 } | 259 } |
| 260 | 260 |
| 261 // Send the connect request to |socket_url| and wait for a response. Returns | 261 // Send the connect request to |socket_url| and wait for a response. Returns |
| 262 // true if the handshake succeeded. | 262 // true if the handshake succeeded. |
| 263 bool ConnectAndWait(const GURL& socket_url) { | 263 bool ConnectAndWait(const GURL& socket_url) { |
| 264 if (!initialised_context_) { | 264 if (!initialised_context_) { |
| 265 InitialiseContext(); | 265 InitialiseContext(); |
| 266 } | 266 } |
| 267 url::Origin origin(GURL("http://localhost")); | 267 url::Origin origin(GURL("http://localhost")); |
| 268 GURL first_party_for_cookies("http://localhost/"); |
| 268 event_interface_ = new ConnectTestingEventInterface; | 269 event_interface_ = new ConnectTestingEventInterface; |
| 269 channel_.reset( | 270 channel_.reset( |
| 270 new WebSocketChannel(base::WrapUnique(event_interface_), &context_)); | 271 new WebSocketChannel(base::WrapUnique(event_interface_), &context_)); |
| 271 channel_->SendAddChannelRequest(GURL(socket_url), sub_protocols_, origin, | 272 channel_->SendAddChannelRequest(GURL(socket_url), sub_protocols_, origin, |
| 272 ""); | 273 first_party_for_cookies, ""); |
| 273 event_interface_->WaitForResponse(); | 274 event_interface_->WaitForResponse(); |
| 274 return !event_interface_->failed(); | 275 return !event_interface_->failed(); |
| 275 } | 276 } |
| 276 | 277 |
| 277 ConnectTestingEventInterface* event_interface_; // owned by channel_ | 278 ConnectTestingEventInterface* event_interface_; // owned by channel_ |
| 278 std::unique_ptr<TestProxyDelegateWithProxyInfo> proxy_delegate_; | 279 std::unique_ptr<TestProxyDelegateWithProxyInfo> proxy_delegate_; |
| 279 TestURLRequestContext context_; | 280 TestURLRequestContext context_; |
| 280 std::unique_ptr<WebSocketChannel> channel_; | 281 std::unique_ptr<WebSocketChannel> channel_; |
| 281 std::vector<std::string> sub_protocols_; | 282 std::vector<std::string> sub_protocols_; |
| 282 bool initialised_context_; | 283 bool initialised_context_; |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 GURL ws_url = ws_server.GetURL("header-continuation"); | 512 GURL ws_url = ws_server.GetURL("header-continuation"); |
| 512 | 513 |
| 513 EXPECT_TRUE(ConnectAndWait(ws_url)); | 514 EXPECT_TRUE(ConnectAndWait(ws_url)); |
| 514 EXPECT_EQ("permessage-deflate; server_max_window_bits=10", | 515 EXPECT_EQ("permessage-deflate; server_max_window_bits=10", |
| 515 event_interface_->extensions()); | 516 event_interface_->extensions()); |
| 516 } | 517 } |
| 517 | 518 |
| 518 } // namespace | 519 } // namespace |
| 519 | 520 |
| 520 } // namespace net | 521 } // namespace net |
| OLD | NEW |