chromium/components/performance_manager/v8_memory/v8_context_tracker_unittest.cc

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

#include "components/performance_manager/v8_memory/v8_context_tracker.h"

#include <memory>
#include <optional>
#include <string>
#include <utility>

#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "base/test/gtest_util.h"
#include "base/types/optional_util.h"
#include "components/performance_manager/graph/frame_node_impl.h"
#include "components/performance_manager/graph/page_node_impl.h"
#include "components/performance_manager/graph/process_node_impl.h"
#include "components/performance_manager/public/execution_context/execution_context_registry.h"
#include "components/performance_manager/public/mojom/v8_contexts.mojom.h"
#include "components/performance_manager/test_support/graph_test_harness.h"
#include "components/performance_manager/test_support/mock_graphs.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/tokens/tokens.h"

namespace performance_manager {
namespace v8_memory {

namespace {

AllOf;
Eq;
Property;

// Fake iframe attributes.
const std::string kIframeId("iframe1");
const std::string kIframeSrc("http://www.fakesite.com/");

// Some tokens for identifying frames and contexts.
const blink::V8ContextToken kFrameMainWorld;
const blink::V8ContextToken kChildFrameMainWorld;
const blink::V8ContextToken kFrameIsolatedWorld;
const blink::V8ContextToken kChildFrameIsolatedWorld;
const blink::RemoteFrameToken kChildFrameRemoteToken;

// A fake extension ID.
const char kExtensionId[] =;

// Helper function for creating an IframeAttributionData.
mojom::IframeAttributionDataPtr GetFakeIframeAttributionDataPtr() {}

class V8ContextTrackerTest : public GraphTestHarness {};

V8ContextTrackerDeathTest;

auto CountsMatch(size_t v8_context_count, size_t execution_context_count) {}

auto DetachedCountsMatch(size_t detached_v8_context_count,
                         size_t destroyed_execution_context_count) {}

}  // namespace

TEST_F(V8ContextTrackerDeathTest, MissingExecutionContextForMainFrameExplodes) {}

TEST_F(V8ContextTrackerDeathTest, DoubleCreationExplodes) {}

TEST_F(V8ContextTrackerDeathTest, MissingContextExplodes) {}

TEST_F(V8ContextTrackerDeathTest, DoubleRemoteFrameCreatedExplodes) {}

TEST_F(V8ContextTrackerDeathTest, RemoteFrameWithBadParentExplodes) {}

TEST_F(V8ContextTrackerDeathTest, IframeAttributionDataForMainFrameExplodes) {}

TEST_F(V8ContextTrackerDeathTest,
       NoIframeAttributionDataForInProcessChildFrameExplodes) {}

TEST_F(V8ContextTrackerDeathTest, MultipleMainContextsForExecutionContext) {}

TEST_F(V8ContextTrackerTest, NormalV8ContextLifecycleWithExecutionContext) {}

TEST_F(V8ContextTrackerTest, NormalV8ContextLifecycleNoExecutionContext) {}

TEST_F(V8ContextTrackerTest, MultipleV8ContextsForExecutionContext) {}

TEST_F(V8ContextTrackerTest, AllEventOrders) {}

TEST_F(V8ContextTrackerTest, PublicApi) {}

}  // namespace v8_memory
}  // namespace performance_manager