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

Side by Side Diff: net/websockets/websocket_end_to_end_test.cc

Issue 1001353002: WebSocket ignores trailing whitespace test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « net/data/websocket/trailing-whitespace_wsh.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 context_.Init(); 235 context_.Init();
236 initialised_context_ = true; 236 initialised_context_ = true;
237 } 237 }
238 238
239 // Send the connect request to |socket_url| and wait for a response. Returns 239 // Send the connect request to |socket_url| and wait for a response. Returns
240 // true if the handshake succeeded. 240 // true if the handshake succeeded.
241 bool ConnectAndWait(const GURL& socket_url) { 241 bool ConnectAndWait(const GURL& socket_url) {
242 if (!initialised_context_) { 242 if (!initialised_context_) {
243 InitialiseContext(); 243 InitialiseContext();
244 } 244 }
245 std::vector<std::string> sub_protocols;
246 url::Origin origin("http://localhost"); 245 url::Origin origin("http://localhost");
247 event_interface_ = new ConnectTestingEventInterface; 246 event_interface_ = new ConnectTestingEventInterface;
248 channel_.reset( 247 channel_.reset(
249 new WebSocketChannel(make_scoped_ptr(event_interface_), &context_)); 248 new WebSocketChannel(make_scoped_ptr(event_interface_), &context_));
250 channel_->SendAddChannelRequest(GURL(socket_url), sub_protocols, origin); 249 channel_->SendAddChannelRequest(GURL(socket_url), sub_protocols_, origin);
251 event_interface_->WaitForResponse(); 250 event_interface_->WaitForResponse();
252 return !event_interface_->failed(); 251 return !event_interface_->failed();
253 } 252 }
254 253
255 ConnectTestingEventInterface* event_interface_; // owned by channel_ 254 ConnectTestingEventInterface* event_interface_; // owned by channel_
256 scoped_ptr<TestNetworkDelegateWithProxyInfo> network_delegate_; 255 scoped_ptr<TestNetworkDelegateWithProxyInfo> network_delegate_;
257 TestURLRequestContext context_; 256 TestURLRequestContext context_;
258 scoped_ptr<WebSocketChannel> channel_; 257 scoped_ptr<WebSocketChannel> channel_;
258 std::vector<std::string> sub_protocols_;
259 bool initialised_context_; 259 bool initialised_context_;
260 }; 260 };
261 261
262 // None of these tests work on Android. 262 // None of these tests work on Android.
263 // TODO(ricea): Make these tests work on Android. See crbug.com/441711. 263 // TODO(ricea): Make these tests work on Android. See crbug.com/441711.
264 #if defined(OS_ANDROID) 264 #if defined(OS_ANDROID)
265 #define DISABLED_ON_ANDROID(test) DISABLED_##test 265 #define DISABLED_ON_ANDROID(test) DISABLED_##test
266 #else 266 #else
267 #define DISABLED_ON_ANDROID(test) test 267 #define DISABLED_ON_ANDROID(test) test
268 #endif 268 #endif
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 InitialiseContext(); 449 InitialiseContext();
450 // Set HSTS via wss: 450 // Set HSTS via wss:
451 GURL wss_url = wss_server.GetURL("set-hsts"); 451 GURL wss_url = wss_server.GetURL("set-hsts");
452 EXPECT_TRUE(ConnectAndWait(wss_url)); 452 EXPECT_TRUE(ConnectAndWait(wss_url));
453 453
454 // Verify via wss: 454 // Verify via wss:
455 GURL ws_url = ReplaceUrlScheme(wss_server.GetURL(kEchoServer), "ws"); 455 GURL ws_url = ReplaceUrlScheme(wss_server.GetURL(kEchoServer), "ws");
456 EXPECT_TRUE(ConnectAndWait(ws_url)); 456 EXPECT_TRUE(ConnectAndWait(ws_url));
457 } 457 }
458 458
459 // Regression test for crbug.com/180504 "WebSocket handshake fails when HTTP
460 // headers have trailing LWS".
461 TEST_F(WebSocketEndToEndTest, DISABLED_ON_ANDROID(TrailingWhitespace)) {
462 SpawnedTestServer ws_server(SpawnedTestServer::TYPE_WS,
463 SpawnedTestServer::kLocalhost,
464 GetWebSocketTestDataDirectory());
465 ASSERT_TRUE(ws_server.Start());
466
467 GURL ws_url = ws_server.GetURL("trailing-whitespace");
468 sub_protocols_.push_back("sip");
469 EXPECT_TRUE(ConnectAndWait(ws_url));
470 EXPECT_EQ("sip", event_interface_->selected_subprotocol());
471 }
472
459 } // namespace 473 } // namespace
460 474
461 } // namespace net 475 } // namespace net
OLDNEW
« no previous file with comments | « net/data/websocket/trailing-whitespace_wsh.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698