Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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) { | |
| 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 do not call WebSocketHost::OnMessageReceived() for | |
|
Adam Rice
2015/03/12 09:17:53
s/do not call/does not call/
hiroshige
2015/03/12 09:21:22
Done.
| |
| 432 // WebSocketHostMsg_AddChannelRequest by default. | |
|
Adam Rice
2015/03/12 09:17:53
Remove "by default". The sentence is clearer witho
hiroshige
2015/03/12 09:21:22
Done.
| |
| 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 |
| OLD | NEW |