chromium/third_party/blink/renderer/core/css/selector_checker_test.cc

// Copyright 2022 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/css/selector_checker.h"

#include <bitset>
#include <optional>

#include "third_party/blink/renderer/core/css/css_test_helpers.h"
#include "third_party/blink/renderer/core/css/selector_checker-inl.h"
#include "third_party/blink/renderer/core/css/style_rule.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/node_computed_style.h"
#include "third_party/blink/renderer/core/dom/shadow_root.h"
#include "third_party/blink/renderer/core/html/html_element.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
#include "third_party/blink/renderer/core/testing/page_test_base.h"

namespace blink {

struct ScopeProximityTestData {};

ScopeProximityTestData scope_proximity_test_data[] =;

class ScopeProximityTest
    : public PageTestBase,
      public testing::WithParamInterface<ScopeProximityTestData> {};

INSTANTIATE_TEST_SUITE_P();

TEST_P(ScopeProximityTest, All) {}

struct MatchFlagsTestData {};

constexpr MatchFlags Active() {}
constexpr MatchFlags Drag() {}
constexpr MatchFlags FocusWithin() {}
constexpr MatchFlags Hover() {}

MatchFlagsTestData result_flags_test_data[] =;

class MatchFlagsTest : public PageTestBase,
                       public testing::WithParamInterface<MatchFlagsTestData> {};

INSTANTIATE_TEST_SUITE_P();

TEST_P(MatchFlagsTest, All) {}

class ImpactTest : public PageTestBase {};

// :hover

TEST_F(ImpactTest, HoverSubjectOnly) {}

TEST_F(ImpactTest, HoverNonSubjectOnly) {}

TEST_F(ImpactTest, HoverBoth) {}

TEST_F(ImpactTest, HoverDescendantCombinatorSubject) {}

// :-webkit-drag

TEST_F(ImpactTest, DragSubjectOnly) {}

TEST_F(ImpactTest, DragNonSubjectOnly) {}

TEST_F(ImpactTest, DragBoth) {}

TEST_F(ImpactTest, DragDescendantCombinatorSubject) {}

// :focus-within

TEST_F(ImpactTest, FocusWithinSubjectOnly) {}

TEST_F(ImpactTest, FocusWithinNonSubjectOnly) {}

TEST_F(ImpactTest, FocusWithinBoth) {}

TEST_F(ImpactTest, FocusWithinDescendantCombinatorSubject) {}

// :active

TEST_F(ImpactTest, ActiveSubjectOnly) {}

TEST_F(ImpactTest, ActiveNonSubjectOnly) {}

TEST_F(ImpactTest, ActiveBoth) {}

TEST_F(ImpactTest, ActiveDescendantCombinatorSubject) {}

// :focus-visible

TEST_F(ImpactTest, FocusVisibleSubjectOnly) {}

TEST_F(ImpactTest, FocusVisibleNonSubjectOnly) {}

TEST_F(ImpactTest, FocusVisibleBoth) {}

TEST_F(ImpactTest, FocusVisibleDescendantCombinatorSubject) {}

// :has()

TEST_F(ImpactTest, HasSubjectOnly) {}

TEST_F(ImpactTest, HasNonSubjectOnly) {}

TEST_F(ImpactTest, HasBoth) {}

TEST_F(ImpactTest, HasDescendantCombinatorSubject) {}

TEST_F(ImpactTest, HasDescendantCombinatorBoth) {}

TEST_F(ImpactTest, HasSubjectAndDescendantCombinatorBoth) {}

TEST_F(ImpactTest, HasDescendantCombinatorWithinIsBoth) {}

TEST_F(ImpactTest, HasDescendantCombinatorWithIsBoth) {}

// Cases involving :host are special, because we need to call SelectorChecker
// with a non-nullptr scope node.

MatchFlagsTestData result_flags_shadow_test_data[] =;

class MatchFlagsShadowTest
    : public PageTestBase,
      public testing::WithParamInterface<MatchFlagsTestData> {};

INSTANTIATE_TEST_SUITE_P();

TEST_P(MatchFlagsShadowTest, Host) {}

class MatchFlagsScopeTest : public PageTestBase {};

TEST_F(MatchFlagsScopeTest, NoHover) {}

TEST_F(MatchFlagsScopeTest, HoverSubject) {}

TEST_F(MatchFlagsScopeTest, HoverNonSubject) {}

TEST_F(MatchFlagsScopeTest, ScopeSubject) {}

TEST_F(MatchFlagsScopeTest, ScopeNonSubject) {}

TEST_F(MatchFlagsScopeTest, ScopeLimit) {}

TEST_F(MatchFlagsScopeTest, ScopeLimitNonSubject) {}

class EasySelectorCheckerTest : public PageTestBase {};

bool EasySelectorCheckerTest::Matches(const String& selector_text,
                                      const char* id) {}

#if DCHECK_IS_ON()  // Requires all_rules_, to find back the rules we add.

// Parse the given selector, buckets it and returns whether it was counted
// as easy or not.
bool EasySelectorCheckerTest::IsEasy(const String& selector_text) {}

TEST_F(EasySelectorCheckerTest, IsEasy) {}

#endif  // DCHECK_IS_ON()

TEST_F(EasySelectorCheckerTest, SmokeTest) {}

class SelectorCheckerTest : public PageTestBase {};

TEST_F(SelectorCheckerTest, PseudoScopeWithoutScope) {}

TEST_F(SelectorCheckerTest, PseudoTrue) {}

TEST_F(SelectorCheckerTest, PseudoTrueMatchesHost) {}

}  // namespace blink