chromium/third_party/blink/renderer/core/workers/dedicated_worker_test.cc

// Copyright 2016 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/core/workers/dedicated_worker_test.h"

#include <bitset>
#include <cstddef>
#include <memory>

#include "base/functional/bind.h"
#include "base/functional/callback_forward.h"
#include "base/run_loop.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/bind.h"
#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/v8_cache_options.mojom-blink.h"
#include "third_party/blink/public/mojom/worker/dedicated_worker_host.mojom-blink.h"
#include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/renderer/bindings/core/v8/sanitize_script_errors.h"
#include "third_party/blink/renderer/bindings/core/v8/serialization/post_message_helper.h"
#include "third_party/blink/renderer/bindings/core/v8/serialization/serialized_script_value.h"
#include "third_party/blink/renderer/bindings/core/v8/serialization/unpacked_serialized_script_value.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_testing.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_message_port.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_post_message_options.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_worker_options.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/event_type_names.h"
#include "third_party/blink/renderer/core/events/message_event.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/inspector/thread_debugger_common_impl.h"
#include "third_party/blink/renderer/core/messaging/blink_transferable_message.h"
#include "third_party/blink/renderer/core/messaging/message_channel.h"
#include "third_party/blink/renderer/core/messaging/message_port.h"
#include "third_party/blink/renderer/core/script/script.h"
#include "third_party/blink/renderer/core/testing/page_test_base.h"
#include "third_party/blink/renderer/core/testing/wait_for_event.h"
#include "third_party/blink/renderer/core/workers/custom_event_message.h"
#include "third_party/blink/renderer/core/workers/dedicated_worker.h"
#include "third_party/blink/renderer/core/workers/dedicated_worker_global_scope.h"
#include "third_party/blink/renderer/core/workers/dedicated_worker_messaging_proxy.h"
#include "third_party/blink/renderer/core/workers/dedicated_worker_object_proxy.h"
#include "third_party/blink/renderer/core/workers/dedicated_worker_thread.h"
#include "third_party/blink/renderer/core/workers/global_scope_creation_params.h"
#include "third_party/blink/renderer/core/workers/parent_execution_context_task_runners.h"
#include "third_party/blink/renderer/core/workers/worker_backing_thread_startup_data.h"
#include "third_party/blink/renderer/core/workers/worker_thread.h"
#include "third_party/blink/renderer/core/workers/worker_thread_test_helper.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/heap/visitor.h"
#include "third_party/blink/renderer/platform/scheduler/public/post_cross_thread_task.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin.h"
#include "third_party/blink/renderer/platform/weborigin/security_policy.h"
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
#include "third_party/blink/renderer/platform/wtf/functional.h"
#include "v8-value.h"

namespace blink {

namespace {

constexpr char kCustomEventName[] =;
constexpr char kCustomErrorEventName[] =;

class CustomEventWithData final : public Event {};

ScriptValue CreateStringScriptValue(ScriptState* script_state,
                                    const String& str) {}

CrossThreadFunction<Event*(ScriptState*, CustomEventMessage)>
CustomEventFactoryCallback(base::RepeatingClosure quit_closure,
                           CustomEventWithData** out_event = nullptr) {}

CrossThreadFunction<Event*(ScriptState*)> CustomEventFactoryErrorCallback(
    base::RepeatingClosure quit_closure,
    Event** out_event = nullptr) {}

CrossThreadFunction<Event*(ScriptState*, CustomEventMessage)>
CustomEventWithPortsFactoryCallback(base::RepeatingClosure quit_closure,
                                    CustomEventWithData** out_event = nullptr) {}

}  // namespace

class DedicatedWorkerThreadForTest final : public DedicatedWorkerThread {};

class DedicatedWorkerObjectProxyForTest final
    : public DedicatedWorkerObjectProxy {};

class DedicatedWorkerMessagingProxyForTest
    : public DedicatedWorkerMessagingProxy {};

class FakeWebDedicatedWorkerHostFactoryClient
    : public WebDedicatedWorkerHostFactoryClient {};

class FakeWebDedicatedWorkerHostFactoryClientPlatformSupport
    : public TestingPlatformSupport {};

void DedicatedWorkerTest::SetUp() {}

void DedicatedWorkerTest::TearDown() {}

DedicatedWorkerMessagingProxyForTest*
DedicatedWorkerTest::WorkerMessagingProxy() {}

DedicatedWorkerThreadForTest* DedicatedWorkerTest::GetWorkerThread() {}

void DedicatedWorkerTest::StartWorker(
    std::unique_ptr<GlobalScopeCreationParams> params) {}

void DedicatedWorkerTest::EvaluateClassicScript(const String& source_code) {}

namespace {

void PostExitRunLoopTaskOnParent(WorkerThread* worker_thread,
                                 CrossThreadOnceClosure quit_closure) {}

}  // anonymous namespace

void DedicatedWorkerTest::WaitUntilWorkerIsRunning() {}

TEST_F(DedicatedWorkerTest, PendingActivity_NoActivityAfterContextDestroyed) {}

TEST_F(DedicatedWorkerTest, UseCounter) {}

TEST_F(DedicatedWorkerTest, TaskRunner) {}

namespace {

BlinkTransferableMessage MakeTransferableMessage(
    base::UnguessableToken agent_cluster_id) {}

}  // namespace

TEST_F(DedicatedWorkerTest, DispatchMessageEventOnWorkerObject) {}

TEST_F(DedicatedWorkerTest,
       DispatchMessageEventOnWorkerObject_CannotDeserialize) {}

TEST_F(DedicatedWorkerTest, DispatchMessageEventOnWorkerGlobalScope) {}

TEST_F(DedicatedWorkerTest, TopLevelFrameSecurityOrigin) {}

TEST_F(DedicatedWorkerTest,
       DispatchMessageEventOnWorkerGlobalScope_CannotDeserialize) {}

TEST_F(DedicatedWorkerTest, PostCustomEventWithString) {}

TEST_F(DedicatedWorkerTest, PostCustomEventWithNumber) {}

TEST_F(DedicatedWorkerTest, PostCustomEventBeforeWorkerStarts) {}

TEST_F(DedicatedWorkerTest, PostCustomEventWithPort) {}

TEST_F(DedicatedWorkerTest, PostCustomEventCannotDeserialize) {}

TEST_F(DedicatedWorkerTest, PostCustomEventNoMessage) {}

}  // namespace blink