summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/animation/css_interpolation_types_map_test.cc
blob: 8811ad19b6552d056395770226dcb8816eb24f06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright 2021 The Chromium 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 "third_party/blink/renderer/core/animation/css_interpolation_types_map.h"

#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/feature_policy/document_policy.h"
#include "third_party/blink/renderer/core/css/css_test_helpers.h"
#include "third_party/blink/renderer/core/css/property_registry.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/document_init.h"
#include "third_party/blink/renderer/core/testing/null_execution_context.h"

namespace blink {

TEST(CSSInterpolationTypesMapTest, RegisteredCustomProperty) {
  auto* execution_context = MakeGarbageCollected<NullExecutionContext>();
  execution_context->SetUpSecurityContextForTesting();
  execution_context->GetSecurityContext().SetDocumentPolicy(
      DocumentPolicy::CreateWithHeaderPolicy({}));

  DocumentInit init =
      DocumentInit::Create().WithExecutionContext(execution_context);
  auto* document1 = MakeGarbageCollected<Document>(init);
  auto* document2 = MakeGarbageCollected<Document>(init);

  AtomicString property_name("--x");
  PropertyRegistration* registration =
      css_test_helpers::CreateLengthRegistration(property_name, 0);
  PropertyRegistry* registry = MakeGarbageCollected<PropertyRegistry>();
  registry->RegisterProperty(property_name, *registration);

  CSSInterpolationTypesMap map1(nullptr, *document1);
  CSSInterpolationTypesMap map2(registry, *document2);

  PropertyHandle handle(property_name);
  auto& types1 = map1.Get(handle);
  auto& types2 = map2.Get(handle);
  EXPECT_NE(&types1, &types2);
  EXPECT_EQ(types1.size(), 1u);

  auto& types1_1 = map1.Get(handle);
  EXPECT_EQ(&types1, &types1_1);

  execution_context->NotifyContextDestroyed();
}

}  // namespace blink