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

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

Issue 1007263002: 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 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 // This is a regression test for https://crrev.com/998173003/.
414 TEST_F(WebSocketDispatcherHostTest, InvalidScheme) {
415 int routing_id = 123;
416 GURL socket_url("http://example.com/test");
417 std::vector<std::string> requested_protocols;
418 requested_protocols.push_back("hello");
419 url::Origin origin("http://example.com");
420 int render_frame_id = -2;
421 WebSocketHostMsg_AddChannelRequest message(
422 routing_id, socket_url, requested_protocols, origin, render_frame_id);
423
424 ASSERT_TRUE(dispatcher_host_->OnMessageReceived(message));
425
426 ASSERT_EQ(1U, mock_hosts_.size());
427 MockWebSocketHost* host = mock_hosts_[0];
428
429 // Tests that WebSocketHost::OnMessageReceived() doesn't cause a crash and
430 // the connection with an invalid scheme fails here.
431 // We call WebSocketHost::OnMessageReceived() here explicitly because
432 // MockWebSocketHost does not call WebSocketHost::OnMessageReceived() for
433 // WebSocketHostMsg_AddChannelRequest.
434 host->WebSocketHost::OnMessageReceived(message);
435
436 EXPECT_EQ(0, dispatcher_host_->num_pending_connections());
437 EXPECT_EQ(1, dispatcher_host_->num_failed_connections());
438 EXPECT_EQ(0, dispatcher_host_->num_succeeded_connections());
439 }
440
441 } // namespace 413 } // namespace
442 } // namespace content 414 } // 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