chromium/third_party/blink/renderer/modules/websockets/dom_websocket_test.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/renderer/modules/websockets/dom_websocket.h"

#include <memory>
#include <string>

#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/mojom/devtools/console_message.mojom-blink.h"
#include "third_party/blink/public/mojom/frame/lifecycle.mojom-blink.h"
#include "third_party/blink/public/mojom/security_context/insecure_request_policy.mojom-blink.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_testing.h"
#include "third_party/blink/renderer/core/execution_context/security_context.h"
#include "third_party/blink/renderer/core/fileapi/blob.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/testing/dummy_page_holder.h"
#include "third_party/blink/renderer/core/typed_arrays/dom_typed_array.h"
#include "third_party/blink/renderer/modules/websockets/mock_websocket_channel.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/heap/thread_state.h"
#include "third_party/blink/renderer/platform/testing/task_environment.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
#include "v8/include/v8.h"

_;
AnyNumber;
InSequence;
Ref;
Return;

namespace blink {

namespace {

Checkpoint;  // NOLINT

class DOMWebSocketWithMockChannel final : public DOMWebSocket {};

class DOMWebSocketTestScope {};

TEST(DOMWebSocketTest, connectToBadURL) {}

TEST(DOMWebSocketTest, connectToNonWsURL) {}

TEST(DOMWebSocketTest, connectToURLHavingFragmentIdentifier) {}

// FIXME: Add a test for Content Security Policy.

TEST(DOMWebSocketTest, invalidSubprotocols) {}

TEST(DOMWebSocketTest, insecureRequestsUpgrade) {}

TEST(DOMWebSocketTest, insecureRequestsUpgradePotentiallyTrustworthy) {}

TEST(DOMWebSocketTest, insecureRequestsDoNotUpgrade) {}

TEST(DOMWebSocketTest, channelConnectSuccess) {}

TEST(DOMWebSocketTest, channelConnectFail) {}

TEST(DOMWebSocketTest, connectSuccess) {}

TEST(DOMWebSocketTest, didClose) {}

TEST(DOMWebSocketTest, maximumReasonSize) {}

TEST(DOMWebSocketTest, reasonSizeExceeding) {}

TEST(DOMWebSocketTest, closeWhenConnecting) {}

TEST(DOMWebSocketTest, close) {}

TEST(DOMWebSocketTest, closeWithoutReason) {}

TEST(DOMWebSocketTest, closeWithoutCodeAndReason) {}

TEST(DOMWebSocketTest, closeWhenClosing) {}

TEST(DOMWebSocketTest, closeWhenClosed) {}

TEST(DOMWebSocketTest, sendStringWhenConnecting) {}

TEST(DOMWebSocketTest, sendStringWhenClosing) {}

TEST(DOMWebSocketTest, sendStringWhenClosed) {}

TEST(DOMWebSocketTest, sendStringSuccess) {}

TEST(DOMWebSocketTest, sendNonLatin1String) {}

TEST(DOMWebSocketTest, sendArrayBufferWhenConnecting) {}

TEST(DOMWebSocketTest, sendArrayBufferWhenClosing) {}

TEST(DOMWebSocketTest, sendArrayBufferWhenClosed) {}

TEST(DOMWebSocketTest, sendArrayBufferSuccess) {}

// FIXME: We should have Blob tests here.
// We can't create a Blob because the blob registration cannot be mocked yet.

TEST(DOMWebSocketTest, bufferedAmountUpdated) {}

TEST(DOMWebSocketTest, bufferedAmountUpdatedBeforeOnMessage) {}

// FIXME: We should add tests for data receiving.

TEST(DOMWebSocketTest, binaryType) {}

// FIXME: We should add tests for suspend / resume.

class DOMWebSocketValidClosingTest : public testing::TestWithParam<uint16_t> {};

TEST_P(DOMWebSocketValidClosingTest, test) {}

INSTANTIATE_TEST_SUITE_P();

class DOMWebSocketInvalidClosingCodeTest
    : public testing::TestWithParam<uint16_t> {};

TEST_P(DOMWebSocketInvalidClosingCodeTest, test) {}

INSTANTIATE_TEST_SUITE_P();

TEST(DOMWebSocketTest, GCWhileEventsPending) {}

}  // namespace

}  // namespace blink