#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "net/websockets/websocket_basic_stream.h"
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <iterator>
#include <optional>
#include <utility>
#include "base/containers/heap_array.h"
#include "base/containers/span.h"
#include "base/numerics/byte_conversions.h"
#include "base/time/time.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
#include "net/base/network_anonymization_key.h"
#include "net/base/privacy_mode.h"
#include "net/base/request_priority.h"
#include "net/base/test_completion_callback.h"
#include "net/dns/public/secure_dns_policy.h"
#include "net/socket/client_socket_handle.h"
#include "net/socket/client_socket_pool.h"
#include "net/socket/connect_job.h"
#include "net/socket/socket_tag.h"
#include "net/socket/socket_test_util.h"
#include "net/test/gtest_util.h"
#include "net/test/test_with_task_environment.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/scheme_host_port.h"
#include "url/url_constants.h"
IsError;
IsOk;
namespace net {
namespace {
#define WEBSOCKET_BASIC_STREAM_TEST_DEFINE_CONSTANT(name, value) …
WEBSOCKET_BASIC_STREAM_TEST_DEFINE_CONSTANT(…);
WEBSOCKET_BASIC_STREAM_TEST_DEFINE_CONSTANT(…);
constexpr size_t kLargeFrameHeaderSize = …;
WEBSOCKET_BASIC_STREAM_TEST_DEFINE_CONSTANT(…);
WEBSOCKET_BASIC_STREAM_TEST_DEFINE_CONSTANT(…);
WEBSOCKET_BASIC_STREAM_TEST_DEFINE_CONSTANT(…);
WEBSOCKET_BASIC_STREAM_TEST_DEFINE_CONSTANT(…);
WEBSOCKET_BASIC_STREAM_TEST_DEFINE_CONSTANT(…);
WEBSOCKET_BASIC_STREAM_TEST_DEFINE_CONSTANT(…);
WEBSOCKET_BASIC_STREAM_TEST_DEFINE_CONSTANT(…);
WEBSOCKET_BASIC_STREAM_TEST_DEFINE_CONSTANT(…);
WEBSOCKET_BASIC_STREAM_TEST_DEFINE_CONSTANT(…);
WEBSOCKET_BASIC_STREAM_TEST_DEFINE_CONSTANT(…);
WEBSOCKET_BASIC_STREAM_TEST_DEFINE_CONSTANT(…);
WEBSOCKET_BASIC_STREAM_TEST_DEFINE_CONSTANT(…);
constexpr WebSocketMaskingKey kNulMaskingKey = …;
constexpr WebSocketMaskingKey kNonNulMaskingKey = …;
WebSocketMaskingKey GenerateNulMaskingKey() { … }
WebSocketMaskingKey GenerateNonNulMaskingKey() { … }
class StrictStaticSocketDataProvider : public StaticSocketDataProvider { … };
class WebSocketBasicStreamSocketTest : public TestWithTaskEnvironment { … };
class WebSocketBasicStreamSocketSingleReadTest
: public WebSocketBasicStreamSocketTest { … };
class WebSocketBasicStreamSocketChunkedReadTest
: public WebSocketBasicStreamSocketTest { … };
class WebSocketBasicStreamSocketWriteTest
: public WebSocketBasicStreamSocketTest { … };
class WebSocketBasicStreamSwitchTest : public WebSocketBasicStreamSocketTest { … };
TEST_F(WebSocketBasicStreamSocketTest, ConstructionWorks) { … }
TEST_F(WebSocketBasicStreamSocketSingleReadTest, SyncReadWorks) { … }
TEST_F(WebSocketBasicStreamSocketSingleReadTest, AsyncReadWorks) { … }
TEST_F(WebSocketBasicStreamSocketChunkedReadTest, HeaderFragmentedSync) { … }
TEST_F(WebSocketBasicStreamSocketChunkedReadTest, HeaderFragmentedAsync) { … }
TEST_F(WebSocketBasicStreamSocketTest, HeaderFragmentedSyncAsync) { … }
TEST_F(WebSocketBasicStreamSocketTest, FragmentedLargeHeader) { … }
TEST_F(WebSocketBasicStreamSocketSingleReadTest, LargeFrameFirstChunk) { … }
TEST_F(WebSocketBasicStreamSocketSingleReadTest, HeaderOnlyChunk) { … }
TEST_F(WebSocketBasicStreamSocketTest, HeaderBodySeparated) { … }
TEST_F(WebSocketBasicStreamSocketChunkedReadTest, LargeFrameTwoChunks) { … }
TEST_F(WebSocketBasicStreamSocketChunkedReadTest, OnlyFinalChunkIsFinal) { … }
TEST_F(WebSocketBasicStreamSocketChunkedReadTest, ContinuationOpCodeUsed) { … }
TEST_F(WebSocketBasicStreamSocketSingleReadTest, ThreeFramesTogether) { … }
TEST_F(WebSocketBasicStreamSocketSingleReadTest, SyncClose) { … }
TEST_F(WebSocketBasicStreamSocketSingleReadTest, AsyncClose) { … }
TEST_F(WebSocketBasicStreamSocketSingleReadTest, SyncCloseWithErr) { … }
TEST_F(WebSocketBasicStreamSocketSingleReadTest, AsyncCloseWithErr) { … }
TEST_F(WebSocketBasicStreamSocketSingleReadTest, SyncErrorsPassedThrough) { … }
TEST_F(WebSocketBasicStreamSocketSingleReadTest, AsyncErrorsPassedThrough) { … }
TEST_F(WebSocketBasicStreamSocketChunkedReadTest, CloseAfterFrame) { … }
TEST_F(WebSocketBasicStreamSocketTest, AsyncCloseAfterIncompleteHeader) { … }
TEST_F(WebSocketBasicStreamSocketTest, AsyncErrCloseAfterIncompleteHeader) { … }
TEST_F(WebSocketBasicStreamSocketSingleReadTest, EmptyFirstFrame) { … }
TEST_F(WebSocketBasicStreamSocketTest, EmptyMiddleFrame) { … }
TEST_F(WebSocketBasicStreamSocketTest, EmptyMiddleFrameAsync) { … }
TEST_F(WebSocketBasicStreamSocketSingleReadTest, EmptyFinalFrame) { … }
TEST_F(WebSocketBasicStreamSocketTest, ThreeFrameEmptyMessage) { … }
TEST_F(WebSocketBasicStreamSocketTest, HttpReadBufferIsUsed) { … }
TEST_F(WebSocketBasicStreamSocketSingleReadTest,
PartialFrameHeaderInHttpResponse) { … }
TEST_F(WebSocketBasicStreamSocketSingleReadTest,
PartialControlFrameInHttpResponse) { … }
TEST_F(WebSocketBasicStreamSocketSingleReadTest,
PartialControlFrameInHttpResponseSync) { … }
TEST_F(WebSocketBasicStreamSocketSingleReadTest, SyncInvalidFrame) { … }
TEST_F(WebSocketBasicStreamSocketSingleReadTest, AsyncInvalidFrame) { … }
TEST_F(WebSocketBasicStreamSocketSingleReadTest, ControlFrameWithoutFin) { … }
TEST_F(WebSocketBasicStreamSocketSingleReadTest, OverlongControlFrame) { … }
TEST_F(WebSocketBasicStreamSocketChunkedReadTest, SplitOverlongControlFrame) { … }
TEST_F(WebSocketBasicStreamSocketChunkedReadTest,
AsyncSplitOverlongControlFrame) { … }
TEST_F(WebSocketBasicStreamSocketChunkedReadTest, SyncControlFrameAssembly) { … }
TEST_F(WebSocketBasicStreamSocketChunkedReadTest, AsyncControlFrameAssembly) { … }
TEST_F(WebSocketBasicStreamSocketChunkedReadTest, OneMegFrame) { … }
TEST_F(WebSocketBasicStreamSocketChunkedReadTest, ReservedFlagCleared) { … }
TEST_F(WebSocketBasicStreamSocketWriteTest, WriteAtOnce) { … }
TEST_F(WebSocketBasicStreamSocketWriteTest, AsyncWriteAtOnce) { … }
TEST_F(WebSocketBasicStreamSocketWriteTest, WriteInBits) { … }
TEST_F(WebSocketBasicStreamSocketWriteTest, WriteNullptrPong) { … }
TEST_F(WebSocketBasicStreamSocketTest, WriteNonNulMask) { … }
TEST_F(WebSocketBasicStreamSocketTest, GetExtensionsWorks) { … }
TEST_F(WebSocketBasicStreamSocketTest, GetSubProtocolWorks) { … }
TEST_F(WebSocketBasicStreamSwitchTest, GetInitialReadBufferSize) { … }
TEST_F(WebSocketBasicStreamSwitchTest, ZeroSecondRead) { … }
TEST_F(WebSocketBasicStreamSwitchTest, CheckSwitch) { … }
}
}