chromium/extensions/renderer/api/messaging/gin_port_unittest.cc

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

#include "extensions/renderer/api/messaging/gin_port.h"

#include <optional>
#include <string_view>

#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "content/public/common/content_features.h"
#include "extensions/common/api/messaging/message.h"
#include "extensions/common/api/messaging/port_id.h"
#include "extensions/common/mojom/message_port.mojom-shared.h"
#include "extensions/renderer/bindings/api_binding_test.h"
#include "extensions/renderer/bindings/api_binding_test_util.h"
#include "extensions/renderer/bindings/api_event_handler.h"
#include "gin/data_object_builder.h"
#include "gin/handle.h"
#include "testing/gmock/include/gmock/gmock.h"

namespace extensions {

namespace {

const char kDefaultPortName[] =;

// Stub delegate for testing.
class TestPortDelegate : public GinPort::Delegate {};

class GinPortTest : public APIBindingTest {};

}  // namespace

// Tests getting the port's name.
TEST_F(GinPortTest, TestGetName) {}

// Tests dispatching a message through the port to JS listeners.
TEST_F(GinPortTest, TestDispatchMessage) {}

// Tests posting a message from JS.
TEST_F(GinPortTest, TestPostMessage) {}

// Tests that calling Disconnect() notifies any listeners of the onDisconnect
// event and then closes the port.
TEST_F(GinPortTest, TestNativeDisconnect) {}

// Tests calling disconnect() from JS.
TEST_F(GinPortTest, TestJSDisconnect) {}

// Tests that a call of disconnect() from the listener of the onDisconnect event
// is rejected. Regression test for crbug.com/932347.
TEST_F(GinPortTest, JSDisconnectFromOnDisconnect) {}

// Tests that a call of postMessage() from the listener of the onDisconnect
// event is rejected. Regression test for crbug.com/932347.
TEST_F(GinPortTest, JSPostMessageFromOnDisconnect) {}

// Tests setting and getting the 'sender' property.
TEST_F(GinPortTest, TestSenderProperty) {}

TEST_F(GinPortTest, TryUsingPortAfterInvalidation) {}

TEST_F(GinPortTest, AlteringPortName) {}

}  // namespace extensions