diff options
author | yhirano@chromium.org <yhirano@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-16 17:09:19 +0000 |
---|---|---|
committer | yhirano@chromium.org <yhirano@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-16 17:09:19 +0000 |
commit | d0f628f2312a855b936772095ead5285d9785dde (patch) | |
tree | 88dbeeca9404eb578d4dfd76c6370a4576c320a0 /net/websockets/websocket_deflate_stream_test.cc | |
parent | fcf3880e1654c58a8cec516b23aa98f28b97bf21 (diff) | |
download | chromium_src-d0f628f2312a855b936772095ead5285d9785dde.zip chromium_src-d0f628f2312a855b936772095ead5285d9785dde.tar.gz chromium_src-d0f628f2312a855b936772095ead5285d9785dde.tar.bz2 |
Fix incorrect FIN condition in WebSocketDeflateStream.
WebSocketDeflaterStream handles an incoming frame as final when the internal
inflater becomes empty.
BUG=363964
R=ricea@chromium.org
Review URL: https://codereview.chromium.org/240183002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@264227 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/websockets/websocket_deflate_stream_test.cc')
-rw-r--r-- | net/websockets/websocket_deflate_stream_test.cc | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/net/websockets/websocket_deflate_stream_test.cc b/net/websockets/websocket_deflate_stream_test.cc index 6d29a2b..a8b4e59 100644 --- a/net/websockets/websocket_deflate_stream_test.cc +++ b/net/websockets/websocket_deflate_stream_test.cc @@ -733,6 +733,47 @@ TEST_F(WebSocketDeflateStreamTest, SplitToMultipleFramesInReadFrames) { ToString(frames[0]) + ToString(frames[1]) + ToString(frames[2])); } +TEST_F(WebSocketDeflateStreamTest, InflaterInternalDataCanBeEmpty) { + WebSocketDeflater deflater(WebSocketDeflater::TAKE_OVER_CONTEXT); + deflater.Initialize(kWindowBits); + const std::string original_data(kChunkSize, 'a'); + deflater.AddBytes(original_data.data(), original_data.size()); + deflater.Finish(); + + ScopedVector<WebSocketFrame> frames_to_output; + AppendTo(&frames_to_output, + WebSocketFrameHeader::kOpCodeBinary, + kReserved1, + ToString(deflater.GetOutput(deflater.CurrentOutputSize()))); + AppendTo(&frames_to_output, + WebSocketFrameHeader::kOpCodeBinary, + kFinal, + ""); + + ReadFramesStub stub(OK, &frames_to_output); + CompletionCallback callback; + ScopedVector<WebSocketFrame> frames; + { + InSequence s; + EXPECT_CALL(*mock_stream_, ReadFrames(&frames, _)) + .WillOnce(Invoke(&stub, &ReadFramesStub::Call)); + } + + ASSERT_EQ(OK, deflate_stream_->ReadFrames(&frames, callback)); + ASSERT_EQ(2u, frames.size()); + EXPECT_EQ(WebSocketFrameHeader::kOpCodeBinary, frames[0]->header.opcode); + EXPECT_FALSE(frames[0]->header.final); + EXPECT_FALSE(frames[0]->header.reserved1); + EXPECT_EQ(kChunkSize, static_cast<size_t>(frames[0]->header.payload_length)); + + EXPECT_EQ(WebSocketFrameHeader::kOpCodeContinuation, + frames[1]->header.opcode); + EXPECT_TRUE(frames[1]->header.final); + EXPECT_FALSE(frames[1]->header.reserved1); + EXPECT_EQ(0u, static_cast<size_t>(frames[1]->header.payload_length)); + EXPECT_EQ(original_data, ToString(frames[0]) + ToString(frames[1])); +} + TEST_F(WebSocketDeflateStreamTest, Reserved1TurnsOnDuringReadingCompressedContinuationFrame) { const std::string data1("\xf2\x48\xcd", 3); |