Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(349)

Side by Side Diff: third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/selectors.js

Issue 1529523002: Import dom/ from web-platform-tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tweak W3CImportExpectations Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Bit-mapped flags to indicate which tests the selector is suitable for
2 var TEST_QSA = 0x01; // querySelector() and querySelectorAll() test s
3 var TEST_FIND = 0x04; // find() and findAll() tests, may be unsuitab le for querySelector[All]
4 var TEST_MATCH = 0x10; // matches() tests
5
6 /*
7 * All of these invalid selectors should result in a SyntaxError being thrown by the APIs.
8 *
9 * name: A descriptive name of the selector being tested
10 * selector: The selector to test
11 */
12 var invalidSelectors = [
13 {name: "Empty String", selector: ""},
14 {name: "Invalid character", selector: "["},
15 {name: "Invalid character", selector: "]"},
16 {name: "Invalid character", selector: "("},
17 {name: "Invalid character", selector: ")"},
18 {name: "Invalid character", selector: "{"},
19 {name: "Invalid character", selector: "}"},
20 {name: "Invalid character", selector: "<"},
21 {name: "Invalid character", selector: ">"},
22 {name: "Invalid ID", selector: "#"},
23 {name: "Invalid group of selectors", selector: "div,"},
24 {name: "Invalid class", selector: "."},
25 {name: "Invalid class", selector: ".5cm"},
26 {name: "Invalid class", selector: "..test"},
27 {name: "Invalid class", selector: ".foo..quux"},
28 {name: "Invalid class", selector: ".bar."},
29 {name: "Invalid combinator", selector: "div & address, p"},
30 {name: "Invalid combinator", selector: "div >> address, p"},
31 {name: "Invalid combinator", selector: "div ++ address, p"},
32 {name: "Invalid combinator", selector: "div ~~ address, p"},
33 {name: "Invalid [att=value] selector", selector: "[*=test]"},
34 {name: "Invalid [att=value] selector", selector: "[*|*=test]"},
35 {name: "Invalid [att=value] selector", selector: "[class= space unquoted ]"},
36 {name: "Unknown pseudo-class", selector: "div:example"},
37 {name: "Unknown pseudo-class", selector: ":example"},
38 {name: "Unknown pseudo-element", selector: "div::example"},
39 {name: "Unknown pseudo-element", selector: "::example"},
40 {name: "Invalid pseudo-element", selector: ":::before"},
41 {name: "Undeclared namespace", selector: "ns|div"},
42 {name: "Undeclared namespace", selector: ":not(ns|div)"},
43 {name: "Invalid namespace", selector: "^|div"},
44 {name: "Invalid namespace", selector: "$|div"}
45 ];
46
47 /*
48 * All of these should be valid selectors, expected to match zero or more elemen ts in the document.
49 * None should throw any errors.
50 *
51 * name: A descriptive name of the selector being tested
52 * selector: The selector to test
53 * expect: A list of IDs of the elements expected to be matched. List must b e given in tree order.
54 * exclude: An array of contexts to exclude from testing. The valid values ar e:
55 * ["document", "element", "fragment", "detached", "html", "xhtml"]
56 * The "html" and "xhtml" values represent the type of document bein g queried. These are useful
57 * for tests that are affected by differences between HTML and XML, such as case sensitivity.
58 * level: An integer indicating the CSS or Selectors level in which the sel ector being tested was introduced.
59 * testType: A bit-mapped flag indicating the type of test.
60 *
61 * Note: Interactive pseudo-classes (:active :hover and :focus) have not been te sted in this test suite.
62 */
63 var validSelectors = [
64 // Type Selector
65 {name: "Type selector, matching html element", selector: "html", expect: ["htm l"], exclude: ["element", "fragment", "detached"], level: 1, testType: TEST_QSA | TEST_MATCH},
66 {name: "Type selector, matching html element", selector: "html", expect: [] /* no matches*/, exclude: ["document"], level: 1, testType: TEST_QSA},
67 {name: "Type selector, matching body element", selector: "body", expect: ["bod y"], exclude: ["element", "fragment", "detached"], level: 1, testType: TEST_QSA | TEST_MATCH},
68 {name: "Type selector, matching body element", selector: "body", expect: [] /* no matches*/, exclude: ["document"], level: 1, testType: TEST_QSA},
69
70 // Universal Selector
71 // Testing "*" for entire an entire context node is handled separately.
72 {name: "Universal selector, matching all children of element with specified ID ", selector: "#universal>*", expect: ["universal-p1", "universal-hr1", " universal-pre1", "universal-p2", "universal-address1"], level: 2, testType: TEST _QSA | TEST_MATCH},
73 {name: "Universal selector, matching all grandchildren of element with specifi ed ID", selector: "#universal>*>*", expect: ["universal-code1", "universal-span 1", "universal-a1", "universal-code2"], level: 2, testType: TEST _QSA | TEST_MATCH},
74 {name: "Universal selector, matching all children of empty element with specif ied ID", selector: "#empty>*", expect: [] /*no matches*/, level: 2, testType: TEST _QSA},
75 {name: "Universal selector, matching all descendants of element with specified ID", selector: "#universal *", expect: ["universal-p1", "universal-code1", "universal-hr1", "universal-pre1", "universal-span1", "universal-p2", "universa l-a1", "universal-address1", "universal-code2", "universal-a2"], level: 2, testT ype: TEST_QSA | TEST_MATCH},
76
77 // Attribute Selectors
78 // - presence [att]
79 {name: "Attribute presence selector, matching align attribute with value", selector: ".attr-presence-div1[align]", expect: ["attr-presence-div1"], level: 2, testType: TEST_QSA | TEST_MATCH},
80 {name: "Attribute presence selector, matching align attribute with empty value ", selector: ".attr-presence-div2[align]", expect: ["attr-presence-div2"], level: 2, testType: TEST_QSA | TEST_MATCH},
81 {name: "Attribute presence selector, matching title attribute, case insensitiv ity", selector: "#attr-presence [TiTlE]", expect: ["attr-presence-a1", "attr-presence-span1"], exclude: ["xhtml"], level: 2, testType: TEST_QSA | TEST_MATCH},
82 {name: "Attribute presence selector, not matching title attribute, case sensit ivity", selector: "#attr-presence [TiTlE]", expect: [], exclude: ["html"], level: 2, testType: TEST_QSA | TEST_MATCH},
83 {name: "Attribute presence selector, matching custom data-* attribute", selector: "[data-attr-presence]", expect: ["attr-presence-pre1", "attr-presence-blockquote1"], level: 2, testType: TEST_QSA | TEST_MATCH},
84 {name: "Attribute presence selector, not matching attribute with similar name" , selector: ".attr-presence-div3[align], .attr-presence-div4[align ]", expect: [] /*no matches*/, level: 2, testType: TEST_QSA},
85 {name: "Attribute presence selector, matching attribute with non-ASCII charact ers", selector: "ul[data-中文]", expect: ["attr-presence-ul1"], level: 2, testType: TEST_QSA | TEST_MATCH},
86 {name: "Attribute presence selector, not matching default option without selec ted attribute", selector: "#attr-presence-select1 option[selected]", expect: [] /* no matches */, level: 2, testType: TEST_QSA},
87 {name: "Attribute presence selector, matching option with selected attribute", selector: "#attr-presence-select2 option[selected]", expect: ["attr-presence-select2-option4"], level: 2, testType: TEST_QSA | TEST_MATCH},
88 {name: "Attribute presence selector, matching multiple options with selected a ttributes", selector: "#attr-presence-select3 option[selected]", expect: ["attr-presence-select3-option2", "attr-presence-select3-option3"], level: 2, testType: TEST_QSA | TEST_MATCH},
89
90 // - value [att=val]
91 {name: "Attribute value selector, matching align attribute with value", selector: "#attr-value [align=\"center\"]", expect: ["attr-value-div1"], level: 2, testType: TE ST_QSA | TEST_MATCH},
92 {name: "Attribute value selector, matching align attribute with empty value", selector: "#attr-value [align=\"\"]", expect: ["attr-value-div2"], level: 2, testType: TE ST_QSA | TEST_MATCH},
93 {name: "Attribute value selector, not matching align attribute with partial va lue", selector: "#attr-value [align=\"c\"]", expect: [] /*no matches*/, level: 2, testType: TE ST_QSA},
94 {name: "Attribute value selector, not matching align attribute with incorrect value", selector: "#attr-value [align=\"centera\"]", expect: [] /*no matches*/, level: 2, testType: TE ST_QSA},
95 {name: "Attribute value selector, matching custom data-* attribute with unicod e escaped value", selector: "[data-attr-value=\"\\e9\"]", expect: ["attr-value-div3"], level: 2, testType: TE ST_QSA | TEST_MATCH},
96 {name: "Attribute value selector, matching custom data-* attribute with escape d character", selector: "[data-attr-value\_foo=\"\\e9\"]", expect: ["attr-value-div4"], level: 2, testType: TE ST_QSA | TEST_MATCH},
97 {name: "Attribute value selector with single-quoted value, matching multiple i nputs with type attributes", selector: "#attr-value input[type='hidden'],#attr-v alue input[type='radio']", expect: ["attr-value-input3", "attr-value-input4", "attr-value-input6", "attr-value-input8", "attr-value-input9"], level: 2, testTy pe: TEST_QSA | TEST_MATCH},
98 {name: "Attribute value selector with double-quoted value, matching multiple i nputs with type attributes", selector: "#attr-value input[type=\"hidden\"],#attr -value input[type='radio']", expect: ["attr-value-input3", "attr-value-input4", "attr-value-input6", "attr-value-input8", "attr-value-input9"], level: 2, testTy pe: TEST_QSA | TEST_MATCH},
99 {name: "Attribute value selector with unquoted value, matching multiple inputs with type attributes", selector: "#attr-value input[type=hidden],#attr-val ue input[type=radio]", expect: ["attr-value-input3", "attr-value-input4", "attr-value-input6", "attr-value-input8", "attr-value-input9"], level: 2, testTy pe: TEST_QSA | TEST_MATCH},
100 {name: "Attribute value selector, matching attribute with value using non-ASCI I characters", selector: "[data-attr-value=中文]", expect: ["attr-value-div5"], level: 2, testType: TE ST_QSA | TEST_MATCH},
101
102 // - whitespace-separated list [att~=val]
103 {name: "Attribute whitespace-separated list selector, matching class attribute with value", selector: "#attr-whitespace [clas s~=\"div1\"]", expect: ["attr-whitespace- div1"], level: 2, testType: TEST_QSA | TEST_MATCH},
104 {name: "Attribute whitespace-separated list selector, not matching class attri bute with empty value", selector: "#attr-whitespace [clas s~=\"\"]", expect: [] /*no matches*/ , level: 2, testType: TEST_QSA},
105 {name: "Attribute whitespace-separated list selector, not matching class attri bute with partial value", selector: "[data-attr-whitespace~ =\"div\"]", expect: [] /*no matches*/ , level: 2, testType: TEST_QSA},
106 {name: "Attribute whitespace-separated list selector, matching custom data-* a ttribute with unicode escaped value", selector: "[data-attr-whitespace~ =\"\\0000e9\"]", expect: ["attr-whitespace- div4"], level: 2, testType: TEST_QSA | TEST_MATCH},
107 {name: "Attribute whitespace-separated list selector, matching custom data-* a ttribute with escaped character", selector: "[data-attr-whitespace\ _foo~=\"\\e9\"]", expect: ["attr-whitespace- div5"], level: 2, testType: TEST_QSA | TEST_MATCH},
108 {name: "Attribute whitespace-separated list selector with single-quoted value, matching multiple links with rel attributes", selector: "#attr-whitespace a[rel ~='bookmark'], #attr-whitespace a[rel~='nofollow']", expect: ["attr-whitespace- a1", "attr-whitespace-a2", "attr-whitespace-a3", "attr-whitespace-a5", "attr-whi tespace-a7"], level: 2, testType: TEST_QSA | TEST_MATCH},
109 {name: "Attribute whitespace-separated list selector with double-quoted value, matching multiple links with rel attributes", selector: "#attr-whitespace a[rel ~=\"bookmark\"],#attr-whitespace a[rel~='nofollow']", expect: ["attr-whitespace- a1", "attr-whitespace-a2", "attr-whitespace-a3", "attr-whitespace-a5", "attr-whi tespace-a7"], level: 2, testType: TEST_QSA | TEST_MATCH},
110 {name: "Attribute whitespace-separated list selector with unquoted value, matc hing multiple links with rel attributes", selector: "#attr-whitespace a[rel ~=bookmark], #attr-whitespace a[rel~=nofollow]", expect: ["attr-whitespace- a1", "attr-whitespace-a2", "attr-whitespace-a3", "attr-whitespace-a5", "attr-whi tespace-a7"], level: 2, testType: TEST_QSA | TEST_MATCH},
111 {name: "Attribute whitespace-separated list selector with double-quoted value, not matching value with space", selector: "#attr-whitespace a[rel ~=\"book mark\"]", expect: [] /* no matches * /, level: 2, testType: TEST_QSA},
112 {name: "Attribute whitespace-separated list selector, matching title attribute with value using non-ASCII characters", selector: "#attr-whitespace [titl e~=中文]", expect: ["attr-whitespace- p1"], level: 2, testType: TEST_QSA | TEST_MATCH},
113
114 // - hyphen-separated list [att|=val]
115 {name: "Attribute hyphen-separated list selector, not matching unspecified lan g attribute", selector: "#attr-hyphen-div1[lang|=\"en\"]", expect: [] /*no matches*/, level: 2, testType: TEST_QSA},
116 {name: "Attribute hyphen-separated list selector, matching lang attribute with exact value", selector: "#attr-hyphen-div2[lang|=\"fr\"]", expect: ["attr- hyphen-div2"], level: 2, testType: TEST_QSA | TEST_MATCH},
117 {name: "Attribute hyphen-separated list selector, matching lang attribute with partial value", selector: "#attr-hyphen-div3[lang|=\"en\"]", expect: ["attr- hyphen-div3"], level: 2, testType: TEST_QSA | TEST_MATCH},
118 {name: "Attribute hyphen-separated list selector, not matching incorrect value ", selector: "#attr-hyphen-div4[lang|=\"es-AR\"]", expect: [] /*no matches*/, level: 2, testType: TEST_QSA},
119
120 // - substring begins-with [att^=val] (Level 3)
121 {name: "Attribute begins with selector, matching href attributes beginning wit h specified substring", selector: "#attr-begins a[hr ef^=\"http://www\"]", expect: ["attr-begins-a1", "attr-begins-a3"], level: 3 , testType: TEST_QSA | TEST_MATCH},
122 {name: "Attribute begins with selector, matching lang attributes beginning wit h specified substring, ", selector: "#attr-begins [lan g^=\"en-\"]", expect: ["attr-begins-div2", "attr-begins-div4"], level: 3 , testType: TEST_QSA | TEST_MATCH},
123 {name: "Attribute begins with selector, not matching class attribute not begin ning with specified substring", selector: "#attr-begins [cla ss^=apple]", expect: [] /*no matches*/, level: 3 , testType: TEST_QSA},
124 {name: "Attribute begins with selector with single-quoted value, matching clas s attribute beginning with specified substring", selector: "#attr-begins [cla ss^=' apple']", expect: ["attr-begins-p1"], level: 3 , testType: TEST_QSA | TEST_MATCH},
125 {name: "Attribute begins with selector with double-quoted value, matching clas s attribute beginning with specified substring", selector: "#attr-begins [cla ss^=\" apple\"]", expect: ["attr-begins-p1"], level: 3 , testType: TEST_QSA | TEST_MATCH},
126 {name: "Attribute begins with selector with unquoted value, not matching class attribute not beginning with specified substring", selector: "#attr-begins [cla ss^= apple]", expect: [] /*no matches*/, level: 3 , testType: TEST_QSA},
127
128 // - substring ends-with [att$=val] (Level 3)
129 {name: "Attribute ends with selector, matching href attributes ending with spe cified substring", selector: "#attr-ends a[href$=\". org\"]", expect: ["attr-ends-a1", "attr-ends-a3"], level: 3, testType: TES T_QSA | TEST_MATCH},
130 {name: "Attribute ends with selector, matching lang attributes ending with spe cified substring, ", selector: "#attr-ends [lang$=\"-C H\"]", expect: ["attr-ends-div2", "attr-ends-div4"], level: 3, testType: TES T_QSA | TEST_MATCH},
131 {name: "Attribute ends with selector, not matching class attribute not ending with specified substring", selector: "#attr-ends [class$=app le]", expect: [] /*no matches*/, level: 3, testType: TES T_QSA},
132 {name: "Attribute ends with selector with single-quoted value, matching class attribute ending with specified substring", selector: "#attr-ends [class$='ap ple ']", expect: ["attr-ends-p1"], level: 3, testType: TES T_QSA | TEST_MATCH},
133 {name: "Attribute ends with selector with double-quoted value, matching class attribute ending with specified substring", selector: "#attr-ends [class$=\"a pple \"]", expect: ["attr-ends-p1"], level: 3, testType: TES T_QSA | TEST_MATCH},
134 {name: "Attribute ends with selector with unquoted value, not matching class a ttribute not ending with specified substring", selector: "#attr-ends [class$=app le ]", expect: [] /*no matches*/, level: 3, testType: TES T_QSA},
135
136 // - substring contains [att*=val] (Level 3)
137 {name: "Attribute contains selector, matching href attributes beginning with s pecified substring", selector: "#attr-contains a[href*= \"http://www\"]", expect: ["attr-contains-a1", "attr-contains-a3"], leve l: 3, testType: TEST_QSA | TEST_MATCH},
138 {name: "Attribute contains selector, matching href attributes ending with spec ified substring", selector: "#attr-contains a[href*= \".org\"]", expect: ["attr-contains-a1", "attr-contains-a2"], leve l: 3, testType: TEST_QSA | TEST_MATCH},
139 {name: "Attribute contains selector, matching href attributes containing speci fied substring", selector: "#attr-contains a[href*= \".example.\"]", expect: ["attr-contains-a1", "attr-contains-a3"], leve l: 3, testType: TEST_QSA | TEST_MATCH},
140 {name: "Attribute contains selector, matching lang attributes beginning with s pecified substring, ", selector: "#attr-contains [lang*=\ "en-\"]", expect: ["attr-contains-div2", "attr-contains-div6"], leve l: 3, testType: TEST_QSA | TEST_MATCH},
141 {name: "Attribute contains selector, matching lang attributes ending with spec ified substring, ", selector: "#attr-contains [lang*=\ "-CH\"]", expect: ["attr-contains-div3", "attr-contains-div5"], leve l: 3, testType: TEST_QSA | TEST_MATCH},
142 {name: "Attribute contains selector with single-quoted value, matching class a ttribute beginning with specified substring", selector: "#attr-contains [class*= ' apple']", expect: ["attr-contains-p1"], leve l: 3, testType: TEST_QSA | TEST_MATCH},
143 {name: "Attribute contains selector with single-quoted value, matching class a ttribute ending with specified substring", selector: "#attr-contains [class*= 'orange ']", expect: ["attr-contains-p1"], leve l: 3, testType: TEST_QSA | TEST_MATCH},
144 {name: "Attribute contains selector with single-quoted value, matching class a ttribute containing specified substring", selector: "#attr-contains [class*= 'ple banana ora']", expect: ["attr-contains-p1"], leve l: 3, testType: TEST_QSA | TEST_MATCH},
145 {name: "Attribute contains selector with double-quoted value, matching class a ttribute beginning with specified substring", selector: "#attr-contains [class*= \" apple\"]", expect: ["attr-contains-p1"], leve l: 3, testType: TEST_QSA | TEST_MATCH},
146 {name: "Attribute contains selector with double-quoted value, matching class a ttribute ending with specified substring", selector: "#attr-contains [class*= \"orange \"]", expect: ["attr-contains-p1"], leve l: 3, testType: TEST_QSA | TEST_MATCH},
147 {name: "Attribute contains selector with double-quoted value, matching class a ttribute containing specified substring", selector: "#attr-contains [class*= \"ple banana ora\"]", expect: ["attr-contains-p1"], leve l: 3, testType: TEST_QSA | TEST_MATCH},
148 {name: "Attribute contains selector with unquoted value, matching class attrib ute beginning with specified substring", selector: "#attr-contains [class*= apple]", expect: ["attr-contains-p1"], leve l: 3, testType: TEST_QSA | TEST_MATCH},
149 {name: "Attribute contains selector with unquoted value, matching class attrib ute ending with specified substring", selector: "#attr-contains [class*= orange ]", expect: ["attr-contains-p1"], leve l: 3, testType: TEST_QSA | TEST_MATCH},
150 {name: "Attribute contains selector with unquoted value, matching class attrib ute containing specified substring", selector: "#attr-contains [class*= banana ]", expect: ["attr-contains-p1"], leve l: 3, testType: TEST_QSA | TEST_MATCH},
151
152 // Pseudo-classes
153 // - :root (Level 3)
154 {name: ":root pseudo-class selector, matching document root element", sel ector: ":root", expect: ["html"], exclude: ["element", "fragment", "det ached"], level: 3, testType: TEST_QSA | TEST_MATCH},
155 {name: ":root pseudo-class selector, not matching document root element", sel ector: ":root", expect: [] /*no matches*/, exclude: ["document"], level: 3, testType: TEST_QSA},
156
157 // - :nth-child(n) (Level 3)
158 // XXX write descriptions
159 {name: ":nth-child selector, matching the third child element", selector: "#pseudo-nth-table1 :nth-child(3)", expect: ["pseudo-nt h-td3", "pseudo-nth-td9", "pseudo-nth-tr3", "pseudo-nth-td15"], level: 3, testType: TEST_QSA | TEST_MATCH},
160 {name: ":nth-child selector, matching every third child element", selector: "#pseudo-nth li:nth-child(3n)", expect: ["pseudo-nt h-li3", "pseudo-nth-li6", "pseudo-nth-li9", "pseudo-nth-li12"], level: 3, testType: TEST_QSA | TEST_MATCH},
161 {name: ":nth-child selector, matching every second child element, starting fro m the fourth", selector: "#pseudo-nth li:nth-child(2n+4)", expect: ["pseudo-nt h-li4", "pseudo-nth-li6", "pseudo-nth-li8", "pseudo-nth-li10", "pseudo-nth-li12" ], level: 3, testType: TEST_QSA | TEST_MATCH},
162 {name: ":nth-child selector, matching every fourth child element, starting fro m the third", selector: "#pseudo-nth-p1 :nth-child(4n-1)", expect: ["pseudo-nt h-em2", "pseudo-nth-span3"], level: 3, testType: TEST_QSA | TEST_MATCH},
163
164 // - :nth-last-child (Level 3)
165 {name: ":nth-last-child selector, matching the third last child element", selector: "#pseudo-nth-table1 :nth-last-ch ild(3)", expect: ["pseudo-nth-tr1", "pseudo-nth-td4", "pseudo-nth-td10", "pseudo -nth-td16"], level: 3, testType: TEST_QSA | TEST_MATCH},
166 {name: ":nth-last-child selector, matching every third child element from the end", selector: "#pseudo-nth li:nth-last-child(3 n)", expect: ["pseudo-nth-li1", "pseudo-nth-li4", "pseudo-nth-li7", "pseudo- nth-li10"], level: 3, testType: TEST_QSA | TEST_MATCH},
167 {name: ":nth-last-child selector, matching every second child element from the end, starting from the fourth last", selector: "#pseudo-nth li:nth-last-child(2 n+4)", expect: ["pseudo-nth-li1", "pseudo-nth-li3", "pseudo-nth-li5", "pseudo- nth-li7", "pseudo-nth-li9"], level: 3, testType: TEST_QSA | TEST_MATCH},
168 {name: ":nth-last-child selector, matching every fourth element from the end, starting from the third last", selector: "#pseudo-nth-p1 :nth-last-child( 4n-1)", expect: ["pseudo-nth-span2", "pseudo-nth-span4"], level: 3, testType: TEST_QSA | TEST_MATCH},
169
170 // - :nth-of-type(n) (Level 3)
171 {name: ":nth-of-type selector, matching the third em element", selector: "#pseudo-nth-p1 em:nth-of-type(3)", expec t: ["pseudo-nth-em3"], level: 3, testType: TEST_QSA | TEST_MATCH},
172 {name: ":nth-of-type selector, matching every second element of their type", selector: "#pseudo-nth-p1 :nth-of-type(2n)", expec t: ["pseudo-nth-em2", "pseudo-nth-span2", "pseudo-nth-span4", "pseudo-nth-strong 2", "pseudo-nth-em4"], level: 3, testType: TEST_QSA | TEST_MATCH},
173 {name: ":nth-of-type selector, matching every second elemetn of their type, st arting from the first", selector: "#pseudo-nth-p1 span:nth-of-type(2n-1)", expec t: ["pseudo-nth-span1", "pseudo-nth-span3"], level: 3, testType: TEST_QSA | TEST_MATCH},
174
175 // - :nth-last-of-type(n) (Level 3)
176 {name: ":nth-last-of-type selector, matching the thrid last em element", selec tor: "#pseudo-nth-p1 em:nth-last-of-type(3)", expect: ["pseudo-nth-em2"], l evel: 3, testType: TEST_QSA | TEST_MATCH},
177 {name: ":nth-last-of-type selector, matching every second last element of thei r type", selector: "#pseudo-nth-p1 :nth-last-of-type(2n)", expect: ["pseud o-nth-span1", "pseudo-nth-em1", "pseudo-nth-strong1", "pseudo-nth-em3", "pseudo- nth-span3"], level: 3, testType: TEST_QSA | TEST_MATCH},
178 {name: ":nth-last-of-type selector, matching every second last element of thei r type, starting from the last", selector: "#pseudo-nth-p1 span:nth-last-of-type (2n-1)", expect: ["pseudo-nth-span2", "pseudo-nth-span4"], level: 3, testType: TEST_QSA | TEST_MATCH},
179
180 // - :first-of-type (Level 3)
181 {name: ":first-of-type selector, matching the first em element", selector: "#p seudo-nth-p1 em:first-of-type", expect: ["pseudo-nth-em1"], level: 3, testType: TEST_QSA | TEST_MATCH},
182 {name: ":first-of-type selector, matching the first of every type of element", selector: "#pseudo-nth-p1 :first-of-type", expect: ["pseudo-nth-span1", "pseudo-nth-em1", "pseudo-nth-strong1"], level: 3, testType: TEST_QSA | TEST_MAT CH},
183 {name: ":first-of-type selector, matching the first td element in each table r ow", selector: "#pseudo-nth-table1 tr :first-of-type", expect: ["pseudo-nth-td1" , "pseudo-nth-td7", "pseudo-nth-td13"], level: 3, testType: TEST_QSA | TEST _MATCH},
184
185 // - :last-of-type (Level 3)
186 {name: ":last-of-type selector, matching the last em elemnet", selector: "#pse udo-nth-p1 em:last-of-type", expect: ["pseudo-nth-em4"], level: 3, testType: TEST_QSA | TEST_MATCH},
187 {name: ":last-of-type selector, matching the last of every type of element", s elector: "#pseudo-nth-p1 :last-of-type", expect: ["pseudo-nth-span4", "ps eudo-nth-strong2", "pseudo-nth-em4"], level: 3, testType: TEST_QSA | TEST_MATCH} ,
188 {name: ":last-of-type selector, matching the last td element in each table row ", selector: "#pseudo-nth-table1 tr :last-of-type", expect: ["pseudo-nth-td6", " pseudo-nth-td12", "pseudo-nth-td18"], level: 3, testType: TEST_QSA | TEST_MA TCH},
189
190 // - :first-child
191 {name: ":first-child pseudo-class selector, matching first child div element", selector: "#pseudo-first-child div:first-child", expect: ["pseudo-first-child-div1"], level: 2, testType: TEST_QSA | TEST_MATCH},
192 {name: ":first-child pseudo-class selector, doesn't match non-first-child elem ents", selector: ".pseudo-first-child-div2:first-child, .pseudo-first-child-d iv3:first-child", expect: [] /*no matches*/, level: 2, testType: TEST_QSA},
193 {name: ":first-child pseudo-class selector, matching first-child of multiple e lements", 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 | TEST_MATCH},
194
195 // - :last-child (Level 3)
196 {name: ":last-child pseudo-class selector, matching last child div element", selector: "#pseudo-last-child div:last-child", expect: ["pseudo-last-child-div3"], level: 3, testType: TEST_QSA | TEST_MATCH},
197 {name: ":last-child pseudo-class selector, doesn't match non-last-child elemen ts", selector: ".pseudo-last-child-div1:last-child, .pseudo-last-child-div2: first-child", expect: [] /*no matches*/, level: 3, testType: TEST_QSA},
198 {name: ":last-child pseudo-class selector, matching first-child of multiple el ements", selector: "#pseudo-last-child span:last-child", expect: ["pseudo-last-child-span2", "pseudo-last-child-span4", "ps eudo-last-child-span6"], level: 3, testType: TEST_QSA | TEST_MATCH},
199
200 // - :only-child (Level 3)
201 {name: ":pseudo-only-child pseudo-class selector, matching all only-child elem ents", selector: "#pseudo-only :only-child", expect: ["pseudo-only-span1"], leve l: 3, testType: TEST_QSA | TEST_MATCH},
202 {name: ":pseudo-only-child pseudo-class selector, matching only-child em eleme nts", selector: "#pseudo-only em:only-child", expect: [] /*no matches*/, leve l: 3, testType: TEST_QSA},
203
204 // - :only-of-type (Level 3)
205 {name: ":pseudo-only-of-type pseudo-class selector, matching all elements with no siblings of the same type", selector: "#pseudo-only :only-of-type", expect: ["pseudo-only-span1", "pseudo-only-em1"], level: 3, testType: TEST_QSA | TEST_MA TCH},
206 {name: ":pseudo-only-of-type pseudo-class selector, matching em elements with no siblings of the same type", selector: "#pseudo-only em:only-of-type", expect : ["pseudo-only-em1"], level: 3, testType: TEST_QSA | TEST_MA TCH},
207
208 // - :empty (Level 3)
209 {name: ":empty pseudo-class selector, matching empty p elements", selector: "#pseudo-empty p:empty", expect: ["pseudo-empty-p1", "pseudo-empty-p2"], level: 3, testType: TEST_QSA | TEST_MATCH},
210 {name: ":empty pseudo-class selector, matching all empty elements", selector: "#pseudo-empty :empty", expect: ["pseudo-empty-p1", "pseudo-empty-p2", "pseudo- empty-span1"], level: 3, testType: TEST_QSA | TEST_MATCH},
211
212 // - :link and :visited
213 // Implementations may treat all visited links as unvisited, so these cannot b e tested separately.
214 // The only guarantee is that ":link,:visited" matches the set of all visited and unvisited links and that they are individually mutually exclusive sets.
215 {name: ":link and :visited pseudo-class selectors, matching a and area element s with href attributes", selector: "#pseudo-link :link, #pseudo-link :vis ited", expect: ["pseudo-link-a1", "pseudo-link-a2", "pseudo-link-area1"], level: 1, testType: TEST_QSA | TEST_MATCH},
216 {name: ":link and :visited pseudo-class selectors, matching link elements with href attributes", selector: "#head :link, #head :visited", expect: ["pseudo-link-link1", "pseudo-link-link2"], exclude: ["element", "fragment", "detached"], level: 1, testType: TEST_QSA | TEST_MATCH},
217 {name: ":link and :visited pseudo-class selectors, not matching link elements with href attributes", selector: "#head :link, #head :visited", expect: [] /*no matches*/, exclude: ["document"] , level: 1, testType: TEST_QSA},
218 {name: ":link and :visited pseudo-class selectors, chained, mutually exclusive pseudo-classes match nothing", selector: ":link:visited", expect: [] /*no matches*/, exclude: ["document"] , level: 1, testType: TEST_QSA},
219
220 // - :target (Level 3)
221 {name: ":target pseudo-class selector, matching the element referenced by the URL fragment identifier", selector: ":target", expect: [] /*no matches*/, exclud e: ["document", "element"], level: 3, testType: TEST_QSA},
222 {name: ":target pseudo-class selector, matching the element referenced by the URL fragment identifier", selector: ":target", expect: ["target"], exclud e: ["fragment", "detached"], level: 3, testType: TEST_QSA | TEST_MATCH},
223
224 // - :lang()
225 {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 | TEST_MATCH},
226 {name: ":lang pseudo-class selector, not matching element with no inherited la nguage", selector: "#pseudo-lang-div1:lang(en)", expect: [] /*no matches*/, exclude: ["document", "element"], level: 2, testType: TEST_QSA},
227 {name: ":lang pseudo-class selector, matching specified language with exact va lue", selector: "#pseudo-lang-div2:lang(fr)", expect: ["pseudo-lang-div2"] , level: 2, testType: TEST_QSA | TEST_MATCH},
228 {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_QSA | TEST_MATCH},
229 {name: ":lang pseudo-class selector, not matching incorrect language", selector: "#pseudo-lang-div4:lang(es-AR)", expect: [] /*no matches*/, level: 2, testType: TEST_QSA},
230
231 // - :enabled (Level 3)
232 {name: ":enabled pseudo-class selector, matching all enabled form controls", selector: "#pseudo-ui :enabled", expect: ["pseudo-ui-input1", "pseudo-ui-input2 ", "pseudo-ui-input3", "pseudo-ui-input4", "pseudo-ui-input5", "pseudo-ui-input6 ",
233 "pseudo-ui-input7", "pseudo-ui-input8 ", "pseudo-ui-input9", "pseudo-ui-textarea1", "pseudo-ui-button1"], level: 3, testType: TEST_QSA | TEST_MATCH},
234
235 // - :disabled (Level 3)
236 {name: ":enabled pseudo-class selector, matching all disabled form controls", selector: "#pseudo-ui :disabled", expect: ["pseudo-ui-input10", "pseudo-ui-input 11", "pseudo-ui-input12", "pseudo-ui-input13", "pseudo-ui-input14", "pseudo-ui-i nput15",
237 "pseudo-ui-input16", "pseudo-ui-input 17", "pseudo-ui-input18", "pseudo-ui-textarea2", "pseudo-ui-button2"], level: 3, testType: TEST_QSA | TEST_MATCH},
238
239 // - :checked (Level 3)
240 {name: ":checked pseudo-class selector, matching checked radio buttons and che ckboxes", selector: "#pseudo-ui :checked", expect: ["pseudo-ui-input4", "pseudo- ui-input6", "pseudo-ui-input13", "pseudo-ui-input15"], level: 3, testType: TEST _QSA | TEST_MATCH},
241
242 // - :not(s) (Level 3)
243 {name: ":not pseudo-class selector, matching ", selector: "#not>:not(div)", expect: ["not-p1", "not-p2", "not-p3"], level: 3, testType: TEST_QSA | TEST_MATC H},
244 {name: ":not pseudo-class selector, matching ", selector: "#not * :not(:first- child)", expect: ["not-em1", "not-em2", "not-em3"], level: 3, testType: TEST_Q SA | TEST_MATCH},
245 {name: ":not pseudo-class selector, matching nothing", selector: ":not(*)", expect: [] /* no matches */, level: 3, testType: TEST_QSA},
246 {name: ":not pseudo-class selector, matching nothing", selector: ":not(*|*)", expect: [] /* no matches */, level: 3, testType: TEST_QSA},
247
248 // Pseudo-elements
249 // - ::first-line
250 {name: ":first-line pseudo-element (one-colon syntax) selector, not matching a ny elements", selector: "#pseudo-element:first-line", expect: [] /*no matc hes*/, level: 2, testType: TEST_QSA},
251 {name: "::first-line pseudo-element (two-colon syntax) selector, not matching any elements", selector: "#pseudo-element::first-line", expect: [] /*no matc hes*/, level: 3, testType: TEST_QSA},
252
253 // - ::first-letter
254 {name: ":first-letter pseudo-element (one-colon syntax) selector, not matching any elements", selector: "#pseudo-element:first-letter", expect: [] /*no matc hes*/, level: 2, testType: TEST_QSA},
255 {name: "::first-letter pseudo-element (two-colon syntax) selector, not matchin g any elements", selector: "#pseudo-element::first-letter", expect: [] /*no matc hes*/, level: 3, testType: TEST_QSA},
256
257 // - ::before
258 {name: ":before pseudo-element (one-colon syntax) selector, not matching any e lements", selector: "#pseudo-element:before", expect: [] /*no matc hes*/, level: 2, testType: TEST_QSA},
259 {name: "::before pseudo-element (two-colon syntax) selector, not matching any elements", selector: "#pseudo-element::before", expect: [] /*no matc hes*/, level: 3, testType: TEST_QSA},
260
261 // - ::after
262 {name: ":after pseudo-element (one-colon syntax) selector, not matching any el ements", selector: "#pseudo-element:after", expect: [] /*no matc hes*/, level: 2, testType: TEST_QSA},
263 {name: "::after pseudo-element (two-colon syntax) selector, not matching any e lements", selector: "#pseudo-element::after", expect: [] /*no matc hes*/, level: 3, testType: TEST_QSA},
264
265 // Class Selectors
266 {name: "Class selector, matching element with specified class", selector: ".class-p", expect: ["class -p1","class-p2", "class-p3"], level : 1, testType: TEST_QSA | TEST_MATCH},
267 {name: "Class selector, chained, matching only elements with all specified cla sses", selector: "#class .apple.orange.banana", expect: ["class-div1", "class-div2", "class-p4", "class-div3", "class-p6", "class-div4"] , level: 1, testType: TEST_QSA | TEST_MATCH},
268 {name: "Class Selector, chained, with type selector", selector: "div.apple.banana.orange", expect: ["class -div1", "class-div2", "class-div3", "class-div4"], level : 1, testType: TEST_QSA | TEST_MATCH},
269 {name: "Class selector, matching element with class value using non-ASCII char acters (1)", selector: ".\u53F0\u5317Ta\u0301ibe\u030Ci", expect: ["class-span1"], level: 1, testType: TEST_QSA | TEST_ MATCH},
270 {name: "Class selector, matching multiple elements with class value using non- ASCII characters", selector: ".\u53F0\u5317", expec t: ["class-span1","class-span2"], level: 1, testType: TEST_QSA | TEST_MATCH},
271 {name: "Class selector, chained, matching element with multiple class values u sing non-ASCII characters (1)", selector: ".\u53F0\u5317Ta\u0301ibe\u030Ci.\u53F 0\u5317", expect: ["class-span1"], level: 1, testType: TE ST_QSA | TEST_MATCH},
272 {name: "Class selector, matching element with class with escaped character", selector: ".foo\\:bar", expect: ["class -span3"], level: 1, testType: TEST_QSA | TEST_MATCH},
273 {name: "Class selector, matching element with class with escaped character", selector: ".test\\.foo\\[5\\]bar", expect: ["class -span4"], level: 1, testType: TEST_QSA | TEST_MATCH},
274
275 // ID Selectors
276 {name: "ID selector, matching element with specified id", selector: "#id #id-div1", expect: ["id-div1"], level: 1, testType: TEST_QSA | TEST_MATCH},
277 {name: "ID selector, chained, matching element with specified id", selector: "#id-div1, #id-div1", expect: ["id-div1"], level: 1, testType: TEST_QSA | TEST_MATCH},
278 {name: "ID selector, chained, matching element with specified id", selector: "#id-div1, #id-div2", expect: ["id-div1", "id-div2"], level: 1, testType: TEST_QSA | TEST_MATCH},
279 {name: "ID Selector, chained, with type selector", selector: "div#id-div1, div#id-div2", expect: ["id-div1", "id-div2"], level: 1, testType: TEST_QSA | TEST_MATCH},
280 {name: "ID selector, not matching non-existent descendant", selector: "#id #none", expect: [] /*no matches*/, level: 1, testType: TEST_QSA},
281 {name: "ID selector, not matching non-existent ancestor", selector: "#none #id-div1", expect: [] /*no matches*/, level: 1, testType: TEST_QSA},
282 {name: "ID selector, matching multiple elements with duplicate id", selector: "#id-li-duplicate", expect: ["id-li-duplicate", "id-li-duplicate", "id- li-duplicate", "id-li-duplicate"], level: 1, testType: TEST_QSA | TEST_MATCH},
283
284 {name: "ID selector, matching id value using non-ASCII characters (1)", sel ector: "#\u53F0\u5317Ta\u0301ibe\u030Ci", expect: ["\u53F0\u5317Ta\u03 01ibe\u030Ci"], level: 1, testType: TEST_QSA | TEST_MATCH},
285 {name: "ID selector, matching id value using non-ASCII characters (2)", sel ector: "#\u53F0\u5317", expect: ["\u53F0\u5317"], level: 1, testType: TEST_QSA | TEST_MATCH},
286 {name: "ID selector, matching id values using non-ASCII characters (1)", selec tor: "#\u53F0\u5317Ta\u0301ibe\u030Ci, #\u53F0\u5317", expect: ["\u53F0\u53 17Ta\u0301ibe\u030Ci", "\u53F0\u5317"], level: 1, testType: TEST_QSA | TEST_MATC H},
287
288 // XXX runMatchesTest() in level2-lib.js can't handle this because obtaining t he expected nodes requires escaping characters when generating the selector from 'expect' values
289 {name: "ID selector, matching element with id with escaped character", selecto r: "#\\#foo\\:bar", expect: ["#foo:bar"], level: 1, testType: TE ST_QSA},
290 {name: "ID selector, matching element with id with escaped character", selecto r: "#test\\.foo\\[5\\]bar", expect: ["test.foo[5]bar"], level: 1, testType: TE ST_QSA},
291
292 // Namespaces
293 // XXX runMatchesTest() in level2-lib.js can't handle these because non-HTML e lements don't have a recognised id
294 {name: "Namespace selector, matching element with any namespace", selec tor: "#any-namespace *|div", expect: ["any-namespace-div1", "any-namespace-div2" , "any-namespace-div3", "any-namespace-div4"], level: 3, testType: TEST_QSA},
295 {name: "Namespace selector, matching div elements in no namespace only", selec tor: "#no-namespace |div", expect: ["no-namespace-div3"], level: 3, testType: TEST_QSA},
296 {name: "Namespace selector, matching any elements in no namespace only", selec tor: "#no-namespace |*", expect: ["no-namespace-div3"], level: 3, testType: TEST_QSA},
297
298 // Combinators
299 // - Descendant combinator ' '
300 {name: "Descendant combinator, matching element that is a descendant of an ele ment with id", selector: "#descendant div", ex pect: ["descendant-div1", "descendant-div2", "descendant-div3", "descendant-div4 "], level: 1, testType: TEST_QSA | TEST_MATCH},
301 {name: "Descendant combinator, matching element with id that is a descendant o f an element", selector: "body #descendant-div1", ex pect: ["descendant-div1"], exclude: ["detached", "fragment"], level: 1, testType : TEST_QSA | TEST_MATCH},
302 {name: "Descendant combinator, matching element with id that is a descendant o f an element", selector: "div #descendant-div1", ex pect: ["descendant-div1"], level: 1, testType : TEST_QSA | TEST_MATCH},
303 {name: "Descendant combinator, matching element with id that is a descendant o f an element with id", selector: "#descendant #descendant-div2", ex pect: ["descendant-div2"], level: 1, testType : TEST_QSA | TEST_MATCH},
304 {name: "Descendant combinator, matching element with class that is a descendan t of an element with id", selector: "#descendant .descendant-div2", ex pect: ["descendant-div2"], level: 1, testType : TEST_QSA | TEST_MATCH},
305 {name: "Descendant combinator, matching element with class that is a descendan t of an element with class", selector: ".descendant-div1 .descendant-div3", ex pect: ["descendant-div3"], level: 1, testType : TEST_QSA | TEST_MATCH},
306 {name: "Descendant combinator, not matching element with id that is not a desc endant of an element with id", selector: "#descendant-div1 #descendant-div4", ex pect: [] /*no matches*/, level: 1, testType : TEST_QSA},
307 {name: "Descendant combinator, whitespace characters", selector: "#descendant\t\r\n#descendant-div2", ex pect: ["descendant-div2"], level: 1, testType : TEST_QSA | TEST_MATCH},
308
309 // - Child combinator '>'
310 {name: "Child combinator, matching element that is a child of an element with id", selector: "#child>div", expe ct: ["child-div1", "child-div4"], level: 2, testType: TEST_QSA | TEST_MATCH},
311 {name: "Child combinator, matching element with id that is a child of an eleme nt", selector: "div>#child-div1", expe ct: ["child-div1"], level: 2, testType: TEST_QSA | TEST_MATCH},
312 {name: "Child combinator, matching element with id that is a child of an eleme nt with id", selector: "#child>#child-div1", expe ct: ["child-div1"], level: 2, testType: TEST_QSA | TEST_MATCH},
313 {name: "Child combinator, matching element with id that is a child of an eleme nt with class", selector: "#child-div1>.child-div2", expe ct: ["child-div2"], level: 2, testType: TEST_QSA | TEST_MATCH},
314 {name: "Child combinator, matching element with class that is a child of an el ement with class", selector: ".child-div1>.child-div2", expe ct: ["child-div2"], level: 2, testType: TEST_QSA | TEST_MATCH},
315 {name: "Child combinator, not matching element with id that is not a child of an element with id", selector: "#child>#child-div3", expe ct: [] /*no matches*/, level: 2, testType: TEST_QSA},
316 {name: "Child combinator, not matching element with id that is not a child of an element with class", selector: "#child-div1>.child-div3", expe ct: [] /*no matches*/, level: 2, testType: TEST_QSA},
317 {name: "Child combinator, not matching element with class that is not a child of an element with class", selector: ".child-div1>.child-div3", expe ct: [] /*no matches*/, level: 2, testType: TEST_QSA},
318 {name: "Child combinator, surrounded by whitespace", selector: "#child-div1\t\r\n>\t\r\n#child-div2", expe ct: ["child-div2"], level: 2, testType: TEST_QSA | TEST_MATCH},
319 {name: "Child combinator, whitespace after", selector: "#child-div1>\t\r\n#child-div2", expe ct: ["child-div2"], level: 2, testType: TEST_QSA | TEST_MATCH},
320 {name: "Child combinator, whitespace before", selector: "#child-div1\t\r\n>#child-div2", expe ct: ["child-div2"], level: 2, testType: TEST_QSA | TEST_MATCH},
321 {name: "Child combinator, no whitespace", selector: "#child-div1>#child-div2", expe ct: ["child-div2"], level: 2, testType: TEST_QSA | TEST_MATCH},
322
323 // - Adjacent sibling combinator '+'
324 {name: "Adjacent sibling combinator, matching element that is an adjacent sibl ing of an element with id", selector: "#adjacent-div2+div", expect: ["adjacent-div4"], level: 2, testTyp e: TEST_QSA | TEST_MATCH},
325 {name: "Adjacent sibling combinator, matching element with id that is an adjac ent sibling of an element", selector: "div+#adjacent-div4", expect: ["adjacent-div4"], level: 2, testTyp e: TEST_QSA | TEST_MATCH},
326 {name: "Adjacent sibling combinator, matching element with id that is an adjac ent sibling of an element with id", selector: "#adjacent-div2+#adjacent- div4", expect: ["adjacent-div4"], level: 2, testTyp e: TEST_QSA | TEST_MATCH},
327 {name: "Adjacent sibling combinator, matching element with class that is an ad jacent sibling of an element with id", selector: "#adjacent-div2+.adjacent- div4", expect: ["adjacent-div4"], level: 2, testTyp e: TEST_QSA | TEST_MATCH},
328 {name: "Adjacent sibling combinator, matching element with class that is an ad jacent sibling of an element with class", selector: ".adjacent-div2+.adjacent- div4", expect: ["adjacent-div4"], level: 2, testTyp e: TEST_QSA | TEST_MATCH},
329 {name: "Adjacent sibling combinator, matching p element that is an adjacent si bling of a div element", selector: "#adjacent div+p", expect: ["adjacent-p2"], level: 2, testTyp e: TEST_QSA | TEST_MATCH},
330 {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*/, level: 2, testTyp e: TEST_QSA},
331 {name: "Adjacent sibling combinator, surrounded by whitespace", selector: "#adjacent-p2\t\r\n+\t\r\n #adjacent-p3", expect: ["adjacent-p3"], level: 2, testTyp e: TEST_QSA | TEST_MATCH},
332 {name: "Adjacent sibling combinator, whitespace after", selector: "#adjacent-p2+\t\r\n#adjac ent-p3", expect: ["adjacent-p3"], level: 2, testTyp e: TEST_QSA | TEST_MATCH},
333 {name: "Adjacent sibling combinator, whitespace before", selector: "#adjacent-p2\t\r\n+#adjac ent-p3", expect: ["adjacent-p3"], level: 2, testTyp e: TEST_QSA | TEST_MATCH},
334 {name: "Adjacent sibling combinator, no whitespace", selector: "#adjacent-p2+#adjacent-p3 ", expect: ["adjacent-p3"], level: 2, testTyp e: TEST_QSA | TEST_MATCH},
335
336 // - General sibling combinator ~ (Level 3)
337 {name: "General sibling combinator, matching element that is a sibling of an e lement with id", selector: "#sibling-div2~div", expect: ["sibling-div4", "sibling-div6"], level: 3, te stType: TEST_QSA | TEST_MATCH},
338 {name: "General sibling combinator, matching element with id that is a sibling of an element", selector: "div~#sibling-div4", expect: ["sibling-div4"], level: 3, te stType: TEST_QSA | TEST_MATCH},
339 {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, te stType: TEST_QSA | TEST_MATCH},
340 {name: "General sibling combinator, matching element with class that is a sibl ing of an element with id", selector: "#sibling-div2~.sibling-div", expect: ["sibling-div4", "sibling-div6"], level: 3, testType: TEST_QSA | TEST_MATCH},
341 {name: "General sibling combinator, matching p element that is a sibling of a div element", selector: "#sibling div~p", expect: ["sibling-p2", "sibling-p3"], level: 3, testType: TEST_QSA | TEST_MATCH},
342 {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, te stType: TEST_QSA},
343 {name: "General sibling combinator, not matching element with id that is not a sibling after an element with id", selector: "#sibling-div2~#sibling-div3, #sib ling-div2~#sibling-div1", expect: [] /*no matches*/, level: 3, te stType: TEST_QSA},
344 {name: "General sibling combinator, surrounded by whitespace", selector: "#sibling-p2\t\r\n~\t\r\n#sibling- p3", expect: ["sibling-p3"], level: 3, te stType: TEST_QSA | TEST_MATCH},
345 {name: "General sibling combinator, whitespace after", selector: "#sibling-p2~\t\r\n#sibling-p3", expect: ["sibling-p3"], level: 3, te stType: TEST_QSA | TEST_MATCH},
346 {name: "General sibling combinator, whitespace before", selector: "#sibling-p2\t\r\n~#sibling-p3", expect: ["sibling-p3"], level: 3, te stType: TEST_QSA | TEST_MATCH},
347 {name: "General sibling combinator, no whitespace", selector: "#sibling-p2~#sibling-p3", expect: ["sibling-p3"], level: 3, te stType: TEST_QSA | TEST_MATCH},
348
349 // Group of selectors (comma)
350 {name: "Syntax, group of selectors separator, surrounded by whitespace", selec tor: "#group em\t\r \n,\t\r \n#group strong", expect: ["group-em1", "group-stron g1"], level: 1, testType: TEST_QSA | TEST_MATCH},
351 {name: "Syntax, group of selectors separator, whitespace after", selec tor: "#group em,\t\r\n#group strong", expect: ["group-em1", "group-stron g1"], level: 1, testType: TEST_QSA | TEST_MATCH},
352 {name: "Syntax, group of selectors separator, whitespace before", selec tor: "#group em\t\r\n,#group strong", expect: ["group-em1", "group-stron g1"], level: 1, testType: TEST_QSA | TEST_MATCH},
353 {name: "Syntax, group of selectors separator, no whitespace", selec tor: "#group em,#group strong", expect: ["group-em1", "group-stron g1"], level: 1, testType: TEST_QSA | TEST_MATCH},
354 ];
355
356
357 /*
358 * These selectors are intended to be used with the find(), findAll() and matche s() methods. Expected results
359 * should be determined under the assumption that :scope will be prepended to th e selector where appropriate,
360 * in accordance with the specification.
361 *
362 * All of these should be valid relative selectors, expected to match zero or mo re elements in the document.
363 * None should throw any errors.
364 *
365 * name: A descriptive name of the selector being tested
366 *
367 * selector: The selector to test
368 *
369 * ctx: A selector to obtain the context object to use for tests invokin g context.find(),
370 * and to use as a single reference node for tests invoking documen t.find().
371 * Note: context = root.querySelector(ctx);
372 *
373 * ref: A selector to obtain the reference nodes to be used for the sele ctor.
374 * Note: If root is the document or an in-document element:
375 * refNodes = document.querySelectorAll(ref);
376 * Otherwise, if root is a fragment or detached element:
377 * refNodes = root.querySelectorAll(ref);
378 *
379 * expect: A list of IDs of the elements expected to be matched. List must be given in tree order.
380 *
381 * unexpected: A list of IDs of some elements that are not expected to match t he given selector.
382 * This is used to verify that unexpected.matches(selector, refNod e) does not match.
383 *
384 * exclude: An array of contexts to exclude from testing. The valid values a re:
385 * ["document", "element", "fragment", "detached", "html", "xhtml"]
386 * The "html" and "xhtml" values represent the type of document bei ng queried. These are useful
387 * for tests that are affected by differences between HTML and XML, such as case sensitivity.
388 *
389 * level: An integer indicating the CSS or Selectors level in which the se lector being tested was introduced.
390 *
391 * testType: A bit-mapped flag indicating the type of test.
392 *
393 * The test function for these tests accepts a specified root node, on which the methods will be invoked during the tests.
394 *
395 * Based on whether either 'context' or 'refNodes', or both, are specified the t ests will execute the following methods:
396 *
397 * Where testType is TEST_FIND:
398 *
399 * context.findAll(selector, refNodes)
400 * context.findAll(selector) // Only if refNodes is not specified
401 * root.findAll(selector, context) // Only if refNodes is not specified
402 * root.findAll(selector, refNodes) // Only if context is not specified
403 * root.findAll(selector) // Only if neither context nor refNodes is s pecified
404 *
405 * Where testType is TEST_QSA
406 *
407 * context.querySelectorAll(selector)
408 * root.querySelectorAll(selector) // Only if neither context nor refNodes is s pecified
409 *
410 * Equivalent tests will be run for .find() as well.
411 * Note: Do not specify a testType of TEST_QSA where either implied :scope or ex plicit refNodes
412 * are required.
413 *
414 * Where testType is TEST_MATCH:
415 * For each expected result given, within the specified root:
416 *
417 * expect.matches(selector, context) // Only where refNodes is not specified
418 * expect.matches(selector, refNodes)
419 * expect.matches(selector) // Only if neither context nor refNodes is specified
420 *
421 * The tests involving refNodes for both find(), findAll() and matches() will ea ch be run by passing the
422 * collection as a NodeList, an Array and, if there is only a single element, an Element node.
423 *
424 * Note: Interactive pseudo-classes (:active :hover and :focus) have not been te sted in this test suite.
425 */
426
427 var scopedSelectors = [
428 //{name: "", selector: "", ctx: "", ref: "", expect: [], level: 1, testType: T EST_FIND | TEST_MATCH},
429
430 // Universal Selector
431 {name: "Universal selector, matching all children of the specified reference e lement", selector: ">*", ctx: "#universal", expect: ["universal-p1", "un iversal-hr1", "universal-pre1", "universal-p2", "universal-address1"], unexpecte d: ["universal", "empty"], level: 2, testType: TEST_FIND | TEST_MATCH},
432 {name: "Universal selector, matching all grandchildren of the specified refere nce element", selector: ">*>*", ctx: "#universal", expect: ["universal-code1", "universal-span1", "universal-a1", "universal-code2"], unexpecte d: ["universal", "empty"], level: 2, testType: TEST_FIND | TEST_MATCH},
433 {name: "Universal selector, matching all children of the specified empty refer ence element", selector: ">*", ctx: "#empty", expect: [] /*no matches*/, unexpecte d: ["universal", "empty"], level: 2, testType: TEST_QSA},
434 {name: "Universal selector, matching all descendants of the specified referenc e element", selector: "*", ctx: "#universal", expect: ["universal-p1", "un iversal-code1", "universal-hr1", "universal-pre1", "universal-span1",
435 "universal-p2", "un iversal-a1", "universal-address1", "universal-code2", "universal-a2"], unexpecte d: ["universal", "empty"], level: 2, testType: TEST_FIND | TEST_MATCH},
436
437 // Attribute Selectors
438 // - presence [att]
439 {name: "Attribute presence selector, matching align attribute with value", selector: ".attr-presence-div1[align]", ctx: "#attr-presence", expect: ["attr-presence-div1"], level: 2, testType: TEST_FIND | TEST_MATCH},
440 {name: "Attribute presence selector, matching align attribute with empty value ", selector: ".attr-presence-div2[align]", ctx: "#attr-presence", expect: ["attr-presence-div2"], level: 2, testType: TEST_FIND | TEST_MATCH},
441 {name: "Attribute presence selector, matching title attribute, case insensitiv ity", selector: "[TiTlE]", ctx: "#attr-presence", expect: ["attr-presence-a1", "attr-presence-span1"], exclude: ["xhtml"], level: 2, testType: TEST_FIND | TEST_MATCH},
442 {name: "Attribute presence selector, not matching title attribute, case sensit ivity", selector: "[TiTlE]", ctx: "#attr-presence", expect: [], exclude: ["html"], level: 2, testType: TEST_FIND | TEST_MATCH},
443 {name: "Attribute presence selector, matching custom data-* attribute", selector: "[data-attr-presence]", ctx: "#attr-presence", expect: ["attr-presence-pre1", "attr-presence-blockqu ote1"], level: 2, testType: TEST_FIND | TEST_MATCH},
444 {name: "Attribute presence selector, not matching attribute with similar name" , selector: ".attr-presence-div3[align], .attr-presence-div4[align ]", ctx: "#attr-presence", expect: [] /*no matches*/, level: 2, testType: TEST_FIND},
445 {name: "Attribute presence selector, matching attribute with non-ASCII charact ers", selector: "ul[data-中文]", ctx: "#attr-presence", expect: ["attr-presence-ul1"], level: 2, testType: TEST_FIND | TEST_MATCH},
446 {name: "Attribute presence selector, not matching default option without selec ted attribute", selector: "#attr-presence-select1 option[selected]", ctx: "#attr-presence", expect: [] /* no matches */, level: 2, testType: TEST_FIND},
447 {name: "Attribute presence selector, matching option with selected attribute", selector: "#attr-presence-select2 option[selected]", ctx: "#attr-presence", expect: ["attr-presence-select2-option4"], level: 2, testType: TEST_FIND | TEST_MATCH},
448 {name: "Attribute presence selector, matching multiple options with selected a ttributes", selector: "#attr-presence-select3 option[selected]", ctx: "#attr-presence", expect: ["attr-presence-select3-option2", "attr-prese nce-select3-option3"], level: 2, testType: TEST_FIND | TEST_MATCH},
449
450 // - value [att=val]
451 {name: "Attribute value selector, matching align attribute with value", selector: "[align=\"center\"]", ctx: "#attr-value", expect: ["attr-value-div1"], level: 2, test Type: TEST_FIND | TEST_MATCH},
452 {name: "Attribute value selector, matching align attribute with empty value", selector: "[align=\"\"]", ctx: "#attr-value", expect: ["attr-value-div2"], level: 2, test Type: TEST_FIND | TEST_MATCH},
453 {name: "Attribute value selector, not matching align attribute with partial va lue", selector: "[align=\"c\"]", ctx: "#attr-value", expect: [] /*no matches*/, level: 2, test Type: TEST_FIND},
454 {name: "Attribute value selector, not matching align attribute with incorrect value", selector: "[align=\"centera\"]", ctx: "#attr-value", expect: [] /*no matches*/, level: 2, test Type: TEST_FIND},
455 {name: "Attribute value selector, matching custom data-* attribute with unicod e escaped value", selector: "[data-attr-value=\"\\e9\"]", ctx: "#attr-value", expect: ["attr-value-div3"], level: 2, test Type: TEST_FIND | TEST_MATCH},
456 {name: "Attribute value selector, matching custom data-* attribute with escape d character", selector: "[data-attr-value\_foo=\"\\e9\"]", ctx: "#attr-value", expect: ["attr-value-div4"], level: 2, test Type: TEST_FIND | TEST_MATCH},
457 {name: "Attribute value selector with single-quoted value, matching multiple i nputs with type attributes", selector: "input[type='hidden'],#attr-value input[t ype='radio']", ctx: "#attr-value", expect: ["attr-value-input3", "attr-value-i nput4", "attr-value-input6", "attr-value-input8", "attr-value-input9"], level: 2 , testType: TEST_FIND | TEST_MATCH},
458 {name: "Attribute value selector with double-quoted value, matching multiple i nputs with type attributes", selector: "input[type=\"hidden\"],#attr-value input [type='radio']", ctx: "#attr-value", expect: ["attr-value-input3", "attr-value-i nput4", "attr-value-input6", "attr-value-input8", "attr-value-input9"], level: 2 , testType: TEST_FIND | TEST_MATCH},
459 {name: "Attribute value selector with unquoted value, matching multiple inputs with type attributes", selector: "input[type=hidden],#attr-value input[typ e=radio]", ctx: "#attr-value", expect: ["attr-value-input3", "attr-value-i nput4", "attr-value-input6", "attr-value-input8", "attr-value-input9"], level: 2 , testType: TEST_FIND | TEST_MATCH},
460 {name: "Attribute value selector, matching attribute with value using non-ASCI I characters", selector: "[data-attr-value=中文]", ctx: "#attr-value", expect: ["attr-value-div5"], level: 2, test Type: TEST_FIND | TEST_MATCH},
461
462 // - whitespace-separated list [att~=val]
463 {name: "Attribute whitespace-separated list selector, matching class attribute with value", selector: "[class~=\"div1\"]", ctx: "#attr-whitespace", expect: ["attr-whi tespace-div1"], level: 2, testType: TEST_FIND | TEST_MATCH},
464 {name: "Attribute whitespace-separated list selector, not matching class attri bute with empty value", selector: "[class~=\"\"]", ctx: "#attr-whitespace", expect: [] /*no ma tches*/ , level: 2, testType: TEST_FIND},
465 {name: "Attribute whitespace-separated list selector, not matching class attri bute with partial value", selector: "[data-attr-whitespace~ =\"div\"]", ctx: "#attr-whitespace", e xpect: [] /*no matches*/ , level: 2, testType: TEST_FIND},
466 {name: "Attribute whitespace-separated list selector, matching custom data-* a ttribute with unicode escaped value", selector: "[data-attr-whitespace~ =\"\\0000e9\"]", ctx: "#attr-whitespace", e xpect: ["attr-whitespace-div4"], level: 2, testType: TEST_FIND | TEST_MATCH},
467 {name: "Attribute whitespace-separated list selector, matching custom data-* a ttribute with escaped character", selector: "[data-attr-whitespace\ _foo~=\"\\e9\"]", ctx: "#attr-whitespace", e xpect: ["attr-whitespace-div5"], level: 2, testType: TEST_FIND | TEST_MATCH},
468 {name: "Attribute whitespace-separated list selector with single-quoted value, matching multiple links with rel attributes", selector: "a[rel~='bookmark'], # attr-whitespace a[rel~='nofollow']", ctx: "#attr-whitespace", expect: ["attr-whi tespace-a1", "attr-whitespace-a2", "attr-whitespace-a3", "attr-whitespace-a5", " attr-whitespace-a7"], level: 2, testType: TEST_FIND | TEST_MATCH},
469 {name: "Attribute whitespace-separated list selector with double-quoted value, matching multiple links with rel attributes", selector: "a[rel~=\"bookmark\"],# attr-whitespace a[rel~='nofollow']", ctx: "#attr-whitespace", expect: ["attr-whi tespace-a1", "attr-whitespace-a2", "attr-whitespace-a3", "attr-whitespace-a5", " attr-whitespace-a7"], level: 2, testType: TEST_FIND | TEST_MATCH},
470 {name: "Attribute whitespace-separated list selector with unquoted value, matc hing multiple links with rel attributes", selector: "a[rel~=bookmark], # attr-whitespace a[rel~=nofollow]", ctx: "#attr-whitespace", expect: ["attr-whi tespace-a1", "attr-whitespace-a2", "attr-whitespace-a3", "attr-whitespace-a5", " attr-whitespace-a7"], level: 2, testType: TEST_FIND | TEST_MATCH},
471 {name: "Attribute whitespace-separated list selector with double-quoted value, not matching value with space", selector: "a[rel~=\"book mark\"]" , ctx: "#attr-whitespace", expect: [] /* no m atches */, level: 2, testType: TEST_FIND},
472 {name: "Attribute whitespace-separated list selector, matching title attribute with value using non-ASCII characters", selector: "[title~=中文]", ctx: "#attr-whitespace", expect: ["attr-whi tespace-p1"], level: 2, testType: TEST_FIND | TEST_MATCH},
473
474 // - hyphen-separated list [att|=val]
475 {name: "Attribute hyphen-separated list selector, not matching unspecified lan g attribute", selector: "#attr-hyphen-div1[lang|=\"en\"]", ctx: "#attr-hyp hen", expect: [] /*no matches*/, level: 2, testType: TEST_FIND},
476 {name: "Attribute hyphen-separated list selector, matching lang attribute with exact value", selector: "#attr-hyphen-div2[lang|=\"fr\"]", ctx: "#attr-hyp hen", expect: ["attr-hyphen-div2"], level: 2, testType: TEST_FIND | TEST_MATCH},
477 {name: "Attribute hyphen-separated list selector, matching lang attribute with partial value", selector: "#attr-hyphen-div3[lang|=\"en\"]", ctx: "#attr-hyp hen", expect: ["attr-hyphen-div3"], level: 2, testType: TEST_FIND | TEST_MATCH},
478 {name: "Attribute hyphen-separated list selector, not matching incorrect value ", selector: "#attr-hyphen-div4[lang|=\"es-AR\"]", ctx: "#attr-hyp hen", expect: [] /*no matches*/, level: 2, testType: TEST_FIND},
479
480 // - substring begins-with [att^=val] (Level 3)
481 {name: "Attribute begins with selector, matching href attributes beginning wit h specified substring", selector: "a[href^=\"http:// www\"]", ctx: "#attr-begins", expect: ["attr-begins-a1", "attr-begins-a3"], level: 3, testType: TEST_FIND | TEST_MATCH},
482 {name: "Attribute begins with selector, matching lang attributes beginning wit h specified substring, ", selector: "[lang^=\"en-\"]", ctx: "#attr-begins", expect: ["attr-begins-div2", "attr-begins-div4"], level: 3, testType: TEST_FIND | TEST_MATCH},
483 {name: "Attribute begins with selector, not matching class attribute not begin ning with specified substring", selector: "[class^=apple]", ctx: "#attr-begins", expect: [] /*no matches*/, level: 3, testType: TEST_FIND},
484 {name: "Attribute begins with selector with single-quoted value, matching clas s attribute beginning with specified substring", selector: "[class^=' apple'] ", ctx: "#attr-begins", expect: ["attr-begins-p1"], level: 3, testType: TEST_FIND | TEST_MATCH},
485 {name: "Attribute begins with selector with double-quoted value, matching clas s attribute beginning with specified substring", selector: "[class^=\" apple\ "]", ctx: "#attr-begins", expect: ["attr-begins-p1"], level: 3, testType: TEST_FIND | TEST_MATCH},
486 {name: "Attribute begins with selector with unquoted value, not matching class attribute not beginning with specified substring", selector: "[class^= apple]", ctx: "#attr-begins", expect: [] /*no matches*/, level: 3, testType: TEST_FIND},
487
488 // - substring ends-with [att$=val] (Level 3)
489 {name: "Attribute ends with selector, matching href attributes ending with spe cified substring", selector: "a[href$=\".org\"]", ctx: "#attr-ends", expect: ["attr-ends-a1", "attr-ends-a3"], level: 3, testT ype: TEST_FIND | TEST_MATCH},
490 {name: "Attribute ends with selector, matching lang attributes ending with spe cified substring, ", selector: "[lang$=\"-CH\"]", ctx: "#attr-ends", expect: ["attr-ends-div2", "attr-ends-div4"], level: 3, testT ype: TEST_FIND | TEST_MATCH},
491 {name: "Attribute ends with selector, not matching class attribute not ending with specified substring", selector: "[class$=apple]", ctx: "#attr-ends", expect: [] /*no matches*/, level: 3, testT ype: TEST_FIND},
492 {name: "Attribute ends with selector with single-quoted value, matching class attribute ending with specified substring", selector: "[class$='apple ']", ctx: "#attr-ends", expect: ["attr-ends-p1"], level: 3, testT ype: TEST_FIND | TEST_MATCH},
493 {name: "Attribute ends with selector with double-quoted value, matching class attribute ending with specified substring", selector: "[class$=\"apple \"]", ctx: "#attr-ends", expect: ["attr-ends-p1"], level: 3, testT ype: TEST_FIND | TEST_MATCH},
494 {name: "Attribute ends with selector with unquoted value, not matching class a ttribute not ending with specified substring", selector: "[class$=apple ]", ctx: "#attr-ends", expect: [] /*no matches*/, level: 3, testT ype: TEST_FIND},
495
496 // - substring contains [att*=val] (Level 3)
497 {name: "Attribute contains selector, matching href attributes beginning with s pecified substring", selector: "a[href*=\"http://www\"] ", ctx: "#attr-contains", expect: ["attr-contains-a1", "attr-contains-a3"], level: 3, testType: TEST_FIND | TEST_MATCH},
498 {name: "Attribute contains selector, matching href attributes ending with spec ified substring", selector: "a[href*=\".org\"]", ctx: "#attr-contains", expect: ["attr-contains-a1", "attr-contains-a2"], level: 3, testType: TEST_FIND | TEST_MATCH},
499 {name: "Attribute contains selector, matching href attributes containing speci fied substring", selector: "a[href*=\".example.\"]" , ctx: "#attr-contains", expect: ["attr-contains-a1", "attr-contains-a3"], level: 3, testType: TEST_FIND | TEST_MATCH},
500 {name: "Attribute contains selector, matching lang attributes beginning with s pecified substring, ", selector: "[lang*=\"en-\"]", ctx: "#attr-contains", expect: ["attr-contains-div2", "attr-contains-div6 "], level: 3, testType: TEST_FIND | TEST_MATCH},
501 {name: "Attribute contains selector, matching lang attributes ending with spec ified substring, ", selector: "[lang*=\"-CH\"]", ctx: "#attr-contains", expect: ["attr-contains-div3", "attr-contains-div5 "], level: 3, testType: TEST_FIND | TEST_MATCH},
502 {name: "Attribute contains selector with single-quoted value, matching class a ttribute beginning with specified substring", selector: "[class*=' apple']", ctx: "#attr-contains", expect: ["attr-contains-p1"], level: 3, testType: TEST_FIND | TEST_MATCH},
503 {name: "Attribute contains selector with single-quoted value, matching class a ttribute ending with specified substring", selector: "[class*='orange ']", ctx: "#attr-contains", expect: ["attr-contains-p1"], level: 3, testType: TEST_FIND | TEST_MATCH},
504 {name: "Attribute contains selector with single-quoted value, matching class a ttribute containing specified substring", selector: "[class*='ple banana ora ']", ctx: "#attr-contains", expect: ["attr-contains-p1"], level: 3, testType: TEST_FIND | TEST_MATCH},
505 {name: "Attribute contains selector with double-quoted value, matching class a ttribute beginning with specified substring", selector: "[class*=\" apple\"]", ctx: "#attr-contains", expect: ["attr-contains-p1"], level: 3, testType: TEST_FIND | TEST_MATCH},
506 {name: "Attribute contains selector with double-quoted value, matching class a ttribute ending with specified substring", selector: "[class*=\"orange \"]", ctx: "#attr-contains", expect: ["attr-contains-p1"], level: 3, testType: TEST_FIND | TEST_MATCH},
507 {name: "Attribute contains selector with double-quoted value, matching class a ttribute containing specified substring", selector: "[class*=\"ple banana or a\"]", ctx: "#attr-contains", expect: ["attr-contains-p1"], level: 3, testType: TEST_FIND | TEST_MATCH},
508 {name: "Attribute contains selector with unquoted value, matching class attrib ute beginning with specified substring", selector: "[class*= apple]", ctx: "#attr-contains", expect: ["attr-contains-p1"], level: 3, testType: TEST_FIND | TEST_MATCH},
509 {name: "Attribute contains selector with unquoted value, matching class attrib ute ending with specified substring", selector: "[class*=orange ]", ctx: "#attr-contains", expect: ["attr-contains-p1"], level: 3, testType: TEST_FIND | TEST_MATCH},
510 {name: "Attribute contains selector with unquoted value, matching class attrib ute containing specified substring", selector: "[class*= banana ]", ctx: "#attr-contains", expect: ["attr-contains-p1"], level: 3, testType: TEST_FIND | TEST_MATCH},
511
512 // Pseudo-classes
513 // - :root (Level 3)
514 {name: ":root pseudo-class selector, matching document root element", sel ector: ":root", expect: ["html"], exclude: ["element", "f ragment", "detached"], level: 3, testType: TEST_FIND},
515 {name: ":root pseudo-class selector, not matching document root element", sel ector: ":root", expect: [] /*no matches*/, exclude: ["document"], level: 3, testType: TEST_FIND},
516 {name: ":root pseudo-class selector, not matching document root element", sel ector: ":root", ctx: "#html", expect: [] /*no matches*/, exclude: ["fragment", " detached"], level: 3, testType: TEST_FIND},
517
518 // - :nth-child(n) (Level 3)
519 {name: ":nth-child selector, matching the third child element", selector: ":nth-child(3)", ctx: "#pseudo-nth-table1", expect : ["pseudo-nth-td3", "pseudo-nth-td9", "pseudo-nth-tr3", "pseudo-nth-td15"], level: 3, testType: TEST_FIND | TEST_MATCH},
520 {name: ":nth-child selector, matching every third child element", selector: "li:nth-child(3n)", ctx: "#pseudo-nth", expect: ["pse udo-nth-li3", "pseudo-nth-li6", "pseudo-nth-li9", "pseudo-nth-li12"], level: 3, testType: TEST_FIND | TEST_MATCH},
521 {name: ":nth-child selector, matching every second child element, starting fro m the fourth", selector: "li:nth-child(2n+4)", ctx: "#pseudo-nth", expect: ["pse udo-nth-li4", "pseudo-nth-li6", "pseudo-nth-li8", "pseudo-nth-li10", "pseudo-nth -li12"], level: 3, testType: TEST_FIND | TEST_MATCH},
522 {name: ":nth-child selector, matching every fourth child element, starting fro m the third", selector: ":nth-child(4n-1)", ctx: "#pseudo-nth-p1", expect: [" pseudo-nth-em2", "pseudo-nth-span3"], level: 3, testType: TEST_FIND | TEST_MATCH},
523
524 // - :nth-last-child (Level 3)
525 {name: ":nth-last-child selector, matching the third last child element", selector: ":nth-last-child(3)", ctx: "#pseudo-nth-table1", expect: ["pseudo-nth-tr1", "pseudo-nth-td4", "pseudo-nth-t d10", "pseudo-nth-td16"], level: 3, testType: TEST_FIND | TEST_MATCH},
526 {name: ":nth-last-child selector, matching every third child element from the end", selector: "li:nth-last-child(3n)", ctx: "pseudo-nth", expect: ["pseudo-nth-li1", "pseudo-nth-li4", "pseudo-nth-li7", "ps eudo-nth-li10"], level: 3, testType: TEST_FIND | TEST_MATCH},
527 {name: ":nth-last-child selector, matching every second child element from the end, starting from the fourth last", selector: "li:nth-last-child(2n+4)", ctx: "pseudo-nth", expect: ["pseudo-nth-li1", "pseudo-nth-li3", "pseudo-nth-li5", "ps eudo-nth-li7", "pseudo-nth-li9"], level: 3, testType: TEST_FIND | TEST_MATCH},
528 {name: ":nth-last-child selector, matching every fourth element from the end, starting from the third last", selector: ":nth-last-child(4n-1)", ctx: "#pseudo-nth-p1", expect: ["pseudo-nth-span2", "pseudo-nth-span4"], level: 3, testType: TEST_FIND | TEST_MATCH},
529
530 // - :nth-of-type(n) (Level 3)
531 {name: ":nth-of-type selector, matching the third em element", selector: "em:nth-of-type(3)", ctx: "#pseudo-nth-p1 ", expect: ["pseudo-nth-em3"], level: 3, testType: TEST_FIND | TEST_MATCH},
532 {name: ":nth-of-type selector, matching every second element of their type", selector: ":nth-of-type(2n)", ctx: "#pseudo-nth-p1 ", expect: ["pseudo-nth-em2", "pseudo-nth-span2", "pseudo-nth-span4", "pseudo-nt h-strong2", "pseudo-nth-em4"], level: 3, testType: TEST_FIND | TEST_MATCH},
533 {name: ":nth-of-type selector, matching every second elemetn of their type, st arting from the first", selector: "span:nth-of-type(2n-1)", ctx: "#pseudo-nth-p1 ", expect: ["pseudo-nth-span1", "pseudo-nth-span3"], level: 3, testType: TEST_FIND | TEST_MATCH},
534
535 // - :nth-last-of-type(n) (Level 3)
536 {name: ":nth-last-of-type selector, matching the thrid last em element", selector: "em:nth-last-of-type(3)", ctx: " #pseudo-nth-p1", expect: ["pseudo-nth-em2"], level: 3, testType: TEST_FIND | TES T_MATCH},
537 {name: ":nth-last-of-type selector, matching every second last element of thei r type", selector: ":nth-last-of-type(2n)", ctx: " #pseudo-nth-p1", expect: ["pseudo-nth-span1", "pseudo-nth-em1", "pseudo-nth-stro ng1", "pseudo-nth-em3", "pseudo-nth-span3"], level: 3, testType: TEST_FIND | TES T_MATCH},
538 {name: ":nth-last-of-type selector, matching every second last element of thei r type, starting from the last", selector: "span:nth-last-of-type(2n-1)", ctx: " #pseudo-nth-p1", expect: ["pseudo-nth-span2", "pseudo-nth-span4"], level: 3, testType: TEST_FIND | TES T_MATCH},
539
540 // - :first-of-type (Level 3)
541 {name: ":first-of-type selector, matching the first em element", selector: "em:first-of-type", ctx: "#pseudo-nth-p1", expect: ["pseudo- nth-em1"], level: 3, testType: TEST_FI ND | TEST_MATCH},
542 {name: ":first-of-type selector, matching the first of every type of element", selector: ":first-of-type", ctx: "#pseudo-nth-p1", expect: ["pseudo- nth-span1", "pseudo-nth-em1", "pseudo-nth-strong1"], level: 3, testType: TEST_FI ND | TEST_MATCH},
543 {name: ":first-of-type selector, matching the first td element in each table r ow", selector: "tr :first-of-type", ctx: "#pseudo-nth-table1", expect: ["pseudo- nth-td1", "pseudo-nth-td7", "pseudo-nth-td13"], level: 3, testType: TEST_FI ND | TEST_MATCH},
544
545 // - :last-of-type (Level 3)
546 {name: ":last-of-type selector, matching the last em elemnet", selector: "em:last-of-type", ctx: "#pseudo-nth-p1", expect: ["pseudo- nth-em4"], level: 3, testType: TEST_FI ND | TEST_MATCH},
547 {name: ":last-of-type selector, matching the last of every type of element", selector: ":last-of-type", ctx: "#pseudo-nth-p1", expect: ["pseudo- nth-span4", "pseudo-nth-strong2", "pseudo-nth-em4"], level: 3, testType: TEST_FI ND | TEST_MATCH},
548 {name: ":last-of-type selector, matching the last td element in each table row ", selector: "tr :last-of-type", ctx: "#pseudo-nth-table1", expect: ["pseudo- nth-td6", "pseudo-nth-td12", "pseudo-nth-td18"], level: 3, testType: TEST_FI ND | TEST_MATCH},
549
550 // - :first-child
551 {name: ":first-child pseudo-class selector, matching first child div element", selector: "div:first-child", ctx: "#pseudo-first-child", expect: ["pseudo-first-child-div1" ], level: 2, testType: TEST_FIND | TEST_MATCH},
552 {name: ":first-child pseudo-class selector, doesn't match non-first-child elem ents", selector: ".pseudo-first-child-div2:first-child, .pseudo-first-child-d iv3:first-child", ctx: "#pseudo-first-child", expect: [] /*no matches*/, level: 2, testType: TEST_FIND},
553 {name: ":first-child pseudo-class selector, matching first-child of multiple e lements", selector: "span:first-child", ctx: "#pseudo-first-child", expect: ["pseudo-first-child-span1 ", "pseudo-first-child-span3", "pseudo-first-child-span5"], level: 2, testType: TEST_FIND | TEST_MATCH},
554
555 // - :last-child (Level 3)
556 {name: ":last-child pseudo-class selector, matching last child div element", selector: "div:last-child", ctx: "#pseudo-last-child", expect: ["pseudo-last-child-div3"], level: 3, testType: TEST_FIN D | TEST_MATCH},
557 {name: ":last-child pseudo-class selector, doesn't match non-last-child elemen ts", selector: ".pseudo-last-child-div1:last-child, .pseudo-last-child-div2: first-child", ctx: "#pseudo-last-child", expect: [] /*no matches*/, level: 3, testType: TEST_FIN D},
558 {name: ":last-child pseudo-class selector, matching first-child of multiple el ements", selector: "span:last-child", ctx: "#pseudo-last-child", expect: ["pseudo-last-child-span2", "ps eudo-last-child-span4", "pseudo-last-child-span6"], level: 3, testType: TEST_FIN D | TEST_MATCH},
559
560 // - :only-child (Level 3)
561 {name: ":pseudo-only-child pseudo-class selector, matching all only-child elem ents", selector: ":only-child", ctx: "#pseudo-only", expect: ["pseudo-only-spa n1"], level: 3, testType: TEST_FIND | TEST_MATCH},
562 {name: ":pseudo-only-child pseudo-class selector, matching only-child em eleme nts", selector: "em:only-child", ctx: "#pseudo-only", expect: [] /*no matches*/ , level: 3, testType: TEST_FIND},
563
564 // - :only-of-type (Level 3)
565 {name: ":pseudo-only-of-type pseudo-class selector, matching all elements with no siblings of the same type", selector: " :only-of-type", ctx: "#pseudo-only ", expect: ["pseudo-only-span1", "pseudo-only-em1"], level: 3, testType: TEST_FI ND | TEST_MATCH},
566 {name: ":pseudo-only-of-type pseudo-class selector, matching em elements with no siblings of the same type", selector: " em:only-of-type", ctx: "#pseudo-only ", expect: ["pseudo-only-em1"], level: 3, testType: TEST_FIND | TEST_MATCH},
567
568 // - :empty (Level 3)
569 {name: ":empty pseudo-class selector, matching empty p elements", selector: "p:empty", ctx: "#pseudo-empty", expect: ["pseudo-empty-p1", "pseudo-empty-p2"], level: 3, testType: TEST_FIND | TEST_MATCH},
570 {name: ":empty pseudo-class selector, matching all empty elements", selector: ":empty", ctx: "#pseudo-empty", expect: ["pseudo-empty-p1", "pseudo-empty-p2", "pseudo-empty-span1"], level: 3, testType: TEST_FIND | TEST_MATCH},
571
572 // - :link and :visited
573 // Implementations may treat all visited links as unvisited, so these cannot b e tested separately.
574 // The only guarantee is that ":link,:visited" matches the set of all visited and unvisited links and that they are individually mutually exclusive sets.
575 {name: ":link and :visited pseudo-class selectors, matching a and area element s with href attributes", selector: " :link, #pseudo-link :visited", ctx: "#pseudo-link", expect: ["pseudo-link-a1", "pseudo-link-a2", "pseudo-link-area1" ], level: 1, testType: TEST_FIND | TEST_MATCH},
576 {name: ":link and :visited pseudo-class selectors, matching link elements with href attributes", selector: " :link, #head :visited", ctx: "#head", expect: ["pseudo-link-link1", "pseudo-link-link2"], exclude: ["e lement", "fragment", "detached"], level: 1, testType: TEST_FIND | TEST_MATCH},
577 {name: ":link and :visited pseudo-class selectors, not matching link elements with href attributes", selector: " :link, #head :visited", ctx: "#head", expect: [] /*no matches*/, exclude: ["d ocument"], level: 1, testType: TEST_FIND},
578 {name: ":link and :visited pseudo-class selectors, chained, mutually exclusive pseudo-classes match nothing", selector: ":link:visited", ctx: "#html", expect: [] /*no matches*/, exclude: ["d ocument"], level: 1, testType: TEST_FIND},
579
580 // XXX Figure out context or refNodes for this
581 // - :target (Level 3)
582 {name: ":target pseudo-class selector, matching the element referenced by the URL fragment identifier", selector: ":target", ctx: "", expect: [] /*no matches* /, exclude: ["document", "element"], level: 3, testType: TEST_FIND},
583 {name: ":target pseudo-class selector, matching the element referenced by the URL fragment identifier", selector: ":target", ctx: "", expect: ["target"], exclude: ["fragment", "detached"], level: 3, testType: TEST_FIND},
584
585 // XXX Fix ctx in tests below
586
587 // - :lang()
588 {name: ":lang pseudo-class selector, matching inherited language (1)", selector: "#pseudo-lang-div1:lang(en)", ctx: "", expect: ["pseud o-lang-div1"], exclude: ["detached", "fragment"], level: 2, testType: TEST_FIND | TEST_MATCH},
589 {name: ":lang pseudo-class selector, not matching element with no inherited la nguage", selector: "#pseudo-lang-div1:lang(en)", ctx: "", expect: [] /*no mat ches*/, exclude: ["document", "element"], level: 2, testType: TEST_FIND},
590 {name: ":lang pseudo-class selector, matching specified language with exact va lue (1)", selector: "#pseudo-lang-div2:lang(fr)", ctx: "", expect: ["pseud o-lang-div2"], level: 2, testType: TEST_FIND | TEST_MATCH},
591 {name: ":lang pseudo-class selector, matching specified language with partial value (1)", selector: "#pseudo-lang-div3:lang(en)", ctx: "", expect: ["pseud o-lang-div3"], level: 2, testType: TEST_FIND | TEST_MATCH},
592 {name: ":lang pseudo-class selector, not matching incorrect language", selector: "#pseudo-lang-div4:lang(es-AR)", ctx: "", expect: [] /*no mat ches*/, level: 2, testType: TEST_FIND},
593
594 // - :enabled (Level 3)
595 {name: ":enabled pseudo-class selector, matching all enabled form controls (1) ", selector: "#pseudo-ui :enabled", ctx: "", expect: ["pseudo-ui-input1", "pse udo-ui-input2", "pseudo-ui-input3", "pseudo-ui-input4", "pseudo-ui-input5", "pse udo-ui-input6",
596 "pseudo-ui-input7", "pseudo-ui-input8 ", "pseudo-ui-input9", "pseudo-ui-textarea1", "pseudo-ui-button1"], level: 3, testType: TEST_FIND | TEST_MATCH},
597
598 // - :disabled (Level 3)
599 {name: ":enabled pseudo-class selector, matching all disabled form controls (1 )", selector: "#pseudo-ui :disabled", ctx: "", expect: ["pseudo-ui-input10", "ps eudo-ui-input11", "pseudo-ui-input12", "pseudo-ui-input13", "pseudo-ui-input14", "pseudo-ui-input15",
600 "pseudo-ui-input16", "pseudo-ui-input 17", "pseudo-ui-input18", "pseudo-ui-textarea2", "pseudo-ui-button2"], level: 3, testType: TEST_FIND | TEST_MATCH},
601
602 // - :checked (Level 3)
603 {name: ":checked pseudo-class selector, matching checked radio buttons and che ckboxes (1)", selector: "#pseudo-ui :checked", ctx: "", expect: ["pseudo-ui-inpu t4", "pseudo-ui-input6", "pseudo-ui-input13", "pseudo-ui-input15"], level: 3, t estType: TEST_FIND | TEST_MATCH},
604
605 // - :not(s) (Level 3)
606 {name: ":not pseudo-class selector, matching (1)", selector: "#not>:not(div)", ctx: "", expect: ["not-p1", "not-p2", "not-p3"], level: 3, testType: TEST_FIN D | TEST_MATCH},
607 {name: ":not pseudo-class selector, matching (1)", selector: "#not * :not(:fir st-child)", ctx: "", expect: ["not-em1", "not-em2", "not-em3"], level: 3, test Type: TEST_FIND | TEST_MATCH},
608 {name: ":not pseudo-class selector, matching nothing", selector: ":not(*)", ctx: "", expect: [] /* no matches */, level: 3, testType: TEST_FIND},
609 {name: ":not pseudo-class selector, matching nothing", selector: ":not(*|*)", ctx: "", expect: [] /* no matches */, level: 3, testType: TEST_FIND},
610
611 // Pseudo-elements
612 // - ::first-line
613 {name: ":first-line pseudo-element (one-colon syntax) selector, not matching a ny elements", selector: "#pseudo-element:first-line", ctx: "", expect: [] /*no matches*/, level: 2, testType: TEST_FIND},
614 {name: "::first-line pseudo-element (two-colon syntax) selector, not matching any elements", selector: "#pseudo-element::first-line", ctx: "", expect: [] /*no matches*/, level: 3, testType: TEST_FIND},
615
616 // - ::first-letter
617 {name: ":first-letter pseudo-element (one-colon syntax) selector, not matching any elements", selector: "#pseudo-element:first-letter", ctx: "", expect: [] /*no matches*/, level: 2, testType: TEST_FIND},
618 {name: "::first-letter pseudo-element (two-colon syntax) selector, not matchin g any elements", selector: "#pseudo-element::first-letter", ctx: "", expect: [] /*no matches*/, level: 3, testType: TEST_FIND},
619
620 // - ::before
621 {name: ":before pseudo-element (one-colon syntax) selector, not matching any e lements", selector: "#pseudo-element:before", ctx: "", expect: [] /*no matches*/, level: 2, testType: TEST_FIND},
622 {name: "::before pseudo-element (two-colon syntax) selector, not matching any elements", selector: "#pseudo-element::before", ctx: "", expect: [] /*no matches*/, level: 3, testType: TEST_FIND},
623
624 // - ::after
625 {name: ":after pseudo-element (one-colon syntax) selector, not matching any el ements", selector: "#pseudo-element:after", ctx: "", expect: [] /*no matches*/, level: 2, testType: TEST_FIND},
626 {name: "::after pseudo-element (two-colon syntax) selector, not matching any e lements", selector: "#pseudo-element::after", ctx: "", expect: [] /*no matches*/, level: 3, testType: TEST_FIND},
627
628 // Class Selectors
629 {name: "Class selector, matching element with specified class (1)", selector: ".class-p", ctx: "", ex pect: ["class-p1","class-p2", "class-p3"], level: 1, testType: TEST_FIND | TEST_MATCH},
630 {name: "Class selector, chained, matching only elements with all specified cla sses (1)", selector: "#class .apple.orange.banana", ctx: "", expect: ["class-div1", "class-div2", "class-p4", "class-div3", "class-p6", "class-div4"], level: 1, testType: TEST_FIND | TEST_MATCH},
631 {name: "Class Selector, chained, with type selector (1)", selector: "div.apple.banana.orange", ctx: "", ex pect: ["class-div1", "class-div2", "class-div3", "class-div4"], level: 1, testType: TEST_FIND | TEST_MATCH},
632 {name: "Class selector, matching element with class value using non-ASCII char acters (2)", selector: ".\u53F0\u5317Ta\u0301ibe\u030Ci", ctx: "", expect: ["class-span1"], level: 1, testType: TES T_FIND | TEST_MATCH},
633 {name: "Class selector, matching multiple elements with class value using non- ASCII characters (1)", selector: ".\u53F0\u5317", c tx: "", expect: ["class-span1","class-span2"], level: 1, testType: TEST_FIND | T EST_MATCH},
634 {name: "Class selector, chained, matching element with multiple class values u sing non-ASCII characters (2)", selector: ".\u53F0\u5317Ta\u0301ibe\u030Ci.\u53F 0\u5317", ctx: "", expect: ["class-span1"], level: 1, tes tType: TEST_FIND | TEST_MATCH},
635 {name: "Class selector, matching element with class with escaped character (1) ", selector: ".foo\\:bar", ctx: "", ex pect: ["class-span3"], level: 1, testType: TEST_FIND | TEST_MATCH} ,
636 {name: "Class selector, matching element with class with escaped character (1) ", selector: ".test\\.foo\\[5\\]bar", ctx: "", ex pect: ["class-span4"], level: 1, testType: TEST_FIND | TEST_MATCH} ,
637
638 // ID Selectors
639 {name: "ID selector, matching element with specified id (1)", select or: "#id #id-div1", ctx: "", expect: ["id-div1"], level: 1, testType: TEST_FIND | TEST_MATCH},
640 {name: "ID selector, chained, matching element with specified id (1)", select or: "#id-div1, #id-div1", ctx: "", expect: ["id-div1"], level: 1, testType: TEST_FIND | TEST_MATCH},
641 {name: "ID selector, chained, matching element with specified id (1)", select or: "#id-div1, #id-div2", ctx: "", expect: ["id-div1", "id-div2"], level: 1, testType: TEST_FIND | TEST_MATCH},
642 {name: "ID Selector, chained, with type selector (1)", select or: "div#id-div1, div#id-div2", ctx: "", expect: ["id-div1", "id-div2"], level: 1, testType: TEST_FIND | TEST_MATCH},
643 {name: "ID selector, not matching non-existent descendant", selector: "#id #none", ctx: "", expect: [] /*no matches*/, level: 1, testType: TEST_FIND},
644 {name: "ID selector, not matching non-existent ancestor", selector: "#none #id-div1", ctx: "", expect: [] /*no matches*/, level: 1, testType: TEST_FIND},
645 {name: "ID selector, matching multiple elements with duplicate id (1)", select or: "#id-li-duplicate", ctx: "", expect: ["id-li-duplicate", "id-li-dup licate", "id-li-duplicate", "id-li-duplicate"], level: 1, testType: TEST_FIND | TEST_MATCH},
646
647 {name: "ID selector, matching id value using non-ASCII characters (3)", sel ector: "#\u53F0\u5317Ta\u0301ibe\u030Ci", ctx: "", expect: ["\u53F0\u5 317Ta\u0301ibe\u030Ci"], level: 1, testType: TEST_FIND | TEST_MATCH},
648 {name: "ID selector, matching id value using non-ASCII characters (4)", sel ector: "#\u53F0\u5317", ctx: "", expect: ["\u53F0\u5317"], level: 1, testType: TEST_FIND | TEST_MATCH},
649 {name: "ID selector, matching id values using non-ASCII characters (2)", sel ector: "#\u53F0\u5317Ta\u0301ibe\u030Ci, #\u53F0\u5317", ctx: "", expect: [ "\u53F0\u5317Ta\u0301ibe\u030Ci", "\u53F0\u5317"], level: 1, testType: TEST_FIND | TEST_MATCH},
650
651 // XXX runMatchesTest() in level2-lib.js can't handle this because obtaining t he expected nodes requires escaping characters when generating the selector from 'expect' values
652 {name: "ID selector, matching element with id with escaped character", selecto r: "#\\#foo\\:bar", ctx: "", expect: ["#foo:bar"], level: 1, tes tType: TEST_FIND},
653 {name: "ID selector, matching element with id with escaped character", selecto r: "#test\\.foo\\[5\\]bar", ctx: "", expect: ["test.foo[5]bar"], level: 1, tes tType: TEST_FIND},
654
655 // Namespaces
656 // XXX runMatchesTest() in level2-lib.js can't handle these because non-HTML e lements don't have a recognised id
657 {name: "Namespace selector, matching element with any namespace", selec tor: "#any-namespace *|div", ctx: "", expect: ["any-namespace-div1", "any-namesp ace-div2", "any-namespace-div3", "any-namespace-div4"], level: 3, testType: TEST _FIND},
658 {name: "Namespace selector, matching div elements in no namespace only", selec tor: "#no-namespace |div", ctx: "", expect: ["no-namespace-div3"], level: 3, t estType: TEST_FIND},
659 {name: "Namespace selector, matching any elements in no namespace only", selec tor: "#no-namespace |*", ctx: "", expect: ["no-namespace-div3"], level: 3, t estType: TEST_FIND},
660
661 // Combinators
662 // - Descendant combinator ' '
663 {name: "Descendant combinator, matching element that is a descendant of an ele ment with id (1)", selector: "#descendant div", ctx: "", expect: ["descendant-div1", "descendant-div2", "descendant-div3", "de scendant-div4"], level: 1, testType: TEST_FIND | TEST_MATCH},
664 {name: "Descendant combinator, matching element with id that is a descendant o f an element (1)", selector: "body #descendant-div1", ctx: "", expect: ["descendant-div1"], exclude: ["detached", "fragment"], level : 1, testType: TEST_FIND | TEST_MATCH},
665 {name: "Descendant combinator, matching element with id that is a descendant o f an element (1)", selector: "div #descendant-div1", ctx: "", expect: ["descendant-div1"], level : 1, testType: TEST_FIND | TEST_MATCH},
666 {name: "Descendant combinator, matching element with id that is a descendant o f an element with id (1)", selector: "#descendant #descendant-div2", ctx: "", expect: ["descendant-div2"], level : 1, testType: TEST_FIND | TEST_MATCH},
667 {name: "Descendant combinator, matching element with class that is a descendan t of an element with id (1)", selector: "#descendant .descendant-div2", ctx: "", expect: ["descendant-div2"], level : 1, testType: TEST_FIND | TEST_MATCH},
668 {name: "Descendant combinator, matching element with class that is a descendan t of an element with class (1)", selector: ".descendant-div1 .descendant-div3" , ctx: "", expect: ["descendant-div3"], level : 1, testType: TEST_FIND | TEST_MATCH},
669 {name: "Descendant combinator, not matching element with id that is not a desc endant of an element with id", selector: "#descendant-div1 #descendant-div4", ct x: "", expect: [] /*no matches*/, level: 1, testType: TEST_FIND},
670 {name: "Descendant combinator, whitespace characters (1)", selector: "#descendant\t\r\n#descendant-div2" , ctx: "", expect: ["descendant-div2"], level : 1, testType: TEST_FIND | TEST_MATCH},
671
672 // - Child combinator '>'
673 {name: "Child combinator, matching element that is a child of an element with id (1)", selector: "#child>div", ctx: "", expect: ["child-div1", "child-div4"], level: 2, testType: TEST_FIND | T EST_MATCH},
674 {name: "Child combinator, matching element with id that is a child of an eleme nt (1)", selector: "div>#child-div1", ctx: "", expect: ["child-div1"], level: 2, testType: TEST_FIND | T EST_MATCH},
675 {name: "Child combinator, matching element with id that is a child of an eleme nt with id (1)", selector: "#child>#child-div1", ctx: "", expect: ["child-div1"], level: 2, testType: TEST_FIND | T EST_MATCH},
676 {name: "Child combinator, matching element with id that is a child of an eleme nt with class (1)", selector: "#child-div1>.child-div2", ctx: "", expect: ["child-div2"], level: 2, testType: TEST_FIND | T EST_MATCH},
677 {name: "Child combinator, matching element with class that is a child of an el ement with class (1)", selector: ".child-div1>.child-div2", ctx: "", expect: ["child-div2"], level: 2, testType: TEST_FIND | T EST_MATCH},
678 {name: "Child combinator, not matching element with id that is not a child of an element with id", selector: "#child>#child-div3", ctx: "", expect: [] /*no matches*/, level: 2, testType: TEST_FIND},
679 {name: "Child combinator, not matching element with id that is not a child of an element with class", selector: "#child-div1>.child-div3", ctx: "", expect: [] /*no matches*/, level: 2, testType: TEST_FIND},
680 {name: "Child combinator, not matching element with class that is not a child of an element with class", selector: ".child-div1>.child-div3", ctx: "", expect: [] /*no matches*/, level: 2, testType: TEST_FIND},
681 {name: "Child combinator, surrounded by whitespace (1)", selector: "#child-div1\t\r\n>\t\r\n#child-div2", ctx: "", expect: ["child-div2"], level: 2, testType: TEST_FIND | T EST_MATCH},
682 {name: "Child combinator, whitespace after (1)", selector: "#child-div1>\t\r\n#child-div2", ctx: "", expect: ["child-div2"], level: 2, testType: TEST_FIND | T EST_MATCH},
683 {name: "Child combinator, whitespace before (1)", selector: "#child-div1\t\r\n>#child-div2", ctx: "", expect: ["child-div2"], level: 2, testType: TEST_FIND | T EST_MATCH},
684 {name: "Child combinator, no whitespace (1)", selector: "#child-div1>#child-div2", ctx: "", expect: ["child-div2"], level: 2, testType: TEST_FIND | T EST_MATCH},
685
686 // - Adjacent sibling combinator '+'
687 {name: "Adjacent sibling combinator, matching element that is an adjacent sibl ing of an element with id (1)", selector: "#adjacent-div2+div", ctx: "", expect: ["adjacent-div4"], leve l: 2, testType: TEST_FIND | TEST_MATCH},
688 {name: "Adjacent sibling combinator, matching element with id that is an adjac ent sibling of an element (1)", selector: "div+#adjacent-div4", ctx: "", expect: ["adjacent-div4"], leve l: 2, testType: TEST_FIND | TEST_MATCH},
689 {name: "Adjacent sibling combinator, matching element with id that is an adjac ent sibling of an element with id (1)", selector: "#adjacent-div2+#adjac ent-div4", ctx: "", expect: ["adjacent-div4"], leve l: 2, testType: TEST_FIND | TEST_MATCH},
690 {name: "Adjacent sibling combinator, matching element with class that is an ad jacent sibling of an element with id (1)", selector: "#adjacent-div2+.adjac ent-div4", ctx: "", expect: ["adjacent-div4"], leve l: 2, testType: TEST_FIND | TEST_MATCH},
691 {name: "Adjacent sibling combinator, matching element with class that is an ad jacent sibling of an element with class (1)", selector: ".adjacent-div2+.adjac ent-div4", ctx: "", expect: ["adjacent-div4"], leve l: 2, testType: TEST_FIND | TEST_MATCH},
692 {name: "Adjacent sibling combinator, matching p element that is an adjacent si bling of a div element (1)", selector: "#adjacent div+p", ctx: "", expect: ["adjacent-p2"], leve l: 2, testType: TEST_FIND | TEST_MATCH},
693 {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", ctx: "", expect: [] /*no matches*/, level: 2 , testType: TEST_FIND},
694 {name: "Adjacent sibling combinator, surrounded by whitespace (1)", selector: "#adjacent-p2\t\r\n+\t \r\n#adjacent-p3", ctx: "", expect: ["adjacent-p3"], leve l: 2, testType: TEST_FIND | TEST_MATCH},
695 {name: "Adjacent sibling combinator, whitespace after (1)", selector: "#adjacent-p2+\t\r\n#a djacent-p3", ctx: "", expect: ["adjacent-p3"], leve l: 2, testType: TEST_FIND | TEST_MATCH},
696 {name: "Adjacent sibling combinator, whitespace before (1)", selector: "#adjacent-p2\t\r\n+#a djacent-p3", ctx: "", expect: ["adjacent-p3"], leve l: 2, testType: TEST_FIND | TEST_MATCH},
697 {name: "Adjacent sibling combinator, no whitespace (1)", selector: "#adjacent-p2+#adjacen t-p3", ctx: "", expect: ["adjacent-p3"], leve l: 2, testType: TEST_FIND | TEST_MATCH},
698
699 // - General sibling combinator ~ (Level 3)
700 {name: "General sibling combinator, matching element that is a sibling of an e lement with id (1)", selector: "#sibling-div2~div", ctx: "", expect: ["sibling-div4", "sibling-div6"], level: 3, testType: TEST_FIND | TEST_MATCH},
701 {name: "General sibling combinator, matching element with id that is a sibling of an element (1)", selector: "div~#sibling-div4", ctx: "", expect: ["sibling-div4"], level: 3, testType: TEST_FIND | TEST_MATCH},
702 {name: "General sibling combinator, matching element with id that is a sibling of an element with id (1)", selector: "#sibling-div2~#sibling-div4", ctx: "", expect: ["sibling-div4"], level: 3, testType: TEST_FIND | TEST_MATCH},
703 {name: "General sibling combinator, matching element with class that is a sibl ing of an element with id (1)", selector: "#sibling-div2~.sibling-div", ctx: "", expect: ["sibling-div4", "sibling-div6"], level: 3, testType: TEST_FIND | TEST_MATCH},
704 {name: "General sibling combinator, matching p element that is a sibling of a div element (1)", selector: "#sibling div~p", ctx: "", expect: ["sibling-p2", "sibling-p3"], level: 3, testType: TEST_FIND | TEST_MATCH},
705 {name: "General sibling combinator, not matching element with id that is not a sibling after a p element (1)", selector: "#sibling>p~div", ctx: "", expect: [] /*no matches*/, level: 3, testType: TEST_FIND},
706 {name: "General sibling combinator, not matching element with id that is not a sibling after an element with id", selector: "#sibling-div2~#sibling-div3, #sib ling-div2~#sibling-div1", ctx: "", expect: [] /*no matches*/, lev el: 3, testType: TEST_FIND},
707 {name: "General sibling combinator, surrounded by whitespace (1)", selector: "#sibling-p2\t\r\n~\t\r\n#sibl ing-p3", ctx: "", expect: ["sibling-p3"], level: 3, testType: TEST_FIND | TEST_MATCH},
708 {name: "General sibling combinator, whitespace after (1)", selector: "#sibling-p2~\t\r\n#sibling-p3 ", ctx: "", expect: ["sibling-p3"], level: 3, testType: TEST_FIND | TEST_MATCH},
709 {name: "General sibling combinator, whitespace before (1)", selector: "#sibling-p2\t\r\n~#sibling-p3 ", ctx: "", expect: ["sibling-p3"], level: 3, testType: TEST_FIND | TEST_MATCH},
710 {name: "General sibling combinator, no whitespace (1)", selector: "#sibling-p2~#sibling-p3", ctx: "", expect: ["sibling-p3"], level: 3, testType: TEST_FIND | TEST_MATCH},
711
712 // Group of selectors (comma)
713 {name: "Syntax, group of selectors separator, surrounded by whitespace (1)", s elector: "#group em\t\r \n,\t\r \n#group strong", ctx: "", expect: ["group-em1", "group-strong1"], level: 1, testType: TEST_FIND | TEST_MATCH},
714 {name: "Syntax, group of selectors separator, whitespace after (1)", s elector: "#group em,\t\r\n#group strong", ctx: "", expect: ["group-em1", "group-strong1"], level: 1, testType: TEST_FIND | TEST_MATCH},
715 {name: "Syntax, group of selectors separator, whitespace before (1)", s elector: "#group em\t\r\n,#group strong", ctx: "", expect: ["group-em1", "group-strong1"], level: 1, testType: TEST_FIND | TEST_MATCH},
716 {name: "Syntax, group of selectors separator, no whitespace (1)", s elector: "#group em,#group strong", ctx: "", expect: ["group-em1", "group-strong1"], level: 1, testType: TEST_FIND | TEST_MATCH},
717 ];
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698