blob: 6f4e8955a24837904d35a8d0dacd249ff210d2c8 [file] [log] [blame]
Torne (Richard Coles)09380292014-02-21 12:17:33 +00001// Copyright 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "config.h"
6#include "core/css/CSSTestHelper.h"
7#include "core/css/RuleSet.h"
8
9#include <gtest/gtest.h>
10
11namespace WebCore {
12
13TEST(CSSSelector, Representations)
14{
15 CSSTestHelper helper;
16
17 const char* cssRules =
18 "summary::-webkit-details-marker { }"
19 "* {}"
20 "div {}"
21 "#id {}"
22 ".class {}"
23 "[attr] {}"
24 "div:hover {}"
25 "div:nth-child(2){}"
26 ".class#id { }"
27 "#id.class { }"
28 "[attr]#id { }"
29 "div[attr]#id { }"
Torne (Richard Coles)d5428f32014-03-18 10:21:16 +000030 "video::cue { }"
Torne (Richard Coles)09380292014-02-21 12:17:33 +000031 "div::first-line { }"
32 ".a.b.c { }"
33 "div:not(.a) { }" // without class a
34 "div:not(:visited) { }" // without the visited pseudo class
35
36 "[attr=\"value\"] { }" // Exact equality
37 "[attr~=\"value\"] { }" // One of a space-separated list
38 "[attr^=\"value\"] { }" // Begins with
39 "[attr$=\"value\"] { }" // Ends with
40 "[attr*=\"value\"] { }" // Substring equal to
41 "[attr|=\"value\"] { }" // One of a hyphen-separated list
42
43 ".a .b { }" // .b is a descendant of .a
44 ".a > .b { }" // .b is a direct descendant of .a
45 ".a ~ .b { }" // .a precedes .b in sibling order
46 ".a + .b { }" // .a element immediately precedes .b in sibling order
47 ".a, .b { }" // matches .a or .b
48
49 ".a.b .c {}";
50
51 helper.addCSSRules(cssRules);
52 EXPECT_EQ(30u, helper.ruleSet().ruleCount()); // .a, .b counts as two rules.
53#ifndef NDEBUG
54 helper.ruleSet().show();
55#endif
56}
57
58} // namespace WebCore