From c30a6232df03e1efbd9f3b226777b07e087a1122 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 12 Oct 2020 14:27:29 +0200 Subject: BASELINE: Update Chromium to 85.0.4183.140 Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057 Reviewed-by: Allan Sandfeld Jensen --- chromium/net/websockets/websocket_channel_test.cc | 251 +++++----------------- 1 file changed, 51 insertions(+), 200 deletions(-) (limited to 'chromium/net/websockets/websocket_channel_test.cc') diff --git a/chromium/net/websockets/websocket_channel_test.cc b/chromium/net/websockets/websocket_channel_test.cc index 07f90d5b23b..b0c3478692a 100644 --- a/chromium/net/websockets/websocket_channel_test.cc +++ b/chromium/net/websockets/websocket_channel_test.cc @@ -131,15 +131,6 @@ const char kBinaryBlob[] = {'\n', '\r', // BACKWARDS CRNL }; const size_t kBinaryBlobSize = base::size(kBinaryBlob); -// The amount of quota a new connection gets by default. -// TODO(ricea): If kDefaultSendQuotaHighWaterMark changes, then this value will -// need to be updated. -const size_t kDefaultInitialQuota = 1 << 17; -// The amount of bytes we need to send after the initial connection to trigger a -// quota refresh. TODO(ricea): Change this if kDefaultSendQuotaHighWaterMark or -// kDefaultSendQuotaLowWaterMark change. -const size_t kDefaultQuotaRefreshTrigger = (1 << 16) + 1; - const int kVeryBigTimeoutMillis = 60 * 60 * 24 * 1000; // TestTimeouts::tiny_timeout() is 100ms! I could run halfway around the world @@ -167,17 +158,16 @@ class MockWebSocketEventInterface : public WebSocketEventInterface { } MOCK_METHOD1(OnCreateURLRequest, void(URLRequest*)); - MOCK_METHOD4(OnAddChannelResponse, + MOCK_METHOD3(OnAddChannelResponse, void(std::unique_ptr response, const std::string&, - const std::string&, - int64_t)); // NOLINT + const std::string&)); // NOLINT MOCK_METHOD3(OnDataFrameVector, void(bool, WebSocketMessageType, const std::vector&)); // NOLINT MOCK_METHOD0(HasPendingDataFrames, bool(void)); // NOLINT - MOCK_METHOD1(OnSendFlowControlQuotaAdded, void(int64_t)); // NOLINT + MOCK_METHOD0(OnSendDataFrameDone, void(void)); // NOLINT MOCK_METHOD0(OnClosingHandshake, void(void)); // NOLINT MOCK_METHOD1(OnFailChannel, void(const std::string&)); // NOLINT MOCK_METHOD3(OnDropChannel, @@ -225,13 +215,12 @@ class FakeWebSocketEventInterface : public WebSocketEventInterface { void OnAddChannelResponse( std::unique_ptr response, const std::string& selected_protocol, - const std::string& extensions, - int64_t send_flow_control_quota) override {} + const std::string& extensions) override {} void OnDataFrame(bool fin, WebSocketMessageType type, base::span data_span) override {} + void OnSendDataFrameDone() override {} bool HasPendingDataFrames() override { return false; } - void OnSendFlowControlQuotaAdded(int64_t quota) override {} void OnClosingHandshake() override {} void OnFailChannel(const std::string& message) override {} void OnDropChannel(bool was_clean, @@ -930,11 +919,12 @@ class WebSocketChannelStreamTest : public WebSocketChannelEventInterfaceTest { // whether these methods are called or not. EXPECT_CALL(*mock_stream_, GetSubProtocol()).Times(AnyNumber()); EXPECT_CALL(*mock_stream_, GetExtensions()).Times(AnyNumber()); - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)) + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)) .Times(AnyNumber()); EXPECT_CALL(*event_interface_, OnDataFrameVector(_, _, _)) .Times(AnyNumber()); EXPECT_CALL(*event_interface_, OnClosingHandshake()).Times(AnyNumber()); + EXPECT_CALL(*event_interface_, OnSendDataFrameDone()).Times(AnyNumber()); EXPECT_CALL(*event_interface_, OnFailChannel(_)).Times(AnyNumber()); EXPECT_CALL(*event_interface_, OnDropChannel(_, _, _)).Times(AnyNumber()); } @@ -961,8 +951,9 @@ class WebSocketChannelSendUtf8Test set_stream(std::make_unique()); // For the purpose of the tests using this fixture, it doesn't matter // whether these methods are called or not. - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)) + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)) .Times(AnyNumber()); + EXPECT_CALL(*event_interface_, OnSendDataFrameDone()).Times(AnyNumber()); } }; @@ -1006,7 +997,7 @@ TEST_F(WebSocketChannelTest, EverythingIsPassedToTheCreatorFunction) { TEST_F(WebSocketChannelEventInterfaceTest, ConnectSuccessReported) { // false means success. - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, "", "", _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, "", "")); CreateChannelAndConnect(); @@ -1031,7 +1022,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, NonWebSocketSchemeRejected) { } TEST_F(WebSocketChannelEventInterfaceTest, ProtocolPassed) { - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, "Bob", "", _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, "Bob", "")); CreateChannelAndConnect(); @@ -1044,7 +1035,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, ProtocolPassed) { TEST_F(WebSocketChannelEventInterfaceTest, ExtensionsPassed) { EXPECT_CALL(*event_interface_, - OnAddChannelResponse(_, "", "extension1, extension2", _)); + OnAddChannelResponse(_, "", "extension1, extension2")); CreateChannelAndConnect(); @@ -1066,7 +1057,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, DataLeftFromHandshake) { set_stream(std::move(stream)); { InSequence s; - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL(*event_interface_, OnDataFrameVector(true, WebSocketFrameHeader::kOpCodeText, AsVector("HELLO"))); @@ -1088,7 +1079,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, CloseAfterHandshake) { set_stream(std::move(stream)); { InSequence s; - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL(*event_interface_, OnClosingHandshake()); EXPECT_CALL( *event_interface_, @@ -1112,7 +1103,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, ShouldCloseWhileNoDataFrames) { Checkpoint checkpoint; { InSequence s; - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL(*event_interface_, HasPendingDataFrames()) .WillOnce(Return(false)) .WillOnce(Return(true)) @@ -1142,7 +1133,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, ConnectionCloseAfterHandshake) { set_stream(std::move(stream)); { InSequence s; - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL(*event_interface_, OnDropChannel(false, kWebSocketErrorAbnormalClosure, _)); } @@ -1161,7 +1152,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, NormalAsyncRead) { set_stream(std::move(stream)); { InSequence s; - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL(checkpoint, Call(1)); EXPECT_CALL(*event_interface_, OnDataFrameVector(true, WebSocketFrameHeader::kOpCodeText, @@ -1188,7 +1179,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, AsyncThenSyncRead) { set_stream(std::move(stream)); { InSequence s; - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL(*event_interface_, OnDataFrameVector(true, WebSocketFrameHeader::kOpCodeText, AsVector("HELLO"))); @@ -1226,7 +1217,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, FragmentedMessage) { set_stream(std::move(stream)); { InSequence s; - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL(*event_interface_, OnDataFrameVector(false, WebSocketFrameHeader::kOpCodeText, AsVector("THREE"))); @@ -1259,7 +1250,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, NullMessage) { {FINAL_FRAME, WebSocketFrameHeader::kOpCodeText, NOT_MASKED, nullptr}}; stream->PrepareReadFrames(ReadableFakeWebSocketStream::SYNC, OK, frames); set_stream(std::move(stream)); - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL( *event_interface_, OnDataFrameVector(true, WebSocketFrameHeader::kOpCodeText, AsVector(""))); @@ -1274,7 +1265,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, AsyncAbnormalClosure) { set_stream(std::move(stream)); { InSequence s; - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL(*event_interface_, OnDropChannel(false, kWebSocketErrorAbnormalClosure, _)); } @@ -1291,7 +1282,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, ConnectionReset) { set_stream(std::move(stream)); { InSequence s; - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL(*event_interface_, OnDropChannel(false, kWebSocketErrorAbnormalClosure, _)); } @@ -1310,7 +1301,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, MaskedFramesAreRejected) { set_stream(std::move(stream)); { InSequence s; - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL( *event_interface_, OnFailChannel( @@ -1331,7 +1322,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, UnknownOpCodeIsRejected) { set_stream(std::move(stream)); { InSequence s; - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL(*event_interface_, OnFailChannel("Unrecognized frame opcode: 4")); } @@ -1360,7 +1351,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, ControlFrameInDataMessage) { set_stream(std::move(stream)); { InSequence s; - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL(*event_interface_, OnDataFrameVector(false, WebSocketFrameHeader::kOpCodeText, AsVector("SPLIT "))); @@ -1382,7 +1373,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, PongWithNullData) { {FINAL_FRAME, WebSocketFrameHeader::kOpCodePong, NOT_MASKED, nullptr}}; stream->PrepareReadFrames(ReadableFakeWebSocketStream::ASYNC, OK, frames); set_stream(std::move(stream)); - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); CreateChannelAndConnectSuccessfully(); base::RunLoop().RunUntilIdle(); @@ -1400,7 +1391,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, FrameAfterInvalidFrame) { set_stream(std::move(stream)); { InSequence s; - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL( *event_interface_, OnFailChannel( @@ -1411,105 +1402,13 @@ TEST_F(WebSocketChannelEventInterfaceTest, FrameAfterInvalidFrame) { base::RunLoop().RunUntilIdle(); } -// If the renderer sends lots of small writes, we don't want to update the quota -// for each one. -TEST_F(WebSocketChannelEventInterfaceTest, SmallWriteDoesntUpdateQuota) { - set_stream(std::make_unique()); - { - InSequence s; - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); - } - - CreateChannelAndConnectSuccessfully(); - EXPECT_EQ(channel_->SendFrame(true, WebSocketFrameHeader::kOpCodeText, - AsIOBuffer("B"), 1U), - WebSocketChannel::CHANNEL_ALIVE); -} - -// If we send enough to go below |send_quota_low_water_mark_| we should get our -// quota refreshed. -TEST_F(WebSocketChannelEventInterfaceTest, LargeWriteUpdatesQuota) { - set_stream(std::make_unique()); - // We use this checkpoint object to verify that the quota update comes after - // the write. - Checkpoint checkpoint; - { - InSequence s; - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); - EXPECT_CALL(checkpoint, Call(1)); - EXPECT_CALL(*event_interface_, OnSendFlowControlQuotaAdded(_)); - EXPECT_CALL(checkpoint, Call(2)); - } - - CreateChannelAndConnectSuccessfully(); - checkpoint.Call(1); - EXPECT_EQ( - channel_->SendFrame(true, WebSocketFrameHeader::kOpCodeText, - AsIOBuffer(std::string(kDefaultInitialQuota, 'B')), - kDefaultInitialQuota), - WebSocketChannel::CHANNEL_ALIVE); - checkpoint.Call(2); -} - -// Verify that our quota actually is refreshed when we are told it is. -TEST_F(WebSocketChannelEventInterfaceTest, QuotaReallyIsRefreshed) { - set_stream(std::make_unique()); - Checkpoint checkpoint; - { - InSequence s; - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); - EXPECT_CALL(checkpoint, Call(1)); - EXPECT_CALL(*event_interface_, OnSendFlowControlQuotaAdded(_)); - EXPECT_CALL(checkpoint, Call(2)); - // If quota was not really refreshed, we would get an OnDropChannel() - // message. - EXPECT_CALL(*event_interface_, OnSendFlowControlQuotaAdded(_)); - EXPECT_CALL(checkpoint, Call(3)); - } - - CreateChannelAndConnectSuccessfully(); - checkpoint.Call(1); - EXPECT_EQ(channel_->SendFrame( - true, WebSocketFrameHeader::kOpCodeText, - AsIOBuffer(std::string(kDefaultQuotaRefreshTrigger, 'D')), - kDefaultQuotaRefreshTrigger), - WebSocketChannel::CHANNEL_ALIVE); - checkpoint.Call(2); - // We should have received more quota at this point. - EXPECT_EQ(channel_->SendFrame( - true, WebSocketFrameHeader::kOpCodeText, - AsIOBuffer(std::string(kDefaultQuotaRefreshTrigger, 'E')), - kDefaultQuotaRefreshTrigger), - WebSocketChannel::CHANNEL_ALIVE); - checkpoint.Call(3); -} - -// If we send more than the available quota then the connection will be closed -// with an error. -TEST_F(WebSocketChannelEventInterfaceTest, WriteOverQuotaIsRejected) { - set_stream(std::make_unique()); - { - InSequence s; - EXPECT_CALL(*event_interface_, - OnAddChannelResponse(_, _, _, kDefaultInitialQuota)); - EXPECT_CALL(*event_interface_, OnFailChannel("Send quota exceeded")); - } - - CreateChannelAndConnectSuccessfully(); - EXPECT_EQ(channel_->SendFrame( - true, WebSocketFrameHeader::kOpCodeText, - AsIOBuffer(std::string(kDefaultInitialQuota + 1, 'C')), - kDefaultInitialQuota + 1), - WebSocketChannel::CHANNEL_DELETED); -} - // If a write fails, the channel is dropped. TEST_F(WebSocketChannelEventInterfaceTest, FailedWrite) { set_stream(std::make_unique()); Checkpoint checkpoint; { InSequence s; - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL(checkpoint, Call(1)); EXPECT_CALL(*event_interface_, OnDropChannel(false, kWebSocketErrorAbnormalClosure, _)); @@ -1530,7 +1429,8 @@ TEST_F(WebSocketChannelEventInterfaceTest, SendCloseDropsChannel) { set_stream(std::make_unique()); { InSequence s; - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); + EXPECT_CALL(*event_interface_, OnSendDataFrameDone()); EXPECT_CALL(*event_interface_, OnDropChannel(true, kWebSocketNormalClosure, "Fred")); } @@ -1557,7 +1457,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, CloseDuringConnection) { // connection reset. TEST_F(WebSocketChannelEventInterfaceTest, OnDropChannelCalledOnce) { set_stream(std::make_unique()); - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL(*event_interface_, OnDropChannel(false, kWebSocketErrorAbnormalClosure, "")) @@ -1581,7 +1481,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, CloseWithNoPayloadGivesStatus1005) { stream->PrepareReadFramesError(ReadableFakeWebSocketStream::SYNC, ERR_CONNECTION_CLOSED); set_stream(std::move(stream)); - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL(*event_interface_, OnClosingHandshake()); EXPECT_CALL(*event_interface_, OnDropChannel(true, kWebSocketErrorNoStatusReceived, _)); @@ -1599,7 +1499,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, stream->PrepareReadFramesError(ReadableFakeWebSocketStream::SYNC, ERR_CONNECTION_CLOSED); set_stream(std::move(stream)); - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL(*event_interface_, OnClosingHandshake()); EXPECT_CALL(*event_interface_, OnDropChannel(true, kWebSocketErrorNoStatusReceived, _)); @@ -1614,7 +1514,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, SyncProtocolErrorGivesStatus1002) { stream->PrepareReadFramesError(ReadableFakeWebSocketStream::SYNC, ERR_WS_PROTOCOL_ERROR); set_stream(std::move(stream)); - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL(*event_interface_, OnFailChannel("Invalid frame header")); @@ -1627,7 +1527,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, AsyncProtocolErrorGivesStatus1002) { stream->PrepareReadFramesError(ReadableFakeWebSocketStream::ASYNC, ERR_WS_PROTOCOL_ERROR); set_stream(std::move(stream)); - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL(*event_interface_, OnFailChannel("Invalid frame header")); CreateChannelAndConnectSuccessfully(); @@ -1637,7 +1537,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, AsyncProtocolErrorGivesStatus1002) { TEST_F(WebSocketChannelEventInterfaceTest, StartHandshakeRequest) { { InSequence s; - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL(*event_interface_, OnStartOpeningHandshakeCalled()); } @@ -1685,7 +1585,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, DataAfterCloseIsRejected) { {FINAL_FRAME, WebSocketFrameHeader::kOpCodeText, NOT_MASKED, "Payload"}}; stream->PrepareReadFrames(ReadableFakeWebSocketStream::SYNC, OK, frames); set_stream(std::move(stream)); - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); { InSequence s; @@ -1705,7 +1605,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, OneByteClosePayloadMessage) { {FINAL_FRAME, WebSocketFrameHeader::kOpCodeClose, NOT_MASKED, "\x03"}}; stream->PrepareReadFrames(ReadableFakeWebSocketStream::SYNC, OK, frames); set_stream(std::move(stream)); - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL( *event_interface_, OnFailChannel( @@ -1723,7 +1623,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, ClosePayloadReservedStatusMessage) { NOT_MASKED, CLOSE_DATA(ABNORMAL_CLOSURE, "Not valid on wire")}}; stream->PrepareReadFrames(ReadableFakeWebSocketStream::SYNC, OK, frames); set_stream(std::move(stream)); - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL( *event_interface_, OnFailChannel( @@ -1741,7 +1641,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, ClosePayloadInvalidReason) { NOT_MASKED, CLOSE_DATA(NORMAL_CLOSURE, "\xFF")}}; stream->PrepareReadFrames(ReadableFakeWebSocketStream::SYNC, OK, frames); set_stream(std::move(stream)); - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL( *event_interface_, OnFailChannel( @@ -1765,7 +1665,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, ReservedBitsMustNotBeSet) { stream->PrepareRawReadFrames(ReadableFakeWebSocketStream::SYNC, OK, std::move(raw_frames)); set_stream(std::move(stream)); - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL(*event_interface_, OnFailChannel( "One or more reserved bits are on: reserved1 = 1, " @@ -1782,7 +1682,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, stream->PrepareReadFramesError(ReadableFakeWebSocketStream::SYNC, ERR_IO_PENDING); set_stream(std::move(stream)); - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); // This checkpoint object verifies that the OnDropChannel message comes after // the timeout. Checkpoint checkpoint; @@ -1818,7 +1718,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, NOT_MASKED, CLOSE_DATA(NORMAL_CLOSURE, "OK")}}; stream->PrepareReadFrames(ReadableFakeWebSocketStream::ASYNC, OK, frames); set_stream(std::move(stream)); - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); Checkpoint checkpoint; TestClosure completion; { @@ -1877,7 +1777,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, SingleFrameMessage) { set_stream(std::move(stream)); { InSequence s; - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL(*event_interface_, OnDataFrameVector(true, WebSocketFrameHeader::kOpCodeText, AsVector("FOUR"))); @@ -1899,7 +1799,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, EmptyMessage) { set_stream(std::move(stream)); { InSequence s; - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL(*event_interface_, OnDataFrameVector(true, WebSocketFrameHeader::kOpCodeText, AsVector("FIRST MESSAGE"))); @@ -1933,7 +1833,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, set_stream(std::move(stream)); Checkpoint checkpoint; InSequence s; - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL(*event_interface_, HasPendingDataFrames()).WillOnce(Return(true)); EXPECT_CALL(checkpoint, Call(1)); EXPECT_CALL(*event_interface_, HasPendingDataFrames()) @@ -2283,26 +2183,6 @@ TEST_F(WebSocketChannelStreamTest, WaitingMessagesAreBatched) { std::move(write_callback).Run(OK); } -// When the renderer sends more on a channel than it has quota for, we send the -// remote server a kWebSocketErrorGoingAway error code. -TEST_F(WebSocketChannelStreamTest, SendGoingAwayOnRendererQuotaExceeded) { - static const InitFrame expected[] = { - {FINAL_FRAME, WebSocketFrameHeader::kOpCodeClose, - MASKED, CLOSE_DATA(GOING_AWAY, "")}}; - EXPECT_CALL(*mock_stream_, ReadFramesInternal(_, _)) - .WillOnce(Return(ERR_IO_PENDING)); - EXPECT_CALL(*mock_stream_, WriteFramesInternal(EqualsFrames(expected), _)) - .WillOnce(Return(OK)); - EXPECT_CALL(*mock_stream_, Close()); - - CreateChannelAndConnectSuccessfully(); - EXPECT_EQ(channel_->SendFrame( - true, WebSocketFrameHeader::kOpCodeText, - AsIOBuffer(std::string(kDefaultInitialQuota + 1, 'C')), - kDefaultInitialQuota + 1), - WebSocketChannel::CHANNEL_DELETED); -} - // For convenience, most of these tests use Text frames. However, the WebSocket // protocol also has Binary frames and those need to be 8-bit clean. For the // sake of completeness, this test verifies that they are. @@ -2345,7 +2225,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, ReadBinaryFramesAre8BitClean) { stream->PrepareRawReadFrames(ReadableFakeWebSocketStream::SYNC, OK, std::move(frames)); set_stream(std::move(stream)); - EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _, _)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL( *event_interface_, OnDataFrameVector( @@ -2477,8 +2357,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, ReceivedInvalidUtf8) { stream->PrepareReadFrames(ReadableFakeWebSocketStream::SYNC, OK, frames); set_stream(std::move(stream)); - EXPECT_CALL(*event_interface_, - OnAddChannelResponse(_, _, _, kDefaultInitialQuota)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL(*event_interface_, OnFailChannel("Could not decode a text frame as UTF-8.")); @@ -2667,8 +2546,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, BogusContinuation) { stream->PrepareReadFrames(ReadableFakeWebSocketStream::SYNC, OK, frames); set_stream(std::move(stream)); - EXPECT_CALL(*event_interface_, - OnAddChannelResponse(_, _, _, kDefaultInitialQuota)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL(*event_interface_, OnDataFrameVector(false, WebSocketFrameHeader::kOpCodeBinary, AsVector("frame1"))); @@ -2689,8 +2567,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, MessageStartingWithContinuation) { stream->PrepareReadFrames(ReadableFakeWebSocketStream::SYNC, OK, frames); set_stream(std::move(stream)); - EXPECT_CALL(*event_interface_, - OnAddChannelResponse(_, _, _, kDefaultInitialQuota)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL(*event_interface_, OnFailChannel("Received unexpected continuation frame.")); @@ -2709,8 +2586,7 @@ TEST_F(WebSocketChannelEventInterfaceTest, DataFramesNonEmptyOrFinal) { stream->PrepareReadFrames(ReadableFakeWebSocketStream::SYNC, OK, frames); set_stream(std::move(stream)); - EXPECT_CALL(*event_interface_, - OnAddChannelResponse(_, _, _, kDefaultInitialQuota)); + EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _, _)); EXPECT_CALL( *event_interface_, OnDataFrameVector(true, WebSocketFrameHeader::kOpCodeText, AsVector(""))); @@ -2925,30 +2801,5 @@ TEST_F(WebSocketChannelStreamTimeoutTest, ConnectionCloseTimesOut) { completion.WaitForResult(); } -// Verify that current_send_quota() returns a non-zero value for a newly -// connected channel. -TEST_F(WebSocketChannelTest, CurrentSendQuotaNonZero) { - CreateChannelAndConnectSuccessfully(); - EXPECT_GT(channel_->current_send_quota(), 0); -} - -// Verify that current_send_quota() is updated when SendFrame() is called. -TEST_F(WebSocketChannelTest, CurrentSendQuotaUpdated) { - const int kMessageSize = 5; - set_stream(std::make_unique()); - CreateChannelAndConnectSuccessfully(); - - int initial_send_quota = channel_->current_send_quota(); - EXPECT_GE(initial_send_quota, kMessageSize); - - EXPECT_EQ(channel_->SendFrame( - true, WebSocketFrameHeader::kOpCodeText, - AsIOBuffer(std::string(static_cast(kMessageSize), 'a')), - static_cast(kMessageSize)), - WebSocketChannel::CHANNEL_ALIVE); - int new_send_quota = channel_->current_send_quota(); - EXPECT_EQ(kMessageSize, initial_send_quota - new_send_quota); -} - } // namespace } // namespace net -- cgit v1.2.1