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

Unified Diff: content/browser/renderer_host/websocket_dispatcher_host_unittest.cc

Issue 1013663002: Revert of Revert of Add WebSocketDispatcherHostTest.InvalidScheme (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..4eb1104bfb7484deb91c7d5cf1fdbaee1dbbb3b0 100644
--- a/content/browser/renderer_host/websocket_dispatcher_host_unittest.cc
+++ b/content/browser/renderer_host/websocket_dispatcher_host_unittest.cc
@@ -410,5 +410,33 @@
EXPECT_EQ(0, dispatcher_host_->num_succeeded_connections());
}
+// This is a regression test for https://crrev.com/998173003/.
+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 does not call WebSocketHost::OnMessageReceived() for
+ // WebSocketHostMsg_AddChannelRequest.
+ 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
« 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