#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/core/css/parser/css_selector_parser.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/core/css/css_selector.h"
#include "third_party/blink/renderer/core/css/css_selector_list.h"
#include "third_party/blink/renderer/core/css/css_test_helpers.h"
#include "third_party/blink/renderer/core/css/parser/css_parser_context.h"
#include "third_party/blink/renderer/core/css/parser/css_tokenizer.h"
#include "third_party/blink/renderer/core/css/style_sheet_contents.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/execution_context/security_context.h"
#include "third_party/blink/renderer/core/testing/dummy_page_holder.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/testing/task_environment.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
namespace blink {
ANPlusBTestCase;
struct SelectorTestCase { … };
class SelectorParseTest : public ::testing::TestWithParam<SelectorTestCase> { … };
TEST_P(SelectorParseTest, Parse) { … }
TEST(CSSSelectorParserTest, ValidANPlusB) { … }
TEST(CSSSelectorParserTest, InvalidANPlusB) { … }
TEST(CSSSelectorParserTest, PseudoElementsInCompoundLists) { … }
TEST(CSSSelectorParserTest, ValidSimpleAfterPseudoElementInCompound) { … }
TEST(CSSSelectorParserTest, InvalidSimpleAfterPseudoElementInCompound) { … }
TEST(CSSSelectorParserTest, TransitionPseudoStyles) { … }
TEST(CSSSelectorParserTest, WorkaroundForInvalidCustomPseudoInUAStyle) { … }
TEST(CSSSelectorParserTest, InvalidPseudoElementInNonRightmostCompound) { … }
TEST(CSSSelectorParserTest, UnresolvedNamespacePrefix) { … }
TEST(CSSSelectorParserTest, UnexpectedPipe) { … }
TEST(CSSSelectorParserTest, SerializedUniversal) { … }
TEST(CSSSelectorParserTest, AttributeSelectorUniversalInvalid) { … }
TEST(CSSSelectorParserTest, InternalPseudo) { … }
TEST(CSSSelectorParserTest, ScrollControlPseudos) { … }
static const SelectorTestCase invalid_pseudo_is_argments_data[] = …;
INSTANTIATE_TEST_SUITE_P(…);
static const SelectorTestCase is_where_nesting_data[] = …;
INSTANTIATE_TEST_SUITE_P(…);
static const SelectorTestCase is_where_forgiving_data[] = …;
INSTANTIATE_TEST_SUITE_P(…);
namespace {
AtomicString TagLocalName(const CSSSelector* selector) { … }
AtomicString AttributeLocalName(const CSSSelector* selector) { … }
AtomicString SelectorValue(const CSSSelector* selector) { … }
struct ASCIILowerTestCase { … };
}
TEST(CSSSelectorParserTest, ASCIILowerHTMLStrict) { … }
TEST(CSSSelectorParserTest, ASCIILowerHTMLQuirks) { … }
TEST(CSSSelectorParserTest, ShadowPartPseudoElementValid) { … }
TEST(CSSSelectorParserTest, ShadowPartAndBeforeAfterPseudoElementValid) { … }
static bool IsCounted(const char* selector,
CSSParserMode mode,
WebFeature feature) { … }
TEST(CSSSelectorParserTest, UseCountShadowPseudo) { … }
TEST(CSSSelectorParserTest, IsWhereUseCount) { … }
TEST(CSSSelectorParserTest, ImplicitShadowCrossingCombinators) { … }
static const SelectorTestCase invalid_pseudo_has_arguments_data[] = …;
INSTANTIATE_TEST_SUITE_P(…);
static const SelectorTestCase has_nesting_data[] = …;
INSTANTIATE_TEST_SUITE_P(…);
static CSSSelectorList* ParseNested(String inner_rule,
CSSNestingType nesting_type) { … }
static std::optional<CSSSelector::PseudoType> GetImplicitlyAddedPseudo(
String inner_rule,
CSSNestingType nesting_type) { … }
TEST(CSSSelectorParserTest, NestingTypeImpliedDescendant) { … }
static const CSSSelector* NthSimpleSelector(const CSSSelector& selector,
wtf_size_t index) { … }
struct ScopeActivationData { … };
ScopeActivationData scope_activation_data[] = …;
class ScopeActivationTest
: public ::testing::TestWithParam<ScopeActivationData> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(ScopeActivationTest, All) { … }
template <typename PredicateFunc>
static wtf_size_t CountSimpleSelectors(const CSSSelectorList& list,
PredicateFunc predicate) { … }
template <typename PredicateFunc>
static std::optional<wtf_size_t> CountSimpleSelectors(
String selector_text,
CSSNestingType nesting_type,
PredicateFunc predicate) { … }
static std::optional<wtf_size_t> CountPseudoTrue(String selector_text,
CSSNestingType nesting_type) { … }
static std::optional<wtf_size_t> CountScopeActivations(
String selector_text,
CSSNestingType nesting_type) { … }
static std::optional<wtf_size_t> CountPseudoTrueWithScopeActivation(
String selector_text,
CSSNestingType nesting_type) { … }
TEST(CSSSelectorParserTest, CountMatchesSelfTest) { … }
struct ScopeActivationCountData { … };
ScopeActivationCountData scope_activation_count_data[] = …;
class ScopeActivationCountTest
: public ::testing::TestWithParam<ScopeActivationCountData> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(ScopeActivationCountTest, Scope) { … }
TEST_P(ScopeActivationCountTest, Nesting) { … }
TEST_P(ScopeActivationCountTest, None) { … }
}