OLD | NEW |
(Empty) | |
| 1 /// Test for the Selectors API ported from |
| 2 /// <https://github.com/w3c/web-platform-tests/tree/master/selectors-api> |
| 3 /// Failures caused by csslib are triaged with "TODO". |
| 4 library html5lib.test.selectors.selectors; |
| 5 |
| 6 // Bit-mapped flags to indicate which tests the selector is suitable for |
| 7 var TEST_QSA_BASELINE = 0x01; // querySelector() and querySelectorAll() base
line tests |
| 8 var TEST_QSA_ADDITIONAL = 0x02; // querySelector() and querySelectorAll() addi
tional tests |
| 9 var TEST_FIND_BASELINE = 0x04; // find() and findAll() baseline tests, may be
unsuitable for querySelector[All] |
| 10 var TEST_FIND_ADDITIONAL = 0x08; // find() and findAll() additional tests, may
be unsuitable for querySelector[All] |
| 11 var TEST_MATCH_BASELINE = 0x10; // matches() baseline tests |
| 12 var TEST_MATCH_ADDITIONAL = 0x20; // matches() additional tests |
| 13 |
| 14 |
| 15 /* |
| 16 * All of these invalid selectors should result in a SyntaxError being thrown by
the APIs. |
| 17 * |
| 18 * name: A descriptive name of the selector being tested |
| 19 * selector: The selector to test |
| 20 */ |
| 21 var invalidSelectors = [ |
| 22 {'name': "Empty String", 'selector': ""}, |
| 23 {'name': "Invalid character", 'selector': "["}, |
| 24 {'name': "Invalid character", 'selector': "]"}, |
| 25 {'name': "Invalid character", 'selector': "("}, |
| 26 {'name': "Invalid character", 'selector': ")"}, |
| 27 {'name': "Invalid character", 'selector': "{"}, |
| 28 {'name': "Invalid character", 'selector': "}"}, |
| 29 {'name': "Invalid character", 'selector': "<"}, |
| 30 {'name': "Invalid character", 'selector': ">"}, |
| 31 {'name': "Invalid ID", 'selector': "#"}, |
| 32 {'name': "Invalid group of selectors", 'selector': "div,"}, |
| 33 {'name': "Invalid class", 'selector': "."}, |
| 34 {'name': "Invalid class", 'selector': ".5cm"}, |
| 35 {'name': "Invalid class", 'selector': "..test"}, |
| 36 {'name': "Invalid class", 'selector': ".foo..quux"}, |
| 37 {'name': "Invalid class", 'selector': ".bar."}, |
| 38 {'name': "Invalid combinator", 'selector': "div & address, p"}
, |
| 39 {'name': "Invalid combinator", 'selector': "div >> address, p"
}, |
| 40 {'name': "Invalid combinator", 'selector': "div ++ address, p"
}, |
| 41 {'name': "Invalid combinator", 'selector': "div ~~ address, p"
}, |
| 42 {'name': "Invalid [att=value] selector", 'selector': "[*=test]"}, |
| 43 {'name': "Invalid [att=value] selector", 'selector': "[*|*=test]"}, |
| 44 {'name': "Invalid [att=value] selector", 'selector': "[class= space unqu
oted ]"}, |
| 45 {'name': "Unknown pseudo-class", 'selector': "div:example"}, |
| 46 {'name': "Unknown pseudo-class", 'selector': ":example"}, |
| 47 {'name': "Unknown pseudo-element", 'selector': "div::example"}, |
| 48 {'name': "Unknown pseudo-element", 'selector': "::example"}, |
| 49 {'name': "Invalid pseudo-element", 'selector': ":::before"}, |
| 50 {'name': "Undeclared namespace", 'selector': "ns|div"}, |
| 51 {'name': "Undeclared namespace", 'selector': ":not(ns|div)"}, |
| 52 {'name': "Invalid namespace", 'selector': "^|div"}, |
| 53 {'name': "Invalid namespace", 'selector': "\$|div"} |
| 54 ]; |
| 55 |
| 56 /* |
| 57 * All of these should be valid selectors, expected to match zero or more elemen
ts in the document. |
| 58 * None should throw any errors. |
| 59 * |
| 60 * name: A descriptive name of the selector being tested |
| 61 * selector: The selector to test |
| 62 * 'expect': A list of IDs of the elements expected to be matched. List must
be given in tree order. |
| 63 * 'exclude': An array of contexts to exclude from testing. The valid values
are: |
| 64 * ["document", "element", "fragment", "detached", "html", "xhtml"] |
| 65 * The "html" and "xhtml" values represent the type of document bein
g queried. These are useful |
| 66 * for tests that are affected by differences between HTML and XML,
such as case sensitivity. |
| 67 * 'level': An integer indicating the CSS or Selectors level in which the s
elector being tested was introduced. |
| 68 * 'testType': A bit-mapped flag indicating the type of test. |
| 69 * |
| 70 * Note: Interactive pseudo-classes (:active :hover and :focus) have not been te
sted in this test suite. |
| 71 */ |
| 72 var validSelectors = [ |
| 73 // Type Selector |
| 74 {'name': "Type selector, matching html element", 'selector': "html", 'ex
pect': ["html"], 'exclude': ["element", "fragment", "detached"], 'level
': 1, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 75 {'name': "Type selector, matching html element", 'selector': "html", 'ex
pect': [] /*no matches*/, 'exclude': ["document"], 'level
': 1, 'testType': TEST_QSA_BASELINE}, |
| 76 {'name': "Type selector, matching body element", 'selector': "body", 'ex
pect': ["body"], 'exclude': ["element", "fragment", "detached"], 'level
': 1, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 77 {'name': "Type selector, matching body element", 'selector': "body", 'ex
pect': [] /*no matches*/, 'exclude': ["document"], 'level
': 1, 'testType': TEST_QSA_BASELINE}, |
| 78 |
| 79 // Universal Selector |
| 80 // Testing "*" for entire an entire context node is handled separately. |
| 81 {'name': "Universal selector, matching all children of element with spec
ified ID", 'selector': "#universal>*", 'expect': ["universal-p1", "unive
rsal-hr1", "universal-pre1", "universal-p2", "universal-address1"], 'level': 2,
'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 82 {'name': "Universal selector, matching all grandchildren of element with
specified ID", 'selector': "#universal>*>*", 'expect': ["universal-code1", "un
iversal-span1", "universal-a1", "universal-code2"], 'level': 2,
'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 83 {'name': "Universal selector, matching all children of empty element wit
h specified ID", 'selector': "#empty>*", 'expect': [] /*no matches*/,
'level': 2,
'testType': TEST_QSA_BASELINE}, |
| 84 {'name': "Universal selector, matching all descendants of element with s
pecified ID", 'selector': "#universal *", 'expect': ["universal-p1", "unive
rsal-code1", "universal-hr1", "universal-pre1", "universal-span1", "universal-p2
", "universal-a1", "universal-address1", "universal-code2", "universal-a2"], 'le
vel': 2, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 85 |
| 86 // Attribute Selectors |
| 87 // - presence [att] |
| 88 {'name': "Attribute presence selector, matching align attribute with val
ue", 'selector': ".attr-presence-div1[align]",
'expect': ["attr-presence-div1"],
'level': 2, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 89 {'name': "Attribute presence selector, matching align attribute with emp
ty value", 'selector': ".attr-presence-div2[align]",
'expect': ["attr-presence-div2"],
'level': 2, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 90 {'name': "Attribute presence selector, matching title attribute, case in
sensitivity", 'selector': "#attr-presence [TiTlE]",
'expect': ["attr-presence-a1", "attr-presence-span1"], 'exclude':
["xhtml"], 'level': 2, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 91 {'name': "Attribute presence selector, not matching title attribute, cas
e sensitivity", 'selector': "#attr-presence [TiTlE]",
'expect': [], 'exclude':
["html"], 'level': 2, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 92 {'name': "Attribute presence selector, matching custom data-* attribute"
, 'selector': "[data-attr-presence]",
'expect': ["attr-presence-pre1", "attr-presence-blockquote1"],
'level': 2, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 93 {'name': "Attribute presence selector, not matching attribute with simil
ar name", 'selector': ".attr-presence-div3[align], .attr-presence-
div4[align]", 'expect': [] /*no matches*/,
'level': 2, 'testType': TEST_QSA_BASELINE}, |
| 94 {'name': "Attribute presence selector, matching attribute with non-ASCII
characters", 'selector': "ul[data-中文]",
'expect': ["attr-presence-ul1"],
'level': 2, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 95 {'name': "Attribute presence selector, not matching default option witho
ut selected attribute", 'selector': "#attr-presence-select1 option[selected]",
'expect': [] /* no matches */,
'level': 2, 'testType': TEST_QSA_BASELINE}, |
| 96 {'name': "Attribute presence selector, matching option with selected att
ribute", 'selector': "#attr-presence-select2 option[selected]",
'expect': ["attr-presence-select2-option4"],
'level': 2, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 97 {'name': "Attribute presence selector, matching multiple options with se
lected attributes", 'selector': "#attr-presence-select3 option[selected]",
'expect': ["attr-presence-select3-option2", "attr-presence-select3
-option3"], 'level': 2, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 98 |
| 99 // - value [att=val] |
| 100 {'name': "Attribute value selector, matching align attribute with value"
, 'selector': "#attr-value [align=\"center\"]
", 'expect': ["attr-value-div1"], 'level': 2
, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 101 {'name': "Attribute value selector, matching align attribute with empty
value", 'selector': "#attr-value [align=\"\"]",
'expect': ["attr-value-div2"], 'level': 2
, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 102 {'name': "Attribute value selector, not matching align attribute with pa
rtial value", 'selector': "#attr-value [align=\"c\"]",
'expect': [] /*no matches*/, 'level': 2
, 'testType': TEST_QSA_BASELINE}, |
| 103 {'name': "Attribute value selector, not matching align attribute with in
correct value", 'selector': "#attr-value [align=\"centera\"
]", 'expect': [] /*no matches*/, 'level': 2
, 'testType': TEST_QSA_BASELINE}, |
| 104 {'name': "Attribute value selector, matching custom data-* attribute wit
h unicode escaped value", 'selector': "[data-attr-value=\"\\e9\"]",
'expect': ["attr-value-div3"], 'level': 2
, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 105 {'name': "Attribute value selector, matching custom data-* attribute wit
h escaped character", 'selector': "[data-attr-value\_foo=\"\\e9\"
]", 'expect': ["attr-value-div4"], 'level': 2
, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 106 {'name': "Attribute value selector with single-quoted value, matching mu
ltiple inputs with type attributes", 'selector': "#attr-value input[type='hidden
'],#attr-value input[type='radio']", 'expect': ["attr-value-input3", "attr-val
ue-input4", "attr-value-input6", "attr-value-input8", "attr-value-input9"], 'lev
el': 2, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 107 {'name': "Attribute value selector with double-quoted value, matching mu
ltiple inputs with type attributes", 'selector': "#attr-value input[type=\"hidde
n\"],#attr-value input[type='radio']", 'expect': ["attr-value-input3", "attr-val
ue-input4", "attr-value-input6", "attr-value-input8", "attr-value-input9"], 'lev
el': 2, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 108 {'name': "Attribute value selector with unquoted value, matching multipl
e inputs with type attributes", 'selector': "#attr-value input[type=hidden]
,#attr-value input[type=radio]", 'expect': ["attr-value-input3", "attr-val
ue-input4", "attr-value-input6", "attr-value-input8", "attr-value-input9"], 'lev
el': 2, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 109 {'name': "Attribute value selector, matching attribute with value using
non-ASCII characters", 'selector': "[data-attr-value=中文]",
'expect': ["attr-value-div5"], 'level': 2
, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 110 |
| 111 // - whitespace-separated list [att~=val] |
| 112 {'name': "Attribute whitespace-separated list selector, matching class a
ttribute with value", 'selector': "#attr-whites
pace [class~=\"div1\"]", 'expect': ["attr
-whitespace-div1"], 'level': 2, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASEL
INE}, |
| 113 {'name': "Attribute whitespace-separated list selector, not matching cla
ss attribute with empty value", 'selector': "#attr-whites
pace [class~=\"\"]", 'expect': [] /*n
o matches*/ , 'level': 2, 'testType': TEST_QSA_BASELINE}, |
| 114 {'name': "Attribute whitespace-separated list selector, not matching cla
ss attribute with partial value", 'selector': "[data-attr-w
hitespace~=\"div\"]", 'expect': [] /*n
o matches*/ , 'level': 2, 'testType': TEST_QSA_BASELINE}, |
| 115 {'name': "Attribute whitespace-separated list selector, matching custom
data-* attribute with unicode escaped value", 'selector': "[data-attr-w
hitespace~=\"\\0000e9\"]", 'expect': ["attr
-whitespace-div4"], 'level': 2, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASEL
INE}, |
| 116 {'name': "Attribute whitespace-separated list selector, matching custom
data-* attribute with escaped character", 'selector': "[data-attr-w
hitespace\_foo~=\"\\e9\"]", 'expect': ["attr
-whitespace-div5"], 'level': 2, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASEL
INE}, |
| 117 {'name': "Attribute whitespace-separated list selector with single-quote
d value, matching multiple links with rel attributes", 'selector': "#attr-whites
pace a[rel~='bookmark'], #attr-whitespace a[rel~='nofollow']", 'expect': ["attr
-whitespace-a1", "attr-whitespace-a2", "attr-whitespace-a3", "attr-whitespace-a5
", "attr-whitespace-a7"], 'level': 2, 'testType': TEST_QSA_BASELINE | TEST_MATCH
_BASELINE}, |
| 118 {'name': "Attribute whitespace-separated list selector with double-quote
d value, matching multiple links with rel attributes", 'selector': "#attr-whites
pace a[rel~=\"bookmark\"],#attr-whitespace a[rel~='nofollow']", 'expect': ["attr
-whitespace-a1", "attr-whitespace-a2", "attr-whitespace-a3", "attr-whitespace-a5
", "attr-whitespace-a7"], 'level': 2, 'testType': TEST_QSA_BASELINE | TEST_MATCH
_BASELINE}, |
| 119 {'name': "Attribute whitespace-separated list selector with unquoted val
ue, matching multiple links with rel attributes", 'selector': "#attr-whites
pace a[rel~=bookmark], #attr-whitespace a[rel~=nofollow]", 'expect': ["attr
-whitespace-a1", "attr-whitespace-a2", "attr-whitespace-a3", "attr-whitespace-a5
", "attr-whitespace-a7"], 'level': 2, 'testType': TEST_QSA_BASELINE | TEST_MATCH
_BASELINE}, |
| 120 {'name': "Attribute whitespace-separated list selector with double-quote
d value, not matching value with space", 'selector': "#attr-whites
pace a[rel~=\"book mark\"]", 'expect': [] /*
no matches */, 'level': 2, 'testType': TEST_QSA_BASELINE}, |
| 121 {'name': "Attribute whitespace-separated list selector, matching title a
ttribute with value using non-ASCII characters", 'selector': "#attr-whites
pace [title~=中文]", 'expect': ["attr
-whitespace-p1"], 'level': 2, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASEL
INE}, |
| 122 |
| 123 // - hyphen-separated list [att|=val] |
| 124 {'name': "Attribute hyphen-separated list selector, not matching unspeci
fied lang attribute", 'selector': "#attr-hyphen-div1[lang|=\"en\"]", 'expe
ct': [] /*no matches*/, 'level': 2, 'testType': TEST_QSA_BASELINE}, |
| 125 {'name': "Attribute hyphen-separated list selector, matching lang attrib
ute with exact value", 'selector': "#attr-hyphen-div2[lang|=\"fr\"]", 'expe
ct': ["attr-hyphen-div2"], 'level': 2, 'testType': TEST_QSA_BASELINE | TEST_MATC
H_BASELINE}, |
| 126 {'name': "Attribute hyphen-separated list selector, matching lang attrib
ute with partial value", 'selector': "#attr-hyphen-div3[lang|=\"en\"]", 'expe
ct': ["attr-hyphen-div3"], 'level': 2, 'testType': TEST_QSA_BASELINE | TEST_MATC
H_BASELINE}, |
| 127 {'name': "Attribute hyphen-separated list selector, not matching incorre
ct value", 'selector': "#attr-hyphen-div4[lang|=\"es-AR\"]", 'expe
ct': [] /*no matches*/, 'level': 2, 'testType': TEST_QSA_BASELINE}, |
| 128 |
| 129 // - substring begins-with [att^=val] (Level 3) |
| 130 {'name': "Attribute begins with selector, matching href attributes begin
ning with specified substring", 'selector': "#attr-b
egins a[href^=\"http://www\"]", 'expect': ["attr-begins-a1", "attr-begins-a3"],
'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 131 {'name': "Attribute begins with selector, matching lang attributes begin
ning with specified substring, ", 'selector': "#attr-b
egins [lang^=\"en-\"]", 'expect': ["attr-begins-div2", "attr-begins-div4
"], 'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 132 {'name': "Attribute begins with selector, not matching class attribute n
ot beginning with specified substring", 'selector': "#attr-b
egins [class^=apple]", 'expect': [] /*no matches*/,
'level': 3, 'testType': TEST_QSA_ADDITIONAL}, |
| 133 {'name': "Attribute begins with selector with single-quoted value, match
ing class attribute beginning with specified substring", 'selector': "#attr-b
egins [class^=' apple']", 'expect': ["attr-begins-p1"],
'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 134 {'name': "Attribute begins with selector with double-quoted value, match
ing class attribute beginning with specified substring", 'selector': "#attr-b
egins [class^=\" apple\"]", 'expect': ["attr-begins-p1"],
'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 135 {'name': "Attribute begins with selector with unquoted value, not matchi
ng class attribute not beginning with specified substring", 'selector': "#attr-b
egins [class^= apple]", 'expect': [] /*no matches*/,
'level': 3, 'testType': TEST_QSA_ADDITIONAL}, |
| 136 |
| 137 // - substring ends-with [att\$=val] (Level 3) |
| 138 {'name': "Attribute ends with selector, matching href attributes ending
with specified substring", 'selector': "#attr-ends a
[href\$=\".org\"]", 'expect': ["attr-ends-a1", "attr-ends-a3"], 'level': 3
, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 139 {'name': "Attribute ends with selector, matching lang attributes ending
with specified substring, ", 'selector': "#attr-ends [
lang\$=\"-CH\"]", 'expect': ["attr-ends-div2", "attr-ends-div4"], 'level': 3
, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 140 {'name': "Attribute ends with selector, not matching class attribute not
ending with specified substring", 'selector': "#attr-ends [
class\$=apple]", 'expect': [] /*no matches*/, 'level': 3
, 'testType': TEST_QSA_ADDITIONAL}, |
| 141 {'name': "Attribute ends with selector with single-quoted value, matchin
g class attribute ending with specified substring", 'selector': "#attr-ends [
class\$='apple ']", 'expect': ["attr-ends-p1"], 'level': 3
, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 142 {'name': "Attribute ends with selector with double-quoted value, matchin
g class attribute ending with specified substring", 'selector': "#attr-ends [
class\$=\"apple \"]", 'expect': ["attr-ends-p1"], 'level': 3
, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 143 {'name': "Attribute ends with selector with unquoted value, not matching
class attribute not ending with specified substring", 'selector': "#attr-ends [
class\$=apple ]", 'expect': [] /*no matches*/, 'level': 3
, 'testType': TEST_QSA_ADDITIONAL}, |
| 144 |
| 145 // - substring contains [att*=val] (Level 3) |
| 146 {'name': "Attribute contains selector, matching href attributes beginnin
g with specified substring", 'selector': "#attr-contain
s a[href*=\"http://www\"]", 'expect': ["attr-contains-a1", "attr-contains-a3
"], 'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 147 {'name': "Attribute contains selector, matching href attributes ending w
ith specified substring", 'selector': "#attr-contain
s a[href*=\".org\"]", 'expect': ["attr-contains-a1", "attr-contains-a2
"], 'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 148 {'name': "Attribute contains selector, matching href attributes containi
ng specified substring", 'selector': "#attr-contain
s a[href*=\".example.\"]", 'expect': ["attr-contains-a1", "attr-contains-a3
"], 'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 149 {'name': "Attribute contains selector, matching lang attributes beginnin
g with specified substring, ", 'selector': "#attr-contain
s [lang*=\"en-\"]", 'expect': ["attr-contains-div2", "attr-contains-
div6"], 'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 150 {'name': "Attribute contains selector, matching lang attributes ending w
ith specified substring, ", 'selector': "#attr-contain
s [lang*=\"-CH\"]", 'expect': ["attr-contains-div3", "attr-contains-
div5"], 'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 151 {'name': "Attribute contains selector with single-quoted value, matching
class attribute beginning with specified substring", 'selector': "#attr-contain
s [class*=' apple']", 'expect': ["attr-contains-p1"],
'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 152 {'name': "Attribute contains selector with single-quoted value, matching
class attribute ending with specified substring", 'selector': "#attr-contain
s [class*='orange ']", 'expect': ["attr-contains-p1"],
'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 153 {'name': "Attribute contains selector with single-quoted value, matching
class attribute containing specified substring", 'selector': "#attr-contain
s [class*='ple banana ora']", 'expect': ["attr-contains-p1"],
'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 154 {'name': "Attribute contains selector with double-quoted value, matching
class attribute beginning with specified substring", 'selector': "#attr-contain
s [class*=\" apple\"]", 'expect': ["attr-contains-p1"],
'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 155 {'name': "Attribute contains selector with double-quoted value, matching
class attribute ending with specified substring", 'selector': "#attr-contain
s [class*=\"orange \"]", 'expect': ["attr-contains-p1"],
'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 156 {'name': "Attribute contains selector with double-quoted value, matching
class attribute containing specified substring", 'selector': "#attr-contain
s [class*=\"ple banana ora\"]", 'expect': ["attr-contains-p1"],
'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 157 {'name': "Attribute contains selector with unquoted value, matching clas
s attribute beginning with specified substring", 'selector': "#attr-contain
s [class*= apple]", 'expect': ["attr-contains-p1"],
'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 158 {'name': "Attribute contains selector with unquoted value, matching clas
s attribute ending with specified substring", 'selector': "#attr-contain
s [class*=orange ]", 'expect': ["attr-contains-p1"],
'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 159 {'name': "Attribute contains selector with unquoted value, matching clas
s attribute containing specified substring", 'selector': "#attr-contain
s [class*= banana ]", 'expect': ["attr-contains-p1"],
'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 160 |
| 161 // Pseudo-classes |
| 162 // - :root (Level 3) |
| 163 {'name': ":root pseudo-class selector, matching document root element",
'selector': ":root", 'expect': ["html"], 'exclude': ["element", "f
ragment", "detached"], 'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_
BASELINE}, |
| 164 {'name': ":root pseudo-class selector, not matching document root elemen
t", 'selector': ":root", 'expect': [] /*no matches*/, 'exclude': ["document"],
'level': 3, 'testType': TEST_QSA_ADDITIONAL}, |
| 165 |
| 166 // - :nth-child(n) (Level 3) |
| 167 {'name': ":nth-child selector, matching the third child element",
'selector': "#pseudo-nth-table1 :nth-child(3)", 'expect':
["pseudo-nth-td3", "pseudo-nth-td9", "pseudo-nth-tr3", "pseudo-nth-td15"],
'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
}, |
| 168 {'name': ":nth-child selector, matching every third child element",
'selector': "#pseudo-nth li:nth-child(3n)", 'expect':
["pseudo-nth-li3", "pseudo-nth-li6", "pseudo-nth-li9", "pseudo-nth-li12"],
'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
}, |
| 169 {'name': ":nth-child selector, matching every second child element, star
ting from the fourth", 'selector': "#pseudo-nth li:nth-child(2n+4)", 'expect':
["pseudo-nth-li4", "pseudo-nth-li6", "pseudo-nth-li8", "pseudo-nth-li10", "pseu
do-nth-li12"], 'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
}, |
| 170 {'name': ":nth-child selector, matching every fourth child element, star
ting from the third", 'selector': "#pseudo-nth-p1 :nth-child(4n-1)", 'expect':
["pseudo-nth-em2", "pseudo-nth-span3"],
'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE
}, |
| 171 |
| 172 // - :nth-last-child (Level 3) |
| 173 {'name': ":nth-last-child selector, matching the third last child elemen
t", 'selector': "#pseudo-nth-table1 :n
th-last-child(3)", 'expect': ["pseudo-nth-tr1", "pseudo-nth-td4", "pseudo-nth-td
10", "pseudo-nth-td16"], 'level': 3, 'testType': TEST_QSA_ADDITI
ONAL | TEST_MATCH_BASELINE}, |
| 174 {'name': ":nth-last-child selector, matching every third child element f
rom the end", 'selector': "#pseudo-nth li:nth-la
st-child(3n)", 'expect': ["pseudo-nth-li1", "pseudo-nth-li4", "pseudo-nth-li
7", "pseudo-nth-li10"], 'level': 3, 'testType': TEST_QSA_ADDITI
ONAL | TEST_MATCH_BASELINE}, |
| 175 {'name': ":nth-last-child selector, matching every second child element
from the end, starting from the fourth last", 'selector': "#pseudo-nth li:nth-la
st-child(2n+4)", 'expect': ["pseudo-nth-li1", "pseudo-nth-li3", "pseudo-nth-li
5", "pseudo-nth-li7", "pseudo-nth-li9"], 'level': 3, 'testType': TEST_QSA_ADDITI
ONAL | TEST_MATCH_BASELINE}, |
| 176 {'name': ":nth-last-child selector, matching every fourth element from t
he end, starting from the third last", 'selector': "#pseudo-nth-p1 :nth-l
ast-child(4n-1)", 'expect': ["pseudo-nth-span2", "pseudo-nth-span4"],
'level': 3, 'testType': TEST_QSA_ADDITI
ONAL | TEST_MATCH_BASELINE}, |
| 177 |
| 178 // - :nth-of-type(n) (Level 3) |
| 179 {'name': ":nth-of-type selector, matching the third em element",
'selector': "#pseudo-nth-p1 em:nth-of-type(3)",
'expect': ["pseudo-nth-em3"],
'level': 3, 'testType': TEST_QSA_ADDITIONAL |
TEST_MATCH_BASELINE}, |
| 180 {'name': ":nth-of-type selector, matching every second element of their
type", 'selector': "#pseudo-nth-p1 :nth-of-type(2n)",
'expect': ["pseudo-nth-em2", "pseudo-nth-span2", "pseudo-nth-span4", "pseud
o-nth-strong2", "pseudo-nth-em4"], 'level': 3, 'testType': TEST_QSA_ADDITIONAL |
TEST_MATCH_BASELINE}, |
| 181 {'name': ":nth-of-type selector, matching every second elemetn of their
type, starting from the first", 'selector': "#pseudo-nth-p1 span:nth-of-type(2n-
1)", 'expect': ["pseudo-nth-span1", "pseudo-nth-span3"],
'level': 3, 'testType': TEST_QSA_ADDITIONAL |
TEST_MATCH_BASELINE}, |
| 182 |
| 183 // - :nth-last-of-type(n) (Level 3) |
| 184 {'name': ":nth-last-of-type selector, matching the thrid last em element
", 'selector': "#pseudo-nth-p1 em:nth-last-of-type(3)", 'expect': ["pseudo-
nth-em2"],
'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 185 {'name': ":nth-last-of-type selector, matching every second last element
of their type", 'selector': "#pseudo-nth-p1 :nth-last-of-type(2n)", 'expe
ct': ["pseudo-nth-span1", "pseudo-nth-em1", "pseudo-nth-strong1", "pseudo-nth-em
3", "pseudo-nth-span3"], 'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATC
H_BASELINE}, |
| 186 {'name': ":nth-last-of-type selector, matching every second last element
of their type, starting from the last", 'selector': "#pseudo-nth-p1 span:nth-la
st-of-type(2n-1)", 'expect': ["pseudo-nth-span2", "pseudo-nth-span4"],
'level': 3, 'testType': TEST_QS
A_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 187 |
| 188 // - :first-of-type (Level 3) |
| 189 {'name': ":first-of-type selector, matching the first em element", 'sele
ctor': "#pseudo-nth-p1 em:first-of-type", 'expect': ["pseudo-nth-em1"],
'level': 3, 'testType': TEST_QSA_ADDITION
AL | TEST_MATCH_BASELINE}, |
| 190 {'name': ":first-of-type selector, matching the first of every type of e
lement", 'selector': "#pseudo-nth-p1 :first-of-type", 'expect': ["pseudo-
nth-span1", "pseudo-nth-em1", "pseudo-nth-strong1"], 'level': 3, 'testType': TES
T_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 191 {'name': ":first-of-type selector, matching the first td element in each
table row", 'selector': "#pseudo-nth-table1 tr :first-of-type", 'expect': ["pse
udo-nth-td1", "pseudo-nth-td7", "pseudo-nth-td13"], 'level': 3, 'testType':
TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 192 |
| 193 // - :last-of-type (Level 3) |
| 194 {'name': ":last-of-type selector, matching the last em elemnet", 'select
or': "#pseudo-nth-p1 em:last-of-type", 'expect': ["pseudo-nth-em4"],
'level': 3, 'testType': TEST_QSA_ADDITIONAL
| TEST_MATCH_BASELINE}, |
| 195 {'name': ":last-of-type selector, matching the last of every type of ele
ment", 'selector': "#pseudo-nth-p1 :last-of-type", 'expect': ["pseudo-nth
-span4", "pseudo-nth-strong2", "pseudo-nth-em4"], 'level': 3, 'testType': TEST_Q
SA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 196 {'name': ":last-of-type selector, matching the last td element in each t
able row", 'selector': "#pseudo-nth-table1 tr :last-of-type", 'expect': ["pseudo
-nth-td6", "pseudo-nth-td12", "pseudo-nth-td18"], 'level': 3, 'testType': TE
ST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 197 |
| 198 // - :first-child |
| 199 {'name': ":first-child pseudo-class selector, matching first child div e
lement", 'selector': "#pseudo-first-child div:first-child",
'expect': ["pseudo-first-child-div1"],
'level': 2, 'testType': TEST_QSA_BAS
ELINE | TEST_MATCH_BASELINE}, |
| 200 {'name': ":first-child pseudo-class selector, doesn't match non-first-ch
ild elements", 'selector': ".pseudo-first-child-div2:first-child, .pseudo-fir
st-child-div3:first-child", 'expect': [] /*no matches*/,
'level': 2, 'testType': TEST_QSA_BAS
ELINE}, |
| 201 {'name': ":first-child pseudo-class selector, matching first-child of mu
ltiple elements", 'selector': "#pseudo-first-child span:first-child",
'expect': ["pseudo-first-child-span1", "pseudo-first
-child-span3", "pseudo-first-child-span5"], 'level': 2, 'testType': TEST_QSA_BAS
ELINE | TEST_MATCH_BASELINE}, |
| 202 |
| 203 // - :last-child (Level 3) |
| 204 {'name': ":last-child pseudo-class selector, matching last child div ele
ment", 'selector': "#pseudo-last-child div:last-child",
'expect': ["pseudo-last-child-div3"],
'level': 3, 'testType': TEST_QSA_ADDITIONAL
| TEST_MATCH_BASELINE}, |
| 205 {'name': ":last-child pseudo-class selector, doesn't match non-last-chil
d elements", 'selector': ".pseudo-last-child-div1:last-child, .pseudo-last-c
hild-div2:first-child", 'expect': [] /*no matches*/,
'level': 3, 'testType': TEST_QSA_ADDITIONAL
}, |
| 206 {'name': ":last-child pseudo-class selector, matching first-child of mul
tiple elements", 'selector': "#pseudo-last-child span:last-child",
'expect': ["pseudo-last-child-span2", "pseudo-last-child
-span4", "pseudo-last-child-span6"], 'level': 3, 'testType': TEST_QSA_ADDITIONAL
| TEST_MATCH_BASELINE}, |
| 207 |
| 208 // - :only-child (Level 3) |
| 209 {'name': ":pseudo-only-child pseudo-class selector, matching all only-ch
ild elements", 'selector': "#pseudo-only :only-child", 'expect': ["pseudo-only-s
pan1"], 'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 210 {'name': ":pseudo-only-child pseudo-class selector, matching only-child
em elements", 'selector': "#pseudo-only em:only-child", 'expect': [] /*no match
es*/, 'level': 3, 'testType': TEST_QSA_ADDITIONAL}, |
| 211 |
| 212 // - :only-of-type (Level 3) |
| 213 {'name': ":pseudo-only-of-type pseudo-class selector, matching all eleme
nts with no siblings of the same type", 'selector': "#pseudo-only :only-of-type"
, 'expect': ["pseudo-only-span1", "pseudo-only-em1"], 'level': 3, 'testType': TE
ST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 214 {'name': ":pseudo-only-of-type pseudo-class selector, matching em elemen
ts with no siblings of the same type", 'selector': "#pseudo-only em:only-of-typ
e", 'expect': ["pseudo-only-em1"], 'level': 3, 'testType': TE
ST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 215 |
| 216 // - :empty (Level 3) |
| 217 {'name': ":empty pseudo-class selector, matching empty p elements", 's
elector': "#pseudo-empty p:empty", 'expect': ["pseudo-empty-p1", "pseudo-empty-p
2"], 'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MA
TCH_BASELINE}, |
| 218 {'name': ":empty pseudo-class selector, matching all empty elements", 's
elector': "#pseudo-empty :empty", 'expect': ["pseudo-empty-p1", "pseudo-empty-p
2", "pseudo-empty-span1"], 'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MA
TCH_BASELINE}, |
| 219 |
| 220 // - :link and :visited |
| 221 // Implementations may treat all visited links as unvisited, so these ca
nnot be tested separately. |
| 222 // The only guarantee is that ":link,:visited" matches the set of all vi
sited and unvisited links and that they are individually mutually exclusive sets
. |
| 223 {'name': ":link and :visited pseudo-class selectors, matching a and area
elements with href attributes", 'selector': "#pseudo-link :link, #pseudo
-link :visited", 'expect': ["pseudo-link-a1", "pseudo-link-a2", "pseudo-link-are
a1"], 'level': 1, 'testType': TEST_QSA_BASELINE |
TEST_MATCH_BASELINE}, |
| 224 {'name': ":link and :visited pseudo-class selectors, matching link eleme
nts with href attributes", 'selector': "#head :link, #head :visited
", 'expect': ["pseudo-link-link1", "pseudo-link-link2"], 'exclude'
: ["element", "fragment", "detached"], 'level': 1, 'testType': TEST_QSA_BASELINE
| TEST_MATCH_BASELINE}, |
| 225 {'name': ":link and :visited pseudo-class selectors, not matching link e
lements with href attributes", 'selector': "#head :link, #head :visited
", 'expect': [] /*no matches*/, 'exclude'
: ["document"], 'level': 1, 'testType': TEST_QSA_BASELINE
}, |
| 226 {'name': ":link and :visited pseudo-class selectors, chained, mutually e
xclusive pseudo-classes match nothing", 'selector': ":link:visited",
'expect': [] /*no matches*/, 'exclude'
: ["document"], 'level': 1, 'testType': TEST_QSA_BASELINE
}, |
| 227 |
| 228 // - :target (Level 3) |
| 229 {'name': ":target pseudo-class selector, matching the element referenced
by the URL fragment identifier", 'selector': ":target", 'expect': [] /*no match
es*/, 'exclude': ["document", "element"], 'level': 3, 'testType': TEST_QSA_ADDI
TIONAL}, |
| 230 {'name': ":target pseudo-class selector, matching the element referenced
by the URL fragment identifier", 'selector': ":target", 'expect': ["target"],
'exclude': ["fragment", "detached"], 'level': 3, 'testType': TEST_QSA_ADDI
TIONAL | TEST_MATCH_BASELINE}, |
| 231 |
| 232 // - :lang() |
| 233 {'name': ":lang pseudo-class selector, matching inherited language",
'selector': "#pseudo-lang-div1:lang(en)", 'expect': ["pseudo
-lang-div1"], 'exclude': ["detached", "fragment"], 'level': 2, 'testType': TEST_
QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 234 {'name': ":lang pseudo-class selector, not matching element with no inhe
rited language", 'selector': "#pseudo-lang-div1:lang(en)", 'expect': [] /*no
matches*/, 'exclude': ["document", "element"], 'level': 2, 'testType': TEST_
QSA_BASELINE}, |
| 235 {'name': ":lang pseudo-class selector, matching specified language with
exact value", 'selector': "#pseudo-lang-div2:lang(fr)", 'expect': ["pseudo
-lang-div2"], 'level': 2, 'testType': TEST_QS
A_BASELINE | TEST_MATCH_BASELINE}, |
| 236 {'name': ":lang pseudo-class selector, matching specified language with
partial value", 'selector': "#pseudo-lang-div3:lang(en)", 'expect': ["pseudo
-lang-div3"], 'level': 2, 'testType': TEST_QS
A_BASELINE | TEST_MATCH_BASELINE}, |
| 237 {'name': ":lang pseudo-class selector, not matching incorrect language",
'selector': "#pseudo-lang-div4:lang(es-AR)", 'expect': [] /*no
matches*/, 'level': 2, 'testType': TEST_QS
A_BASELINE}, |
| 238 |
| 239 // - :enabled (Level 3) |
| 240 {'name': ":enabled pseudo-class selector, matching all enabled form cont
rols", 'selector': "#pseudo-ui :enabled", 'expect': ["pseudo-ui-input1", "pseu
do-ui-input2", "pseudo-ui-input3", "pseudo-ui-input4", "pseudo-ui-input5", "pseu
do-ui-input6", |
| 241
"pseudo-ui-input7", "pseudo-ui-
input8", "pseudo-ui-input9", "pseudo-ui-textarea1", "pseudo-ui-button1"], 'le
vel': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 242 |
| 243 // - :disabled (Level 3) |
| 244 {'name': ":enabled pseudo-class selector, matching all disabled form con
trols", 'selector': "#pseudo-ui :disabled", 'expect': ["pseudo-ui-input10", "pse
udo-ui-input11", "pseudo-ui-input12", "pseudo-ui-input13", "pseudo-ui-input14",
"pseudo-ui-input15", |
| 245
"pseudo-ui-input16", "pseudo-ui
-input17", "pseudo-ui-input18", "pseudo-ui-textarea2", "pseudo-ui-button2"], 'le
vel': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 246 |
| 247 // - :checked (Level 3) |
| 248 {'name': ":checked pseudo-class selector, matching checked radio buttons
and checkboxes", 'selector': "#pseudo-ui :checked", 'expect': ["pseudo-ui-input
4", "pseudo-ui-input6", "pseudo-ui-input13", "pseudo-ui-input15"], 'level': 3,
'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 249 |
| 250 // - :not(s) (Level 3) |
| 251 {'name': ":not pseudo-class selector, matching ", 'selector': "#not>:not
(div)", 'expect': ["not-p1", "not-p2", "not-p3"], 'level': 3, 'testType': TEST
_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 252 {'name': ":not pseudo-class selector, matching ", 'selector': "#not * :n
ot(:first-child)", 'expect': ["not-em1", "not-em2", "not-em3"], 'level': 3, 't
estType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 253 {'name': ":not pseudo-class selector, matching nothing", 'selector': ":n
ot(*)", 'expect': [] /* no matches */, 'level': 3, 'testType': TEST_QSA_ADDITI
ONAL}, |
| 254 {'name': ":not pseudo-class selector, matching nothing", 'selector': ":n
ot(*|*)", 'expect': [] /* no matches */, 'level': 3, 'testType': TEST_QSA_ADDITI
ONAL}, |
| 255 |
| 256 // Pseudo-elements |
| 257 // - ::first-line |
| 258 {'name': ":first-line pseudo-element (one-colon syntax) selector, not ma
tching any elements", 'selector': "#pseudo-element:first-line", 'expect':
[] /*no matches*/, 'level': 2, 'testType': TEST_QSA_BASELINE}, |
| 259 {'name': "::first-line pseudo-element (two-colon syntax) selector, not m
atching any elements", 'selector': "#pseudo-element::first-line", 'expect':
[] /*no matches*/, 'level': 3, 'testType': TEST_QSA_ADDITIONAL}, |
| 260 |
| 261 // - ::first-letter |
| 262 {'name': ":first-letter pseudo-element (one-colon syntax) selector, not
matching any elements", 'selector': "#pseudo-element:first-letter", 'expect':
[] /*no matches*/, 'level': 2, 'testType': TEST_QSA_BASELINE}, |
| 263 {'name': "::first-letter pseudo-element (two-colon syntax) selector, not
matching any elements", 'selector': "#pseudo-element::first-letter", 'expect':
[] /*no matches*/, 'level': 3, 'testType': TEST_QSA_ADDITIONAL}, |
| 264 |
| 265 // - ::before |
| 266 {'name': ":before pseudo-element (one-colon syntax) selector, not matchi
ng any elements", 'selector': "#pseudo-element:before", 'expect':
[] /*no matches*/, 'level': 2, 'testType': TEST_QSA_BASELINE}, |
| 267 {'name': "::before pseudo-element (two-colon syntax) selector, not match
ing any elements", 'selector': "#pseudo-element::before", 'expect':
[] /*no matches*/, 'level': 3, 'testType': TEST_QSA_ADDITIONAL}, |
| 268 |
| 269 // - ::after |
| 270 {'name': ":after pseudo-element (one-colon syntax) selector, not matchin
g any elements", 'selector': "#pseudo-element:after", 'expect':
[] /*no matches*/, 'level': 2, 'testType': TEST_QSA_BASELINE}, |
| 271 {'name': "::after pseudo-element (two-colon syntax) selector, not matchi
ng any elements", 'selector': "#pseudo-element::after", 'expect':
[] /*no matches*/, 'level': 3, 'testType': TEST_QSA_ADDITIONAL}, |
| 272 |
| 273 // Class Selectors |
| 274 {'name': "Class selector, matching element with specified class",
'selector': ".class-p", 'expe
ct': ["class-p1","class-p2", "class-p3"],
'level': 1, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 275 {'name': "Class selector, chained, matching only elements with all speci
fied classes", 'selector': "#class .apple.orange.banana",
'expect': ["class-div1", "class-div2", "class-p4", "class-div3", "class-p6", "
class-div4"], 'level': 1, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 276 {'name': "Class Selector, chained, with type selector",
'selector': "div.apple.banana.orange", 'expe
ct': ["class-div1", "class-div2", "class-div3", "class-div4"],
'level': 1, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 277 // Caution: If copying and pasting the folowing non-ASCII classes, ensur
e unicode normalisation is not performed in the process. |
| 278 {'name': "Class selector, matching element with class value using non-AS
CII characters", 'selector': ".台北Táiběi", 'expe
ct': ["class-span1"], 'level': 1, 'testType': TEST_QSA_BASELINE |
TEST_MATCH_BASELINE}, |
| 279 {'name': "Class selector, matching multiple elements with class value us
ing non-ASCII characters", 'selector': ".台北", 'expe
ct': ["class-span1","class-span2"], 'level': 1, 'testType': TEST_QSA_BASELINE |
TEST_MATCH_BASELINE}, |
| 280 {'name': "Class selector, chained, matching element with multiple class
values using non-ASCII characters", 'selector': ".台北Táiběi.台北", 'expe
ct': ["class-span1"], 'level': 1, 'testType': TEST_QSA_BASELINE |
TEST_MATCH_BASELINE}, |
| 281 {'name': "Class selector, matching element with class with escaped chara
cter", 'selector': ".foo\\:bar", 'expe
ct': ["class-span3"], 'level': 1, 'testType': TEST_QSA_BASELINE |
TEST_MATCH_BASELINE}, |
| 282 {'name': "Class selector, matching element with class with escaped chara
cter", 'selector': ".test\\.foo\\[5\\]bar", 'expe
ct': ["class-span4"], 'level': 1, 'testType': TEST_QSA_BASELINE |
TEST_MATCH_BASELINE}, |
| 283 |
| 284 // ID Selectors |
| 285 {'name': "ID selector, matching element with specified id", 's
elector': "#id #id-div1", 'expect': ["id-div1"], 'level'
: 1, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 286 {'name': "ID selector, chained, matching element with specified id", 's
elector': "#id-div1, #id-div1", 'expect': ["id-div1"], 'level'
: 1, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 287 {'name': "ID selector, chained, matching element with specified id", 's
elector': "#id-div1, #id-div2", 'expect': ["id-div1", "id-div2"], 'level'
: 1, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 288 {'name': "ID Selector, chained, with type selector", 's
elector': "div#id-div1, div#id-div2", 'expect': ["id-div1", "id-div2"], 'level'
: 1, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 289 {'name': "ID selector, not matching non-existent descendant", 's
elector': "#id #none", 'expect': [] /*no matches*/, 'level'
: 1, 'testType': TEST_QSA_BASELINE}, |
| 290 {'name': "ID selector, not matching non-existent ancestor", 's
elector': "#none #id-div1", 'expect': [] /*no matches*/, 'level'
: 1, 'testType': TEST_QSA_BASELINE}, |
| 291 {'name': "ID selector, matching multiple elements with duplicate id", 's
elector': "#id-li-duplicate", 'expect': ["id-li-duplicate", "id-li-dupl
icate", "id-li-duplicate", "id-li-duplicate"], 'level': 1, 'testType': TEST_QSA_
BASELINE | TEST_MATCH_BASELINE}, |
| 292 |
| 293 // Caution: If copying and pasting the folowing non-ASCII IDs, ensure un
icode normalisation is not performed in the process. |
| 294 {'name': "ID selector, matching id value using non-ASCII characters",
'selector': "#台北Táiběi", 'expect': ["台北Táiběi"], 'level': 1
, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 295 {'name': "ID selector, matching id value using non-ASCII characters",
'selector': "#台北", 'expect': ["台北"], 'level': 1
, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 296 {'name': "ID selector, matching id values using non-ASCII characters",
'selector': "#台北Táiběi, #台北", 'expect': ["台北Táiběi", "台北"], 'level': 1
, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 297 |
| 298 // XXX runMatchesTest() in level2-lib.js can't handle this because obtai
ning the expected nodes requires escaping characters when generating the selecto
r from 'expect' values |
| 299 {'name': "ID selector, matching element with id with escaped character",
'selector': "#\\#foo\\:bar", 'expect': ["#foo:bar"], 'level': 1
, 'testType': TEST_QSA_BASELINE}, |
| 300 {'name': "ID selector, matching element with id with escaped character",
'selector': "#test\\.foo\\[5\\]bar", 'expect': ["test.foo[5]bar"], 'level': 1
, 'testType': TEST_QSA_BASELINE}, |
| 301 |
| 302 // Namespaces |
| 303 // XXX runMatchesTest() in level2-lib.js can't handle these because non-
HTML elements don't have a recognised id |
| 304 {'name': "Namespace selector, matching element with any namespace",
'selector': "#any-namespace *|div", 'expect': ["any-namespace-div1", "any-nam
espace-div2", "any-namespace-div3", "any-namespace-div4"], 'level': 3, 'testType
': TEST_QSA_BASELINE}, |
| 305 {'name': "Namespace selector, matching div elements in no namespace only
", 'selector': "#no-namespace |div", 'expect': ["no-namespace-div3"], 'level':
3, 'testType': TEST_QSA_BASELINE}, |
| 306 {'name': "Namespace selector, matching any elements in no namespace only
", 'selector': "#no-namespace |*", 'expect': ["no-namespace-div3"], 'level':
3, 'testType': TEST_QSA_BASELINE}, |
| 307 |
| 308 // Combinators |
| 309 // - Descendant combinator ' ' |
| 310 {'name': "Descendant combinator, matching element that is a descendant o
f an element with id", 'selector': "#descendant div",
'expect': ["descendant-div1", "descendant-div2", "descendant-div3", "des
cendant-div4"], 'level': 1, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}
, |
| 311 {'name': "Descendant combinator, matching element with id that is a desc
endant of an element", 'selector': "body #descendant-div1",
'expect': ["descendant-div1"], 'exclude': ["detached", "fragment"], 'lev
el': 1, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 312 {'name': "Descendant combinator, matching element with id that is a desc
endant of an element", 'selector': "div #descendant-div1",
'expect': ["descendant-div1"], 'level
': 1, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 313 {'name': "Descendant combinator, matching element with id that is a desc
endant of an element with id", 'selector': "#descendant #descendant-div2
", 'expect': ["descendant-div2"], 'level
': 1, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 314 {'name': "Descendant combinator, matching element with class that is a d
escendant of an element with id", 'selector': "#descendant .descendant-div2
", 'expect': ["descendant-div2"], 'level
': 1, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 315 {'name': "Descendant combinator, matching element with class that is a d
escendant of an element with class", 'selector': ".descendant-div1 .descendant
-div3", 'expect': ["descendant-div3"], 'level
': 1, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 316 {'name': "Descendant combinator, not matching element with id that is no
t a descendant of an element with id", 'selector': "#descendant-div1 #descendant
-div4", 'expect': [] /*no matches*/, 'level
': 1, 'testType': TEST_QSA_BASELINE}, |
| 317 {'name': "Descendant combinator, whitespace characters",
'selector': "#descendant\t\r\n#descendant
-div2", 'expect': ["descendant-div2"], 'level
': 1, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 318 |
| 319 // - Child combinator '>' |
| 320 {'name': "Child combinator, matching element that is a child of an eleme
nt with id", 'selector': "#child>div",
'expect': ["child-div1", "child-div4"], 'level': 2, 'testType': TEST_QSA_B
ASELINE | TEST_MATCH_BASELINE}, |
| 321 {'name': "Child combinator, matching element with id that is a child of
an element", 'selector': "div>#child-div1",
'expect': ["child-div1"], 'level': 2, 'testType': TEST_QSA_B
ASELINE | TEST_MATCH_BASELINE}, |
| 322 {'name': "Child combinator, matching element with id that is a child of
an element with id", 'selector': "#child>#child-div1",
'expect': ["child-div1"], 'level': 2, 'testType': TEST_QSA_B
ASELINE | TEST_MATCH_BASELINE}, |
| 323 {'name': "Child combinator, matching element with id that is a child of
an element with class", 'selector': "#child-div1>.child-div2",
'expect': ["child-div2"], 'level': 2, 'testType': TEST_QSA_B
ASELINE | TEST_MATCH_BASELINE}, |
| 324 {'name': "Child combinator, matching element with class that is a child
of an element with class", 'selector': ".child-div1>.child-div2",
'expect': ["child-div2"], 'level': 2, 'testType': TEST_QSA_B
ASELINE | TEST_MATCH_BASELINE}, |
| 325 {'name': "Child combinator, not matching element with id that is not a c
hild of an element with id", 'selector': "#child>#child-div3",
'expect': [] /*no matches*/, 'level': 2, 'testType': TEST_QSA_B
ASELINE}, |
| 326 {'name': "Child combinator, not matching element with id that is not a c
hild of an element with class", 'selector': "#child-div1>.child-div3",
'expect': [] /*no matches*/, 'level': 2, 'testType': TEST_QSA_B
ASELINE}, |
| 327 {'name': "Child combinator, not matching element with class that is not
a child of an element with class", 'selector': ".child-div1>.child-div3",
'expect': [] /*no matches*/, 'level': 2, 'testType': TEST_QSA_B
ASELINE}, |
| 328 {'name': "Child combinator, surrounded by whitespace",
'selector': "#child-div1\t\r\n>\t\r\n#child-d
iv2", 'expect': ["child-div2"], 'level': 2, 'testType': TEST_QSA_B
ASELINE | TEST_MATCH_BASELINE}, |
| 329 {'name': "Child combinator, whitespace after",
'selector': "#child-div1>\t\r\n#child-div2",
'expect': ["child-div2"], 'level': 2, 'testType': TEST_QSA_B
ASELINE | TEST_MATCH_BASELINE}, |
| 330 {'name': "Child combinator, whitespace before",
'selector': "#child-div1\t\r\n>#child-div2",
'expect': ["child-div2"], 'level': 2, 'testType': TEST_QSA_B
ASELINE | TEST_MATCH_BASELINE}, |
| 331 {'name': "Child combinator, no whitespace",
'selector': "#child-div1>#child-div2",
'expect': ["child-div2"], 'level': 2, 'testType': TEST_QSA_B
ASELINE | TEST_MATCH_BASELINE}, |
| 332 |
| 333 // - Adjacent sibling combinator '+' |
| 334 {'name': "Adjacent sibling combinator, matching element that is an adjac
ent sibling of an element with id", 'selector': "#adjacent-div2+
div", 'expect': ["adjacent-div4"], 'leve
l': 2, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 335 {'name': "Adjacent sibling combinator, matching element with id that is
an adjacent sibling of an element", 'selector': "div+#adjacent-d
iv4", 'expect': ["adjacent-div4"], 'leve
l': 2, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 336 {'name': "Adjacent sibling combinator, matching element with id that is
an adjacent sibling of an element with id", 'selector': "#adjacent-div2+
#adjacent-div4", 'expect': ["adjacent-div4"], 'leve
l': 2, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 337 {'name': "Adjacent sibling combinator, matching element with class that
is an adjacent sibling of an element with id", 'selector': "#adjacent-div2+
.adjacent-div4", 'expect': ["adjacent-div4"], 'leve
l': 2, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 338 {'name': "Adjacent sibling combinator, matching element with class that
is an adjacent sibling of an element with class", 'selector': ".adjacent-div2+
.adjacent-div4", 'expect': ["adjacent-div4"], 'leve
l': 2, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 339 {'name': "Adjacent sibling combinator, matching p element that is an adj
acent sibling of a div element", 'selector': "#adjacent div+p
", 'expect': ["adjacent-p2"], 'leve
l': 2, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 340 {'name': "Adjacent sibling combinator, not matching element with id that
is not an adjacent sibling of an element with id", 'selector': "#adjacent-div2+
#adjacent-p2, #adjacent-div2+#adjacent-div1", 'expect': [] /*no matches*/, 'leve
l': 2, 'testType': TEST_QSA_BASELINE}, |
| 341 {'name': "Adjacent sibling combinator, surrounded by whitespace",
'selector': "#adjacent-p2\t\
r\n+\t\r\n#adjacent-p3", 'expect': ["adjacent-p3"], 'leve
l': 2, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 342 {'name': "Adjacent sibling combinator, whitespace after",
'selector': "#adjacent-p2+\t
\r\n#adjacent-p3", 'expect': ["adjacent-p3"], 'leve
l': 2, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 343 {'name': "Adjacent sibling combinator, whitespace before",
'selector': "#adjacent-p2\t\
r\n+#adjacent-p3", 'expect': ["adjacent-p3"], 'leve
l': 2, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 344 {'name': "Adjacent sibling combinator, no whitespace",
'selector': "#adjacent-p2+#a
djacent-p3", 'expect': ["adjacent-p3"], 'leve
l': 2, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELINE}, |
| 345 |
| 346 // - General sibling combinator ~ (Level 3) |
| 347 {'name': "General sibling combinator, matching element that is a sibling
of an element with id", 'selector': "#sibling-div2~div",
'expect': ["sibling-div4", "sibling-div6"],
'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 348 {'name': "General sibling combinator, matching element with id that is a
sibling of an element", 'selector': "div~#sibling-div4",
'expect': ["sibling-div4"],
'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 349 {'name': "General sibling combinator, matching element with id that is a
sibling of an element with id", 'selector': "#sibling-div2~#sibling-
div4", 'expect': ["sibling-div4"],
'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 350 {'name': "General sibling combinator, matching element with class that i
s a sibling of an element with id", 'selector': "#sibling-div2~.sibling-
div", 'expect': ["sibling-div4", "sibling-div6"],
'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELIN
E}, |
| 351 {'name': "General sibling combinator, matching p element that is a sibli
ng of a div element", 'selector': "#sibling div~p",
'expect': ["sibling-p2", "sibling-p3"],
'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}
, |
| 352 {'name': "General sibling combinator, not matching element with id that
is not a sibling after a p element", 'selector': "#sibling>p~div",
'expect': [] /*no matches*/,
'level': 3, 'testType': TEST_QSA_ADDITIONAL}, |
| 353 {'name': "General sibling combinator, not matching element with id that
is not a sibling after an element with id", 'selector': "#sibling-div2~#sibling-
div3, #sibling-div2~#sibling-div1", 'expect': [] /*no matches*/,
'level': 3, 'testType': TEST_QSA_ADDITIONAL}, |
| 354 {'name': "General sibling combinator, surrounded by whitespace",
'selector': "#sibling-p2\t\r\n~\t\r\
n#sibling-p3", 'expect': ["sibling-p3"],
'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 355 {'name': "General sibling combinator, whitespace after",
'selector': "#sibling-p2~\t\r\n#sibl
ing-p3", 'expect': ["sibling-p3"],
'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 356 {'name': "General sibling combinator, whitespace before",
'selector': "#sibling-p2\t\r\n~#sibl
ing-p3", 'expect': ["sibling-p3"],
'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 357 {'name': "General sibling combinator, no whitespace",
'selector': "#sibling-p2~#sibling-p3
", 'expect': ["sibling-p3"],
'level': 3, 'testType': TEST_QSA_ADDITIONAL | TEST_MATCH_BASELINE}, |
| 358 |
| 359 // Group of selectors (comma) |
| 360 {'name': "Syntax, group of selectors separator, surrounded by whitespace
", 'selector': "#group em\t\r \n,\t\r \n#group strong", 'expect': ["group-em1",
"group-strong1"], 'level': 1, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELIN
E}, |
| 361 {'name': "Syntax, group of selectors separator, whitespace after",
'selector': "#group em,\t\r\n#group strong", 'expect': ["group-em1",
"group-strong1"], 'level': 1, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELIN
E}, |
| 362 {'name': "Syntax, group of selectors separator, whitespace before",
'selector': "#group em\t\r\n,#group strong", 'expect': ["group-em1",
"group-strong1"], 'level': 1, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELIN
E}, |
| 363 {'name': "Syntax, group of selectors separator, no whitespace",
'selector': "#group em,#group strong", 'expect': ["group-em1",
"group-strong1"], 'level': 1, 'testType': TEST_QSA_BASELINE | TEST_MATCH_BASELIN
E}, |
| 364 ]; |
OLD | NEW |