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

Unified Diff: Source/modules/websockets/WebSocketPerMessageDeflateTest.cpp

Issue 314043002: [WebSocket] Add tests for permessage deflate split frames. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 6 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
Index: Source/modules/websockets/WebSocketPerMessageDeflateTest.cpp
diff --git a/Source/modules/websockets/WebSocketPerMessageDeflateTest.cpp b/Source/modules/websockets/WebSocketPerMessageDeflateTest.cpp
index 9972a7e8732f0de0622371a6a1416412d16305e9..d221e7c8ba36d6648d35cd4ccc87d9bdcada59c8 100644
--- a/Source/modules/websockets/WebSocketPerMessageDeflateTest.cpp
+++ b/Source/modules/websockets/WebSocketPerMessageDeflateTest.cpp
@@ -292,6 +292,31 @@ TEST(WebSocketPerMessageDeflateTest, TestInflate)
EXPECT_TRUE(f3.final);
}
+TEST(WebSocketPerMessageDeflateTest, TestInflateMultipleBlocksOverMultipleFrames)
+{
+ WebSocketPerMessageDeflate c;
+ c.enable(8, WebSocketDeflater::TakeOverContext);
+ WebSocketFrame::OpCode opcode = WebSocketFrame::OpCodeText;
+ WebSocketFrame::OpCode continuation = WebSocketFrame::OpCodeContinuation;
+ std::string expected = "HelloHello";
+ std::string actual;
+ WebSocketFrame f1(opcode, "\xf2\x48\xcd\xc9\xc9\x07\x00\x00\x00\xff\xff", 11, WebSocketFrame::Compress);
+ WebSocketFrame f2(continuation, "\xf2\x00\x11\x00\x00", 5, WebSocketFrame::Final);
+
+ ASSERT_TRUE(c.inflate(f1));
+ EXPECT_FALSE(f1.compress);
+ EXPECT_FALSE(f1.final);
+ actual += std::string(f1.payload, f1.payloadLength);
+
+ c.resetInflateBuffer();
+ ASSERT_TRUE(c.inflate(f2));
+ EXPECT_FALSE(f2.compress);
+ EXPECT_TRUE(f2.final);
+ actual += std::string(f2.payload, f2.payloadLength);
+
+ EXPECT_EQ(expected, actual);
+}
+
TEST(WebSocketPerMessageDeflateTest, TestInflateEmptyFrame)
{
WebSocketPerMessageDeflate c;

Powered by Google App Engine
This is Rietveld 408576698