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

Side by Side Diff: content/browser/renderer_host/websocket_dispatcher_host_unittest.cc

Issue 1000883004: Add WebSocketDispatcherHostTest.InvalidScheme (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comment fix. 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 | « no previous file | 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 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 "content/browser/renderer_host/websocket_dispatcher_host.h" 5 #include "content/browser/renderer_host/websocket_dispatcher_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 EXPECT_EQ(255, dispatcher_host_->num_failed_connections()); 403 EXPECT_EQ(255, dispatcher_host_->num_failed_connections());
404 EXPECT_EQ(0, dispatcher_host_->num_succeeded_connections()); 404 EXPECT_EQ(0, dispatcher_host_->num_succeeded_connections());
405 405
406 ASSERT_TRUE(AddMultipleChannels(1)); 406 ASSERT_TRUE(AddMultipleChannels(1));
407 407
408 EXPECT_EQ(1, dispatcher_host_->num_pending_connections()); 408 EXPECT_EQ(1, dispatcher_host_->num_pending_connections());
409 EXPECT_EQ(255, dispatcher_host_->num_failed_connections()); 409 EXPECT_EQ(255, dispatcher_host_->num_failed_connections());
410 EXPECT_EQ(0, dispatcher_host_->num_succeeded_connections()); 410 EXPECT_EQ(0, dispatcher_host_->num_succeeded_connections());
411 } 411 }
412 412
413 TEST_F(WebSocketDispatcherHostTest, InvalidScheme) {
Adam Rice 2015/03/12 09:53:34 Please add a comment such as // This is a regress
hiroshige 2015/03/12 09:57:48 Done.
414 int routing_id = 123;
415 GURL socket_url("http://example.com/test");
416 std::vector<std::string> requested_protocols;
417 requested_protocols.push_back("hello");
418 url::Origin origin("http://example.com");
419 int render_frame_id = -2;
420 WebSocketHostMsg_AddChannelRequest message(
421 routing_id, socket_url, requested_protocols, origin, render_frame_id);
422
423 ASSERT_TRUE(dispatcher_host_->OnMessageReceived(message));
424
425 ASSERT_EQ(1U, mock_hosts_.size());
426 MockWebSocketHost* host = mock_hosts_[0];
427
428 // Tests that WebSocketHost::OnMessageReceived() doesn't cause a crash and
429 // the connection with an invalid scheme fails here.
430 // We call WebSocketHost::OnMessageReceived() here explicitly because
431 // MockWebSocketHost does not call WebSocketHost::OnMessageReceived() for
432 // WebSocketHostMsg_AddChannelRequest.
433 host->WebSocketHost::OnMessageReceived(message);
434
435 EXPECT_EQ(0, dispatcher_host_->num_pending_connections());
436 EXPECT_EQ(1, dispatcher_host_->num_failed_connections());
437 EXPECT_EQ(0, dispatcher_host_->num_succeeded_connections());
438 }
439
413 } // namespace 440 } // namespace
414 } // namespace content 441 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698