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

Unified Diff: net/websockets/websocket_channel_test.cc

Issue 177403002: net::WebSocketChannel should reject reserved bits (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix typo. Created 6 years, 10 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 | « net/websockets/websocket_channel.cc ('k') | net/websockets/websocket_stream.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/websockets/websocket_channel_test.cc
diff --git a/net/websockets/websocket_channel_test.cc b/net/websockets/websocket_channel_test.cc
index 81c2f29e15976fa7d4f5faa74b5720caf2904465..f9f3a9302f0ae22ad59f9e15096945d6672ea90f 100644
--- a/net/websockets/websocket_channel_test.cc
+++ b/net/websockets/websocket_channel_test.cc
@@ -2075,6 +2075,30 @@ TEST_F(WebSocketChannelEventInterfaceTest, ClosePayloadInvalidReason) {
CreateChannelAndConnectSuccessfully();
}
+// The reserved bits must all be clear on received frames. Extensions should
+// clear the bits when they are set correctly before passing on the frame.
+TEST_F(WebSocketChannelEventInterfaceTest, ReservedBitsMustNotBeSet) {
+ scoped_ptr<ReadableFakeWebSocketStream> stream(
+ new ReadableFakeWebSocketStream);
+ static const InitFrame frames[] = {
+ {FINAL_FRAME, WebSocketFrameHeader::kOpCodeText,
+ NOT_MASKED, "sakana"}};
+ // It is not worth adding support for reserved bits to InitFrame just for this
+ // one test, so set the bit manually.
+ ScopedVector<WebSocketFrame> raw_frames = CreateFrameVector(frames);
+ raw_frames[0]->header.reserved1 = true;
+ stream->PrepareRawReadFrames(
+ ReadableFakeWebSocketStream::SYNC, OK, raw_frames.Pass());
+ set_stream(stream.Pass());
+ EXPECT_CALL(*event_interface_, OnAddChannelResponse(false, _, _));
+ EXPECT_CALL(*event_interface_, OnFlowControl(_));
+ EXPECT_CALL(
+ *event_interface_,
+ OnFailChannel("Received a frame with an invalid reserved bit set."));
+
+ CreateChannelAndConnectSuccessfully();
+}
+
// The closing handshake times out and sends an OnDropChannel event if no
// response to the client Close message is received.
TEST_F(WebSocketChannelEventInterfaceTest,
« no previous file with comments | « net/websockets/websocket_channel.cc ('k') | net/websockets/websocket_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698