chromium/v8/test/unittests/execution/microtask-queue-unittest.cc

// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "src/execution/microtask-queue.h"

#include <algorithm>
#include <functional>
#include <memory>
#include <vector>

#include "include/v8-function.h"
#include "src/heap/factory.h"
#include "src/objects/foreign.h"
#include "src/objects/js-array-inl.h"
#include "src/objects/js-objects-inl.h"
#include "src/objects/objects-inl.h"
#include "src/objects/promise-inl.h"
#include "src/objects/visitors.h"
#include "test/unittests/test-utils.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace v8 {
namespace internal {

Closure;

void RunStdFunction(void* data) {}

template <typename TMixin>
class WithFinalizationRegistryMixin : public TMixin {};

template <typename TMixin>
SaveFlags* WithFinalizationRegistryMixin<TMixin>::save_flags_ =;

using TestWithNativeContextAndFinalizationRegistry =  //
    WithInternalIsolateMixin<                         //
        WithContextMixin<                             //
            WithFinalizationRegistryMixin<            //
                WithIsolateScopeMixin<                //
                    WithIsolateMixin<                 //
                        WithDefaultPlatformMixin<     //
                            ::testing::Test>>>>>>;

namespace {

void DummyPromiseHook(PromiseHookType type, Local<Promise> promise,
                      Local<Value> parent) {}

}  // namespace

class MicrotaskQueueTest : public TestWithNativeContextAndFinalizationRegistry,
                           public ::testing::WithParamInterface<bool> {};

class RecordingVisitor : public RootVisitor {};

// Sanity check. Ensure a microtask is stored in a queue and run.
TEST_P(MicrotaskQueueTest, EnqueueAndRun) {}

// Check for a buffer growth.
TEST_P(MicrotaskQueueTest, BufferGrowth) {}

// MicrotaskQueue instances form a doubly linked list.
TEST_P(MicrotaskQueueTest, InstanceChain) {}

// Pending Microtasks in MicrotaskQueues are strong roots. Ensure they are
// visited exactly once.
TEST_P(MicrotaskQueueTest, VisitRoot) {}

TEST_P(MicrotaskQueueTest, PromiseHandlerContext) {}

TEST_P(MicrotaskQueueTest, DetachGlobal_Enqueue) {}

TEST_P(MicrotaskQueueTest, DetachGlobal_Run) {}

TEST_P(MicrotaskQueueTest, DetachGlobal_PromiseResolveThenableJobTask) {}

TEST_P(MicrotaskQueueTest, DetachGlobal_ResolveThenableForeignThen) {}

TEST_P(MicrotaskQueueTest, DetachGlobal_HandlerContext) {}

TEST_P(MicrotaskQueueTest, DetachGlobal_Chain) {}

TEST_P(MicrotaskQueueTest, DetachGlobal_InactiveHandler) {}

TEST_P(MicrotaskQueueTest, MicrotasksScope) {}

INSTANTIATE_TEST_SUITE_P(
    , MicrotaskQueueTest, ::testing::Values(false, true),
    [](const ::testing::TestParamInfo<MicrotaskQueueTest::ParamType>& info) {};

}  // namespace internal
}  // namespace v8