Chromium Code Reviews| Index: content/browser/renderer_host/websocket_dispatcher_host_unittest.cc |
| diff --git a/content/browser/renderer_host/websocket_dispatcher_host_unittest.cc b/content/browser/renderer_host/websocket_dispatcher_host_unittest.cc |
| index 088f85d3b4150bbc0c834dccf69f85b926fd27bf..b5c572b4764f1ed299ee1276da548615d30ccd4e 100644 |
| --- a/content/browser/renderer_host/websocket_dispatcher_host_unittest.cc |
| +++ b/content/browser/renderer_host/websocket_dispatcher_host_unittest.cc |
| @@ -410,5 +410,32 @@ TEST_F(WebSocketDispatcherHostTest, NotRejectedAfter255FailedConnections) { |
| EXPECT_EQ(0, dispatcher_host_->num_succeeded_connections()); |
| } |
| +TEST_F(WebSocketDispatcherHostTest, InvalidScheme) { |
| + int routing_id = 123; |
| + GURL socket_url("http://example.com/test"); |
| + std::vector<std::string> requested_protocols; |
| + requested_protocols.push_back("hello"); |
| + url::Origin origin("http://example.com"); |
| + int render_frame_id = -2; |
| + WebSocketHostMsg_AddChannelRequest message( |
| + routing_id, socket_url, requested_protocols, origin, render_frame_id); |
| + |
| + ASSERT_TRUE(dispatcher_host_->OnMessageReceived(message)); |
| + |
| + ASSERT_EQ(1U, mock_hosts_.size()); |
| + MockWebSocketHost* host = mock_hosts_[0]; |
| + |
| + // Tests that WebSocketHost::OnMessageReceived() doesn't cause a crash and |
| + // the connection with an invalid scheme fails here. |
| + // We call WebSocketHost::OnMessageReceived() here explicitly because |
| + // 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.
|
| + // 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.
|
| + host->WebSocketHost::OnMessageReceived(message); |
| + |
| + EXPECT_EQ(0, dispatcher_host_->num_pending_connections()); |
| + EXPECT_EQ(1, dispatcher_host_->num_failed_connections()); |
| + EXPECT_EQ(0, dispatcher_host_->num_succeeded_connections()); |
| +} |
| + |
| } // namespace |
| } // namespace content |