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

Unified Diff: net/websockets/websocket_channel_test.cc

Issue 2845033002: Avoid sending double responding close control frames in WebSockets (Closed)
Patch Set: const -> constexpr Created 3 years, 8 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') | no next file » | 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 7a50c41cbe4b4f21ebd7021492000c940353d50d..d5ceae8e478f282f7646ddb5eedff6c0392cdb73 100644
--- a/net/websockets/websocket_channel_test.cc
+++ b/net/websockets/websocket_channel_test.cc
@@ -2542,6 +2542,39 @@ TEST_F(WebSocketChannelFlowControlTest, CloseFrameShouldNotOvertakeDataFrames) {
checkpoint.Call(4);
}
+// SendFlowControl calls should not trigger multiple close respond frames.
+TEST_F(WebSocketChannelFlowControlTest, DoNotSendMultipleCloseRespondFrames) {
+ std::unique_ptr<ReadableFakeWebSocketStream> stream(
+ new ReadableFakeWebSocketStream);
+ static constexpr InitFrame frames[] = {
+ {FINAL_FRAME, WebSocketFrameHeader::kOpCodeText, NOT_MASKED,
+ "FIRST SECOND"},
+ {FINAL_FRAME, WebSocketFrameHeader::kOpCodeClose, NOT_MASKED,
+ CLOSE_DATA(NORMAL_CLOSURE, "GOOD BYE")},
+ };
+ stream->PrepareReadFrames(ReadableFakeWebSocketStream::SYNC, OK, frames);
+ set_stream(std::move(stream));
+ Checkpoint checkpoint;
+ InSequence s;
+ EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _));
+ EXPECT_CALL(*event_interface_, OnFlowControl(_));
+ EXPECT_CALL(*event_interface_,
+ OnDataFrameVector(false, WebSocketFrameHeader::kOpCodeText,
+ AsVector("FIRST ")));
+ EXPECT_CALL(checkpoint, Call(1));
+ EXPECT_CALL(*event_interface_,
+ OnDataFrameVector(true, WebSocketFrameHeader::kOpCodeContinuation,
+ AsVector("SECOND")));
+ EXPECT_CALL(*event_interface_, OnClosingHandshake());
+ EXPECT_CALL(checkpoint, Call(2));
+
+ CreateChannelAndConnectWithQuota(6);
+ checkpoint.Call(1);
+ ASSERT_EQ(CHANNEL_ALIVE, channel_->SendFlowControl(6));
+ checkpoint.Call(2);
+ ASSERT_EQ(CHANNEL_ALIVE, channel_->SendFlowControl(6));
+}
+
// RFC6455 5.1 "a client MUST mask all frames that it sends to the server".
// WebSocketChannel actually only sets the mask bit in the header, it doesn't
// perform masking itself (not all transports actually use masking).
« no previous file with comments | « net/websockets/websocket_channel.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698