content/base/test/file_bug416317.xhtml

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:73ac99ad8def
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:svg="http://www.w3.org/2000/svg"
4 xml:lang="en" lang="en" dir="ltr" id="html" class="unitTest" title=":root selector">
5 <head>
6 <title>selectorTest</title>
7 <!-- (c) Disruptive Innovations 2008 -->
8 <style type="text/css">
9 /* TEST 0 : BASIC TESTS */
10 /* element type selector */
11 body { background-color: red; margin: 10px; padding: 10px; color: red; font-family: sans-serif }
12 div { background-color: red; color: red; }
13 div.header { background-color: #e0e0e0; color: black; padding: 10px; margin-bottom: 10px;}
14 /* class selector */
15 .unitTest { width: 10px; background-color: red; color: red; margin: 0px; margin-right: 2px; float: left; }
16 .test { margin-bottom: 2px; background-color: green; color: green; }
17 /* group of selectors */
18 .unitTest, .test { height: 10px; }
19
20 .UI > * { float: left }
21 .UI { clear: both; height: auto; padding-top: 6px;}
22 .tilda { clear: both; height: auto; padding-top: 6px;}
23 .plus { clear: both; height: auto; padding-top: 6px;}
24
25 h1, p { width: 500px; color: #000; }
26 a { color: #000; }
27 #results { background: #FFF; width: 600px; padding: 10px 40px; color: #000; font-size: 11px; line-height: 1.3em; }
28 #root, #root2, #root3 { display: none; }
29
30 /* init */
31 .blox16 { background-color: red; }
32 .blox17 { background-color: red; }
33 .lastChild > p { background-color: red; }
34 .firstOfType > p { background-color: red }
35 .lastOfType > p { background-color: red }
36 .empty > .isEmpty { color: red; }
37 html { background-color: red; }
38 </style>
39 <span type="text/test" id="test"><![CDATA[
40 /* :target selector */
41 .target :target { background-color: lime; }
42
43 /* test 1 : childhood selector */
44 html > body { background-color: green; }
45 .test > .blox1 { background-color: lime; }
46
47 /* test 2 : attribute existence selector */
48 /* attribute with a value */
49 .blox2[align] { background-color: lime; }
50 /* attribute with empty value */
51 .blox3[align] { background-color: lime; }
52 /* attribute with almost similar name */
53 .blox4, .blox5 { background-color: lime }
54 .blox4[align], .blox5[align] { background-color: red; }
55
56 /* test3 : attribute value selector */
57 .blox6[align="center"] { background-color: lime; }
58 .blox6[align="c"] { background-color: red; }
59 .blox6[align="centera"] { background-color: red; }
60 .blox6[foo="\e9"] { background-color: lime; }
61 .blox6[\_foo="\e9"] { background-color: lime; }
62
63 /* test 4 : [~=] */
64 .blox7[class~="foo"] { background-color: lime; }
65 .blox8, .blox9, .blox10 { background-color: lime; }
66 .blox8[class~=""] { background-color: red; }
67 .blox9[foo~=""] { background-color: red; }
68 .blox10[foo~="foo"] { background-color: red; }
69
70 /* test5 [^=] */
71 .attrStart > .t3 { background-color: lime; }
72 .attrStart > .t1[class^="unit"] { background-color: lime; }
73 .attrStart > .t2 { background-color: lime; }
74 .attrStart > .t2[class^="nit"] { background-color: red; }
75 .attrStart > .t3[align^=""] { background-color: red; }
76 .attrStart > .t4[foo^="\e9"] { background-color: lime; }
77
78 /* test6 [$=] */
79 .attrEnd > .t3 { background-color: lime; }
80 .attrEnd > .t1[class$="t1"] { background-color: lime; }
81 .attrEnd > .t2 { background-color: lime; }
82 .attrEnd > .t2[class$="unit"] { background-color: red; }
83 .attrEnd > .t3[align$=""] { background-color: red; }
84 .attrEnd > .t4[foo$="\e9"] { background-color: lime; }
85
86 /* test7 [*=] */
87 .attrMiddle > .t3 { background-color: lime; }
88 .attrMiddle > .t1[class*="t t"] { background-color: lime; }
89 .attrMiddle > .t2 { background-color: lime; }
90 .attrMiddle > .t2[class*="a"] { background-color: red; }
91 .attrMiddle > .t3[align*=""] { background-color: red; }
92 .attrMiddle > .t4[foo*="\e9"] { background-color: lime; }
93
94 /* :first-child tests */
95 .firstChild .unitTest:first-child { background-color: lime; }
96 .blox12:first-child { background-color: red; }
97 .blox13:first-child { background-color: red; }
98 .blox12, .blox13 { background-color: lime }
99
100 /* :root tests */
101 :root { background-color: green; }
102
103 /* :scope tests */
104 :scope { background-color: green; }
105
106 /* :nth-child(n) tests */
107 .nthchild1 > :nth-last-child(odd) { background-color: lime; }
108 .nthchild1 > :nth-child(odd) { background-color: lime; }
109
110 .nthchild2 > :nth-last-child(even) { background-color: lime; }
111 .nthchild2 > :nth-child(even) { background-color: lime; }
112
113 .nthchild3 > :nth-child(3n+2) { background-color: lime; }
114 .nthchild3 > :nth-last-child(3n+1) { background-color: lime; }
115 .nthchild3 > :nth-last-child(3n+3) { background-color: lime; }
116
117 .nthoftype1 > div:nth-of-type(odd) { background-color: lime; }
118 .nthoftype1 > div:nth-last-of-type(odd) { background-color: lime; }
119 .nthoftype1 > p { background-color: green; }
120
121 .nthoftype2 > div:nth-of-type(even) { background-color: lime; }
122 .nthoftype2 > div:nth-last-of-type(even) { background-color: lime; }
123 .nthoftype2 > p { background-color: green; }
124
125 .nthoftype3 > div:nth-of-type(3n+1) { background-color: lime; }
126 .nthoftype3 > div:nth-last-of-type(3n+1) { background-color: lime; }
127 .nthoftype3 > div:nth-last-of-type(3n+2) { background-color: lime; }
128 .nthoftype3 > p { background-color: green; }
129
130 /* :not() tests */
131 .blox14:not(span) { background-color: lime; }
132 .blox15:not([foo="blox14"]) { background-color: lime; }
133 .blox16:not(.blox15) { background-color: lime; }
134
135 /* :only-of-type tests */
136 .blox17:only-of-type { background-color: lime; }
137 .blox18:only-of-type { background-color: red; }
138 .blox18:not(:only-of-type) { background-color: lime; }
139
140 /* :last-child tests */
141 .lastChild > :last-child { background-color: lime }
142 .lastChild > :not(:last-child) { background-color: lime }
143
144 /* :first-of-type tests */
145 .firstOfType > *:first-of-type { background-color: lime; }
146 *.firstOfType > :not(:first-of-type) { background-color: lime; }
147
148 /* :last-of-type tests */
149 .lastOfType > *:last-of-type { background-color: lime; }
150 *.lastOfType > :not(:last-of-type) { background-color: lime; }
151
152 /* :only-child tests */
153 .onlyChild > *:not(:only-child) { background-color: lime; }
154 .onlyChild > .unitTest > *:only-child { background-color: lime; }
155
156 /* :only-of-type tests */
157 .onlyOfType *:only-of-type { background-color: lime; }
158 .onlyOfType *:not(:only-of-type) { background-color: lime; }
159
160 /* :empty tests */
161 .empty > *.isEmpty:empty { background-color: lime; color: lime; }
162 .empty > .isNotEmpty { background-color: blue; color: blue; }
163 .empty > .isNotEmpty:empty { background-color: red; color: red; }
164 .empty > .isNotEmpty:not(:empty) { background-color: lime; color: lime; }
165
166 /* :lang() tests */
167 .lang :lang(en) { background-color: lime; }
168 .lang :lang(fr) { background-color: lime; }
169 .lang .t1 { background-color: blue; }
170 .lang .t1:lang(es) { background-color: lime; }
171 .lang :lang(es-AR) { background-color: red; }
172
173 /* [|=] tests */
174 .attrLang .t1 { background-color: lime; }
175 .attrLang .t1[lang|="en"] { background-color: red; }
176 .attrLang [lang|="fr"] { background-color: lime; }
177 .attrLang .t2[lang|="en"] { background-color: lime; }
178 .attrLang .t3 { background-color: blue; }
179 .attrLang .t3[lang|="es"] { background-color: lime; }
180 .attrLang [lang|="es-AR"] { background-color: red; }
181
182 /* UI tests */
183 .UI .t1:enabled > .unitTest { background-color: lime; }
184 .UI .t2:disabled > .unitTest { background-color: lime; }
185 .UI .t3:checked + div { background-color: lime; }
186 .UI .t4:not(:checked) + div { background-color: lime; }
187
188 /* ~ combinator tests */
189 .tilda .t1 { background-color: white; }
190 .tilda .t1 ~ .unitTest { background-color: lime; }
191 .tilda .t1:hover ~ .unitTest { background-color: red; }
192
193 /* ~ combinator tests */
194 .plus .t1, .plus .t2 { background-color: white; }
195 .plus .t1 + .unitTest + .unitTest { background-color: lime; }
196 .plus .t1:hover + .unitTest + .unitTest { background-color: red; }
197 ]]></span>
198 <span type="text/test" id="error">
199 .blox16:not(.blox15[foo="blox14"]) { background-color: red; }
200
201 /* Tests from http://www.w3.org/Style/CSS/Test/CSS3/Selectors/20060307/html/index.html */
202 div:not(:not(div)) { background-color : red }
203
204 div, { background: red; }
205 .5cm { background: red; }
206 foo &amp; address, p { background: red; }
207 [*=test] { background: red; }
208 [*|*=test] { background: red; }
209
210 div:subject { background: red; }
211 :canvas { background: red; }
212 :viewport { background: red; }
213 :window { background: red; }
214 :menu { background: red; }
215 :table { background: red; }
216 :select { background: red; }
217 ::canvas { background: red; }
218 ::viewport { background: red; }
219 ::window { background: red; }
220 ::menu { background: red; }
221 ::table { background: red; }
222 ::select { background: red; }
223
224 ..test { background: red; color: yellow; }
225 .foo..quux { background: red; color: yellow; }
226 .bar. { background: red; color: yellow; }
227 </span>
228 <script><![CDATA[
229 window.onload = function() {
230 if (window.parent && window.parent.SpecialPowers) {
231 window.parent.SpecialPowers.pushPrefEnv(
232 { 'set': [[ "layout.css.scope-pseudo.enabled", true]] },
233 doTest);
234 } else {
235 doTest();
236 }
237 }
238
239 function doTest(){
240 if ( window.location.hash.indexOf("target") == -1 )
241 window.location.hash = "#target";
242
243 var root = document.getElementById("root");
244 var root2 = document.getElementById("root2");
245 var root3 = document.getElementById("root3");
246 var results = [];
247 var tests = 0, passed = 0;
248 var cache = {};
249
250 var css = document.getElementById("test").firstChild.nodeValue.split("\n");
251 for ( var i = 0; i < css.length; i++ ) {
252 css[i] = css[i].replace(/\/\*.*?\*\//g, "")
253 .replace(/^\s*|\s*$/g, "").split(/\s*{/);
254 }
255
256 var ecss = document.getElementById("error").firstChild.nodeValue.split("\n");
257 for ( var i = 0; i < ecss.length; i++ ) {
258 ecss[i] = ecss[i].replace(/\/\*.*?\*\//g, "")
259 .replace(/^\s*|\s*$/g, "").split(/\s*{/);
260 }
261
262 var namespaceCheck = {};
263
264 var badNamespace = [
265 {},
266 null,
267 undefined,
268 ];
269
270 interfaceCheck(root, "Element");
271 runTest( css, "Element", root, true );
272 check( "Inside Element", root, true, false );
273 cacheCheck( "Element", root );
274 check( "Outside Element", root2, passed === 0 ? "autofail" : false, false );
275 runTest( ecss, "SyntaxError: Element", root, false );
276 jqTests("Element", root3, "querySelectorAll");
277
278 var root4 = root2.cloneNode(true);
279 interfaceCheck(root4, "Disconnected Element");
280 runTest( css, "Disconnected Element", root4, true );
281 check( "Disconnected Element", root4, true, true );
282 cacheCheck( "Disconnected Element", root4 );
283 runTest( ecss, "SyntaxError: Disconnected Element", root4, false );
284 jqTests("Disconnected Element", root3.cloneNode(true), "querySelectorAll");
285 var newRoot = document.createElement("nosuchtag");
286 newRoot.appendChild(root3.cloneNode(true));
287 jqTests("Disconnected Element scoping", newRoot, "querySelectorAll");
288
289 var fragment = document.createDocumentFragment();
290 fragment.appendChild( root2.cloneNode(true) );
291
292 interfaceCheck(fragment, "Fragment");
293 runTest( css, "Fragment", fragment, true );
294 check( "Fragment", fragment, true, true );
295 runTest( ecss, "SyntaxError: Fragment", fragment, false );
296 cacheCheck( "Fragment", fragment );
297
298 root.parentNode.removeChild( root );
299
300 interfaceCheck(document, "Document");
301 runTest( css, "Document", document, true );
302 check( "Document", document, true, false );
303 runTest( ecss, "SyntaxError: Document", document, false );
304 jqTests("Document", document, "querySelectorAll");
305 cacheCheck( "Document", document );
306
307 done();
308
309 function interfaceCheck(obj, type){
310 var q = typeof obj.querySelector === "function";
311 assert( q, type + " supports querySelector" );
312 var qa = typeof obj.querySelectorAll === "function";
313 assert( qa, type + " supports querySelectorAll" );
314 return q && qa;
315 }
316
317 function done(){
318 if (window.parent && window.parent.SimpleTest) {
319 window.parent.SimpleTest.finish();
320 } else {
321 var r = document.getElementById("results");
322 var li = document.createElement("li");
323 var b = document.createElement("b");
324 b.appendChild( document.createTextNode( ((passed / tests) * 100).toFixed(1) + "%" ) );
325 li.appendChild( b );
326 li.appendChild( document.createTextNode( ": " + passed + " passed, " + (tests - passed) + " failed" ) );
327 r.appendChild( li );
328
329 for ( var i = 0; i < results.length; i++ ) {
330 var li = document.createElement("li");
331 var span = document.createElement("span");
332 span.style.color = (results[i][0] === "FAIL" ? "red" : "green");
333 span.appendChild( document.createTextNode( results[i][0] ) );
334 li.appendChild( span );
335 li.appendChild( document.createTextNode( " " + results[i][1] ) );
336 r.appendChild( li );
337 }
338 }
339 }
340
341 function cacheCheck( type, root ) {
342 try {
343 var pre = root.querySelectorAll( "div" ), preLength = pre.length;
344
345 var div = document.createElement("div");
346 (root.body || root).appendChild( div );
347
348 var post = root.querySelectorAll( "div" ), postLength = post.length;
349
350 assert( pre.length == preLength, type + ": StaticNodeList" );
351 assert( post.length != pre.length, type + ": StaticNodeList" );
352 } catch(e) {
353 assert( false, type + ": StaticNodeList" );
354 assert( false, type + ": StaticNodeList" );
355 }
356
357 if ( div )
358 (root.body || root).removeChild( div );
359 }
360
361
362 function runTest( css, type, root, expect ) {
363 var pass = false;
364 try {
365 root.querySelectorAll("");
366 } catch(e){ pass = e.name == "SyntaxError" && e.code == DOMException.SYNTAX_ERR; }
367 assert( pass, type + ".querySelectorAll Empty String" );
368
369 pass = false;
370 try {
371 pass = root.querySelectorAll(null).length === 0;
372 } catch(e){ pass = false; }
373 assert( pass, type + ".querySelectorAll null" );
374
375 pass = false;
376 try {
377 pass = root.querySelectorAll(undefined).length === 0;
378 } catch(e){ pass = false; }
379 assert( pass, type + ".querySelectorAll undefined" );
380
381 pass = false;
382 try {
383 if ( root.querySelectorAll )
384 root.querySelectorAll();
385 } catch(e){ pass = true; }
386 assert( pass, type + ".querySelectorAll no value" );
387
388 pass = false;
389 try {
390 root.querySelector("");
391 } catch(e){ pass = e.name == "SyntaxError" && e.code == DOMException.SYNTAX_ERR; }
392 assert( pass, type + ".querySelector Empty String" );
393
394 pass = false;
395 try {
396 pass = root.querySelector(null) === null;
397 } catch(e){ pass = false; }
398 assert( pass, type + ".querySelector null" );
399
400 pass = false;
401 try {
402 pass = root.querySelector(undefined) === null;
403 } catch(e){ pass = false; }
404 assert( pass, type + ".querySelector undefined" );
405
406 pass = false;
407 try {
408 if ( root.querySelector )
409 root.querySelector();
410 } catch(e){ pass = true; }
411 assert( pass, type + ".querySelector no value" );
412
413 for ( var i = 0; i < css.length; i++ ) {
414 var test = css[i];
415 if ( test.length == 2 ) {
416 var query = test[0], color = test[1].match(/: ([^\s;]+)/)[1];
417
418 try {
419 var found = root.querySelectorAll(query);
420
421 for ( var f = 0; f < found.length; f++ ) {
422 found[f].style.backgroundColor = color;
423 }
424
425 var pass = color != "red" || found.length === 0;
426
427 assert(expect && pass, type + ".querySelectorAll: " + query);
428 } catch(e){
429 var pass = !expect && e.name == "SyntaxError" && e.code == DOMException.SYNTAX_ERR || false;
430 assert(pass, type + ".querySelectorAll: " + query);
431 }
432
433 if ( expect ) {
434 var pass = false;
435
436 try {
437 var found2 = root.querySelectorAll( " \t\r\n " + query + " \t\r\n " );
438 pass = found2.length == found.length;
439 } catch(e) {}
440
441 assert(pass, type + ".querySelectorAll Whitespace Trim: " + query);
442 }
443
444 try {
445 var single = root.querySelector(query);
446
447 var pass = found.length == 0 && single === null ||
448 found.length && found[0] == single;
449
450 assert(expect, type + ".querySelector: " + query);
451 } catch(e){
452 var pass = !expect && e.name == "SyntaxError" && e.code == DOMException.SYNTAX_ERR || false;
453 assert(pass, type + ".querySelector: " + query);
454 }
455 }
456 }
457 }
458
459 function check( type, root, expect, fragment ){
460 var walker = document.createTreeWalker( root, NodeFilter.SHOW_ELEMENT, { acceptNode: function(){ return 1; } } );
461
462 while ( walker.nextNode() ) {
463 var div = walker.currentNode;
464 if ( (div.getAttribute("class") || "").toString().indexOf("unitTest") > -1 &&
465 (!fragment || div.getAttribute("id") !== "nofragment") ) {
466 // If we're display:none, we need to toggle that when doing computed
467 // style.
468 var needToggle =
469 (window.frameElement &&
470 window.frameElement.style.display == "none");
471 if (needToggle) {
472 if ((div.getAttribute("class") || "").toString().indexOf("skipWhenToggling") > -1) {
473 continue;
474 }
475 window.frameElement.style.display = "";
476 // make sure it kicks in immediately
477 document.body.offsetWidth;
478 }
479 var view = document.defaultView.getComputedStyle(div, null);
480 var bg = view.getPropertyValue("background-color") || div.style.backgroundColor;
481 if (needToggle) {
482 window.frameElement.style.display = "none";
483 // make sure it kicks in immediately
484 document.body.offsetWidth;
485 }
486
487 var pass = bg && bg.indexOf("(255, 0, 0") == -1 && bg.indexOf("#ff0000") == -1 && bg.indexOf("red") == -1;
488 //var pass = bg && bg.indexOf("(255, 0, 0") == -1 && bg.indexOf("#ff0000") == -1;
489 assert(pass === expect, type + ": " + (div.title || div.parentNode.title));
490 }
491 }
492 }
493
494 function assert(pass, title) {
495 // Update |passed| no matter what: some tests depend on this
496 passed += (pass ? 1 : 0);
497
498 if (window.parent && window.parent.SimpleTest) {
499 window.parent.SimpleTest.ok(pass, title);
500 } else {
501 results.push([ (!pass ? "FAIL" : "PASS"), title ]);
502 tests++;
503 }
504 }
505
506 function jqTests(type, root, select) {
507
508 function query(q, resolver){
509 try {
510 return root[select](q, resolver);
511 } catch(e){
512 if ( e.message.indexOf("ERR") > -1 ||
513 (e.name == "SyntaxError" && e.code == DOMException.SYNTAX_ERR) )
514 throw e;
515 }
516 }
517
518 var all = query("*");
519
520 function checkMatchesSelector(results, q) {
521 var key = +new Date + ":" + Math.random();
522
523 function report(item, shouldMatch) {
524 assert( item.mozMatchesSelector(q) === shouldMatch,
525 item + (shouldMatch ? "does not match" : "matches")
526 + " selector '" + q + "'" );
527 }
528
529 for (var i = 0; i < results.length; i++) {
530 var item = results.item(i);
531 item[key] = true;
532 report( item, true );
533 }
534
535 for (var stride = 15, // reduce test spam
536 i = Math.round(Math.random() * stride);
537 i < all.length; i += stride)
538 {
539 var item = all.item(i),
540 shouldMatch = !!item[key];
541 report( item, shouldMatch );
542 }
543
544 for (var i = 0; i < results.length; i++)
545 delete results.item(i)[key];
546 }
547
548 function t( name, q, ids, restrict, ids2 ) {
549 var pass = true;
550
551 if ( restrict === false && root != document )
552 return;
553
554 var namespaced = /\|[^=]/.test( q );
555 var prepend = namespaced ? "xHTML|*#root3 " : "#root3 ";
556 q = (restrict === false || restrict === ":root" ||
557 restrict === ":scope" ? "" : prepend) +
558 q.replace(/,/g, ", " + prepend);
559 var nq = q.replace(/>/g, "&gt;").replace(/</g, "&lt;");
560
561 if ( namespaced ) {
562 for ( var i = 0; i < badNamespace.length; i++ ) {
563 var resolver = badNamespace[i], pass = false, results = null;
564
565 try {
566 results = query(q, resolver);
567 } catch(e) {
568 pass = (e.message === "bad ERROR" ||
569 (e.name == "SyntaxError" && e.code == DOMException.SYNTAX_ERR));
570 }
571
572 assert( pass, type + ": " + name + " Bad Resolver #" + (i+1) + " (" + nq + ")" +
573 (pass ? "" : " Expected: " + extra(ids) + " Received: " + extra(results)) );
574 }
575 } else {
576 var pass = false;
577
578 try {
579 var results = query(q);
580 pass = hasPassed( results, ids );
581 } catch(e) {
582 pass = e.name == "SyntaxError" && e.code == DOMException.SYNTAX_ERR;
583 }
584
585 assert( pass, type + ": " + name + " (" + nq + ")" +
586 (pass ? "" : " Expected: " + extra(ids) + " Received: " + extra(results)) );
587
588 // For now, don't use checkMatchesSelector when
589 // restrict === ":scope" because we have no way to hand the
590 // right scope to it yet.
591 if (results && restrict !== ":scope")
592 checkMatchesSelector( results, q );
593 }
594
595 function hasPassed(results, ids){
596 var pass = (results && results.length == ids.length) || (!results && !ids);
597
598 if ( ids && results ) {
599 for ( var i = 0; ids && i < ids.length; i++ ) {
600 if ( ids[i] !== results[i].getAttribute("id") ) {
601 pass = false;
602 }
603 }
604 } else {
605 pass = false;
606 }
607
608 return pass;
609 }
610
611 function extra(results){
612 var extra = " [";
613 if ( results ) {
614 for ( var i = 0; i < results.length; i++ ) {
615 extra += (extra.length > 2 ? "," : "") + "'" + (results[i].id || results[i]) + "'";
616 }
617 }
618
619 extra += "]";
620 return extra;
621 }
622 }
623
624 t( "SVG", "*|svg", ["svg1","svg2","svg3"] );
625 t( "SVG", "svg|svg", ["svg2","svg3"] );
626 t( "SVG", "svg|svg *|circle", ["circle2","circle3"] );
627 t( "SVG", "svg|svg svg|circle", ["circle2","circle3"] );
628 t( "SVG", "xHTML|div *|svg", ["svg1","svg2","svg3"] );
629 t( "SVG", "div svg|svg", ["svg2","svg3"] );
630 t( "SVG", "xHTML|div svg|svg", ["svg2","svg3"] );
631 t( "SVG", "xHTML|div svg|svg *|circle", ["circle2","circle3"] );
632 t( "SVG", "xHTML|div svg *|circle", ["circle1","circle2","circle3"], true, ["circle1"] );
633 t( "SVG", "xHTML|div svg|svg svg|circle", ["circle2","circle3"] );
634
635 t( "Element Selector", "xHTML|p", ["firstp","ap","sndp","en","sap","first"] );
636 t( "Parent Element", "xHTML|div p", ["firstp","ap","sndp","en","sap","first"] );
637 t( "Parent Element", "xHTML|div xHTML|p", ["firstp","ap","sndp","en","sap","first"] );
638 t( "Parent Element", "*|div xHTML|p", ["firstp","ap","sndp","en","sap","first"] );
639 t( "Parent Element", "*|div *|p", ["firstp","ap","sndp","en","sap","first"] );
640 t( "Child", "xHTML|p > xHTML|a", ["simon1","google","groups","mark","yahoo","simon"] );
641 t( "Adjacent", "xHTML|a + xHTML|a", ["groups"] );
642 t( "Adjacent", "xHTML|a + a", ["groups"] );
643 t( "Nth-child", "xHTML|*#form xHTML|*#select1 xHTML|option:nth-child(3)", ["option1c"] );
644
645 assert( all && all.length > 30, type + ": Select all" );
646 var good = all && all.length;
647 for ( var i = 0; all && i < all.length; i++ )
648 if ( all[i].nodeType != 1 )
649 good = false;
650 assert( good, type + ": Select all elements, no comment nodes" );
651
652 if ( root == document ) {
653 t( ":root Selector", ":root", ["html"], false );
654 t( ":scope Selector", ":scope", ["html"], ":scope" );
655 } else {
656 t( ":root Selector", ":root", [], ":root" );
657 if (root.localName != "nosuchtag") {
658 t( ":scope Selector", ":scope > nosuchtag",
659 [ "outerbogustag" ], ":scope");
660 }
661 t( ":scope Selector", ":scope nosuchtag nosuchtag",
662 [ "innerbogustag" ], ":scope");
663
664 if ( !root.parentNode ) {
665 t( ":root All Selector", ":root *", [], ":root" );
666 }
667 }
668
669 if ( root.parentNode || root == document ) {
670 assert( query(":root *").length == query("*").length - (root == document ? 1 : 0), type + ": :root All Selector" );
671 }
672 assert( query(":scope *").length == query("*").length - (root == document ? 1 : 0), type + ": :scope All Selector" );
673
674 t( "Element Selector", "p", ["firstp","ap","sndp","en","sap","first"] );
675 t( "Element Selector", "body", ["body"], false );
676 t( "Element Selector", "html", ["html"], false );
677 t( "Parent Element", "div p", ["firstp","ap","sndp","en","sap","first"] );
678 var param = query("#object1 param");
679 assert( param && param.length == 2, type + ": Object/param as context" );
680
681 var l = query("#length");
682 assert( l && l.length, type + ': &lt;input name="length"&gt; cannot be found under IE' );
683 var lin = query("#lengthtest input");
684 assert( lin && lin.length, type + ': &lt;input name="length"&gt; cannot be found under IE' );
685
686 t( "Broken Selector", "[" );
687 t( "Broken Selector", "(" );
688 t( "Broken Selector", "{" );
689 t( "Broken Selector", "<" );
690 t( "Broken Selector", "()" );
691 t( "Broken Selector", "<>" );
692 t( "Broken Selector", "{}" );
693
694 t( "ID Selector", "#body", ["body"], false );
695 t( "ID Selector w/ Element", "body#body", ["body"], false );
696 t( "ID Selector w/ Element", "ul#first", [] );
697 t( "ID selector with existing ID descendant", "#firstp #simon1", ["simon1"] );
698 t( "ID selector with nonexistent descendant", "#firstp #foobar", [] );
699
700 t( "ID selector using UTF8", "#台北Táiběi", ["台北Táiběi"] );
701 t( "Multiple ID selectors using UTF8", "#台北Táiběi, #台北", ["台北Táiběi","台北"] );
702 t( "Descendant ID selector using UTF8", "div #台北", ["台北"] );
703 t( "Child ID selector using UTF8", "form > #台北", ["台北"] );
704
705 t( "Escaped ID", "#foo\\:bar", ["foo:bar"] );
706 t( "Escaped ID", "#test\\.foo\\[5\\]bar", ["test.foo[5]bar"] );
707 t( "Descendant escaped ID", "div #foo\\:bar", ["foo:bar"] );
708 t( "Descendant escaped ID", "div #test\\.foo\\[5\\]bar", ["test.foo[5]bar"] );
709 t( "Child escaped ID", "form > #foo\\:bar", ["foo:bar"] );
710 t( "Child escaped ID", "form > #test\\.foo\\[5\\]bar", ["test.foo[5]bar"] );
711
712 t( "ID Selector, child ID present", "#form > #radio1", ["radio1"] ); // bug #267
713 t( "ID Selector, not an ancestor ID", "#form #first", [] );
714 t( "ID Selector, not a child ID", "#form > #option1a", [] );
715
716 t( "All Children of ID", "#foo > *", ["sndp", "en", "sap"] );
717 t( "All Children of ID with no children", "#firstUL > *", [] );
718
719 t( "ID selector with nonexistent ancestor", "#asdfasdf #foobar", [] ); // bug #986
720
721 //t( "body div#form", [], "ID selector within the context of another element" );
722
723 t( "Class Selector", ".blog", ["mark","simon"] );
724 t( "Class Selector", ".blog.link", ["simon"] );
725 t( "Class Selector w/ Element", "a.blog", ["mark","simon"] );
726 t( "Parent Class Selector", "p .blog", ["mark","simon"] );
727
728 t( "Class selector using UTF8", ".台北Táiběi", ["utf8class1"] );
729 t( "Class selector using UTF8", ".台北", ["utf8class1","utf8class2"] );
730 t( "Class selector using UTF8", ".台北Táiběi.台北", ["utf8class1"] );
731 t( "Class selector using UTF8", ".台北Táiběi, .台北", ["utf8class1","utf8class2"] );
732 t( "Descendant class selector using UTF8", "div .台北Táiběi", ["utf8class1"] );
733 t( "Child class selector using UTF8", "form > .台北Táiběi", ["utf8class1"] );
734
735 t( "Escaped Class", ".foo\\:bar", ["foo:bar"] );
736 t( "Escaped Class", ".test\\.foo\\[5\\]bar", ["test.foo[5]bar"] );
737 t( "Descendant scaped Class", "div .foo\\:bar", ["foo:bar"] );
738 t( "Descendant scaped Class", "div .test\\.foo\\[5\\]bar", ["test.foo[5]bar"] );
739 t( "Child escaped Class", "form > .foo\\:bar", ["foo:bar"] );
740 t( "Child escaped Class", "form > .test\\.foo\\[5\\]bar", ["test.foo[5]bar"] );
741
742 t( "Comma Support", "a.blog, p", ['firstp','ap','mark','sndp','en','sap','simon','first'] );
743 t( "Comma Support", "a.blog , p", ['firstp','ap','mark','sndp','en','sap','simon','first'] );
744 t( "Comma Support", "a.blog ,p", ['firstp','ap','mark','sndp','en','sap','simon','first'] );
745 t( "Comma Support", "a.blog,p", ['firstp','ap','mark','sndp','en','sap','simon','first'] );
746
747 t( "Outer Whitespace", " a.blog,p", ['firstp','ap','mark','sndp','en','sap','simon','first'] );
748 t( "Outer Whitespace", "a.blog,p ", ['firstp','ap','mark','sndp','en','sap','simon','first'] );
749 t( "Outer Whitespace", " p,a.blog", ['firstp','ap','mark','sndp','en','sap','simon','first'] );
750 t( "Outer Whitespace", "p,a.blog ", ['firstp','ap','mark','sndp','en','sap','simon','first'] );
751
752 t( "Child", "p > a", ["simon1","google","groups","mark","yahoo","simon"] );
753 t( "Child", "p> a", ["simon1","google","groups","mark","yahoo","simon"] );
754 t( "Child", "p >a", ["simon1","google","groups","mark","yahoo","simon"] );
755 t( "Child", "p>a", ["simon1","google","groups","mark","yahoo","simon"] );
756 t( "Child w/ Class", "p > a.blog", ["mark","simon"] );
757 t( "All Children", "code > *", ["anchor1","anchor2"] );
758 t( "All Grandchildren", "p > * > *", ["anchor1","anchor2"] );
759 t( "Adjacent", "a + a", ["groups"] );
760 t( "Adjacent", "a +a", ["groups"] );
761 t( "Adjacent", "a+ a", ["groups"] );
762 t( "Adjacent", "a+a", ["groups"] );
763 t( "Adjacent", "p + p", ["ap","en","sap"] );
764 t( "Comma, Child, and Adjacent", "a + a, code > a", ["groups","anchor1","anchor2"] );
765
766 t( "First Child", "p:first-child", ["firstp","sndp"] );
767 t( "Nth Child", "p:nth-child(1)", ["firstp","sndp"] );
768
769 t( "Last Child", "p:last-child", ["sap"] );
770 t( "Last Child", "a:last-child", ["simon1","anchor1","mark","yahoo","anchor2","simon"] );
771
772 t( "Nth-child", "#main form#form > *:nth-child(2)", ["text2"] );
773 t( "Nth-child", "#main form#form > :nth-child(2)", ["text2"] );
774
775 t( "Nth-child", "#form #select1 option:nth-child(3)", ["option1c"] );
776 t( "Nth-child", "#form #select1 option:nth-child(0n+3)", ["option1c"] );
777 t( "Nth-child", "#form #select1 option:nth-child(1n+0)", ["option1a", "option1b", "option1c", "option1d"] );
778 t( "Nth-child", "#form #select1 option:nth-child(1n)", ["option1a", "option1b", "option1c", "option1d"] );
779 t( "Nth-child", "#form #select1 option:nth-child(n)", ["option1a", "option1b", "option1c", "option1d"] );
780 t( "Nth-child", "#form #select1 option:nth-child(even)", ["option1b", "option1d"] );
781 t( "Nth-child", "#form #select1 option:nth-child(odd)", ["option1a", "option1c"] );
782 t( "Nth-child", "#form #select1 option:nth-child(2n)", ["option1b", "option1d"] );
783 t( "Nth-child", "#form #select1 option:nth-child(2n+1)", ["option1a", "option1c"] );
784 t( "Nth-child", "#form #select1 option:nth-child(3n)", ["option1c"] );
785 t( "Nth-child", "#form #select1 option:nth-child(3n+1)", ["option1a", "option1d"] );
786 t( "Nth-child", "#form #select1 option:nth-child(3n+2)", ["option1b"] );
787 t( "Nth-child", "#form #select1 option:nth-child(3n+3)", ["option1c"] );
788 t( "Nth-child", "#form #select1 option:nth-child(3n-1)", ["option1b"] );
789 t( "Nth-child", "#form #select1 option:nth-child(3n-2)", ["option1a", "option1d"] );
790 t( "Nth-child", "#form #select1 option:nth-child(3n-3)", ["option1c"] );
791 t( "Nth-child", "#form #select1 option:nth-child(3n+0)", ["option1c"] );
792 t( "Nth-child", "#form #select1 option:nth-child(-n+3)", ["option1a", "option1b", "option1c"] );
793
794 t( "Attribute Exists", "a[title]", ["google"] );
795 t( "Attribute Exists", "*[title]", ["google"] );
796 t( "Attribute Exists", "[title]", ["google"] );
797
798 t( "Attribute Equals", "a[rel='bookmark']", ["simon1"] );
799 t( "Attribute Equals", 'a[rel="bookmark"]', ["simon1"] );
800 t( "Attribute Equals", "a[rel=bookmark]", ["simon1"] );
801 t( "Multiple Attribute Equals", "#form input[type='hidden'],#form input[type='radio']", ['radio1','radio2','hidden1'] );
802 t( "Multiple Attribute Equals", "#form input[type=\"hidden\"],#form input[type='radio']", ['radio1','radio2','hidden1'] );
803 t( "Multiple Attribute Equals", "#form input[type=hidden],#form input[type=radio]", ['radio1','radio2','hidden1'] );
804
805 t( "Attribute selector using UTF8", "span[lang=中文]", ["台北"] );
806
807 t( "Attribute Begins With", "a[href ^= 'http://www']", ["google","yahoo"] );
808 t( "Attribute Ends With", "a[href $= 'org/']", ["mark"] );
809 t( "Attribute Contains", "a[href *= 'google']", ["google","groups"] );
810
811 // t("Select options via [selected]", "#select1 option[selected]", ["option1a"] );
812 t("Select options via [selected]", "#select1 option[selected]", [] );
813 t("Select options via [selected]", "#select2 option[selected]", ["option2d"] );
814 t("Select options via [selected]", "#select3 option[selected]", ["option3b", "option3c"] );
815
816 t( "Grouped Form Elements", "input[name='foo[bar]']", ["hidden2"] );
817
818 t( ":not() Existing attribute", "#form select:not([multiple])", ["select1", "select2"]);
819 t( ":not() Equals attribute", "#form select:not([name=select1])", ["select2", "select3"]);
820 t( ":not() Equals quoted attribute", "#form select:not([name='select1'])", ["select2", "select3"]);
821
822 t( "First Child", "p:first-child", ["firstp","sndp"] );
823 t( "Last Child", "p:last-child", ["sap"] );
824 t( "Only Child", "a:only-child", ["simon1","anchor1","yahoo","anchor2"] );
825 t( "Empty", "ul:empty", ["firstUL"] );
826 //t( "Enabled UI Element", "#form input:enabled", ["text1","radio1","radio2","check1","check2","hidden2","name"] );
827 t( "Disabled UI Element", "#form input:disabled", ["text2"] );
828 t( "Checked UI Element", "#form input:checked", ["radio2","check1"] );
829 t( "Element Preceded By", "p ~ div", ["foo","fx-queue","fx-tests", "moretests"] );
830 t( "Not", "a.blog:not(.link)", ["mark"] );
831 }
832 };
833 ]]></script>
834 </head>
835 <body id="body" class="unitTest" title="childhood and element type selectors">
836 <h1><a href="http://www.w3.org/TR/selectors-api/">Selectors API</a> Test Suite</h1>
837 <p>Testrunner by <a href="http://ejohn.org/">John Resig</a>, tests by <a href="http://ejohn.org/">John Resig</a>, <a href="http://disruptive-innovations.com/zoo/css3tests/selectorTest.html">Disruptive Innovations</a>, <a href="http://www.w3.org/Style/CSS/Test/CSS3/Selectors/20060307/html/index.html">W3C CSS Working Group</a>, <a href="http://jquery.com/test/">jQuery JavaScript Library</a>.</p>
838 <div id="root">
839 <div class="header">
840 <h3>CSS 3 Selectors tests</h3>
841 <p>(c) <a href="http://www.disruptive-innovations.com">Disruptive Innovations</a> 2008<br/>
842 Last update: 2008-06-06</p>
843 </div>
844
845 <div class="test target">
846 <div class="unitTest skipWhenToggling" id="target" title=":target selector"></div>
847 </div>
848
849 <div class="test">
850 <div class="blox1 unitTest" title="childhood selector"></div>
851 </div>
852
853 <div class="test attributeExistence">
854 <div class="blox2 unitTest" align="center" title="attribute existence selector"></div>
855 <div class="blox3 unitTest" align="" title="attribute existence selector with empty string value"></div>
856 <div class="blox4 unitTest" valign="center" title="attribute existence selector with almost identical attribute"></div>
857 <div class="blox5 unitTest" alignv="center" title="attribute existence selector with almost identical attribute"></div>
858 </div>
859
860 <div class="test attributeValue">
861 <div class="blox6 unitTest" align="center" title="attribute value selector"></div>
862 <div class="blox6 unitTest" foo="&eacute;" title="attribute value selector with an entity in the attribute and an escaped value in the selector"></div>
863 <div class="blox6 unitTest" _foo="&eacute;" title="attribute value selector with an entity in the attribute, an escaped value in the selector, and a leading underscore in the attribute name"></div>
864 </div>
865
866 <div class="test attributeSpaceSeparatedValues">
867 <div class="blox7 foo unitTest" title="[~=] attribute selector"></div>
868 <div class="blox8 unitTest" title="[~=] attribute selector looking for empty string"></div>
869 <div class="blox9 unitTest" foo="" title="[~=] attribute selector looking for empty string in empty attribute"></div>
870 <div class="blox10 unitTest" foo="foobar" title="[~=] attribute selector looking for 'foo' in 'foobar'"></div>
871 </div>
872
873 <div class="test attrStart">
874 <div class="unitTest t1" title="[^=] attribute selector"></div>
875 <div class="unitTest t2" title="[^=] attribute selector"></div>
876 <div class="unitTest t3" align="center" title="[^=] attribute selector looking for empty string"></div>
877 <div class="unitTest t4" foo="&eacute;tagada" title="[^=] attribute selector looking for &eacute;"></div>
878 </div>
879
880 <div class="test attrEnd">
881 <div class="unitTest t1" title="[$=] attribute selector"></div>
882 <div class="unitTest t2" title="[$=] attribute selector"></div>
883 <div class="unitTest t3" align="center" title="[$=] attribute selector looking for empty string"></div>
884 <div class="unitTest t4" foo="tagada&eacute;" title="[$=] attribute selector looking for &eacute;"></div>
885 </div>
886
887 <div class="test attrMiddle">
888 <div class="unitTest t1" title="[*=] attribute selector"></div>
889 <div class="unitTest t2" title="[*=] attribute selector"></div>
890 <div class="unitTest t3" align="center" title="[*=] attribute selector looking for empty string"></div>
891 <div class="unitTest t4" foo="tagada&eacute;foo" title="[*=] attribute selector looking for &eacute;"></div>
892 </div>
893
894 <div class="test firstChild">
895 <div class="unitTest" title=":first-child selector"></div>
896 <div class="blox12 unitTest" title=":first-child selector should not match non first child"></div>
897 <div class="blox13 unitTest" title=":first-child selector should not match non first child"></div>
898 </div>
899
900 <div class="test not">
901 <div class="blox14 unitTest" title="negation pseudo-class with argument being an element type selector"></div>
902 <div class="blox15 unitTest" foo="blox15" title="negation pseudo-class with argument being an attribute selector"></div>
903 <div class="blox16 unitTest" foo="blox15" title="negation pseudo-class accepts only simple selectors for argument"></div>
904 </div>
905
906 <div class="test onlyOfType">
907 <div class="blox17 unitTest" title=":only-of-type selector"></div>
908 <p class="blox18 unitTest" title="negated :only-of-type selector"></p>
909 <p class="blox18 unitTest" title="negated :only-of-type selector"></p>
910 </div>
911
912 <div class="test nthchild1">
913 <div class="unitTest" title=":nth-child(odd) selector"></div>
914 <div class="unitTest" title=":nth-last-child(odd) selector"></div>
915 <div class="unitTest" title=":nth-child(odd) selector"></div>
916 <div class="unitTest" title=":nth-last-child(odd) selector"></div>
917 <div class="unitTest" title=":nth-child(odd) selector"></div>
918 <div class="unitTest" title=":nth-last-child(odd) selector"></div>
919 </div>
920 <div class="test nthchild2">
921 <div class="unitTest" title=":nth-last-child(even) selector"></div>
922 <div class="unitTest" title=":nth-child(even) selector"></div>
923 <div class="unitTest" title=":nth-last-child(even) selector"></div>
924 <div class="unitTest" title=":nth-child(even) selector"></div>
925 <div class="unitTest" title=":nth-last-child(even) selector"></div>
926 <div class="unitTest" title=":nth-child(even) selector"></div>
927 </div>
928 <div class="test nthchild3">
929 <div class="unitTest no" title=":nth-last-child(3n+3) selector"></div>
930 <div class="unitTest" title=":nth-child(3n+2) selector"></div>
931 <div class="unitTest no" title=":nth-last-child(3n+1) selector"></div>
932 <div class="unitTest no" title=":nth-last-child(3n+3) selector"></div>
933 <div class="unitTest" title=":nth-child(3n+2) selector"></div>
934 <div class="unitTest no" title=":nth-last-child(3n+1) selector"></div>
935 </div>
936
937 <div class="test nthoftype1">
938 <div class="unitTest" title=":nth-of-type(odd) selector"></div>
939 <p class="unitTest" title=":nth-* selector"></p>
940 <p class="unitTest" title=":nth-* selector"></p>
941 <div class="unitTest" title=":nth-last-of-type(odd) selector"></div>
942 <p class="unitTest" title=":nth-* selector"></p>
943 <div class="unitTest" title=":nth-of-type(odd) selector"></div>
944 <div class="unitTest" title=":nth-last-of-type(odd) selector"></div>
945 </div>
946 <div class="test nthoftype2">
947 <div class="unitTest" title=":nth-last-of-type(even) selector"></div>
948 <p class="unitTest" title=":nth-* selector"></p>
949 <p class="unitTest" title=":nth-* selector"></p>
950 <div class="unitTest" title=":nth-of-type(even) selector"></div>
951 <p class="unitTest" title=":nth-* selector"></p>
952 <div class="unitTest" title=":nth-last-of-type(even) selector"></div>
953 <div class="unitTest" title=":nth-of-type(even) selector"></div>
954 </div>
955 <div class="test nthoftype3">
956 <div class="unitTest" title=":nth-of-type(3n+1) selector"></div>
957 <p class="unitTest" title=":nth-* selector"></p>
958 <p class="unitTest" title=":nth-* selector"></p>
959 <div class="unitTest" title=":nth-last-of-type(3n+2) selector"></div>
960 <p class="unitTest" title=":nth-* selector"></p>
961 <div class="unitTest" title=":nth-last-of-type(3n+1) selector"></div>
962 <div class="unitTest" title=":nth-of-type(3n+1) selector"></div>
963 <p class="unitTest" title=":nth-* selector"></p>
964 <div class="unitTest" title=":nth-last-of-type(3n+2) selector"></div>
965 <div class="unitTest" title=":nth-last-of-type(3n+1) selector"></div>
966 </div>
967
968 <div class="test lastChild">
969 <p class="unitTest" title=":not(:last-child) selector"></p>
970 <div class="unitTest" title=":last-child selector"></div>&nbsp;
971 </div>
972
973 <div class="test firstOfType">
974 <p class="unitTest" title=":first-of-type selector"></p>
975 <div class="unitTest" title=":first-of-type selector"></div>
976 <p class="unitTest" title=":not(:first-of-type)"></p>
977 <div class="unitTest" title=":not(:first-of-type)"></div>
978 </div>
979
980 <div class="test lastOfType">
981 <p class="unitTest" title=":not(:last-of-type)"></p>
982 <div class="unitTest" title=":not(:last-of-type)"></div>
983 <p class="unitTest" title=":last-of-type selector"></p>
984 <div class="unitTest" title=":last-of-type selector"></div>
985 </div>
986
987 <div class="test onlyChild">
988 <div class="unitTest" title=":only-child where the element is NOT the only child"></div>
989 <div class="unitTest" title=":only-child where the element is the only child">
990 <div class="unitTest" title=":only-child where the element is the only child"></div>
991 </div>
992 </div>
993
994 <div class="test onlyOfType">
995 <p class="unitTest" title=":only-of-type"></p>
996 <div class="unitTest" title=":only-of-type">
997 <div class="unitTest" title=":only-of-type"></div>
998 </div>
999 <div class="unitTest" title=":not(only-of-type)"></div>
1000 </div>
1001
1002 <div class="test empty">
1003 <div class="unitTest isEmpty" title=":empty with empty element"></div>
1004 <div class="unitTest isNotEmpty" title=":empty but element contains a whitespace"> </div>
1005 <div class="unitTest isEmpty" title=":empty and element contains an SGML comment"><!-- foo --></div>
1006 <div class="unitTest isNotEmpty" title=":empty but element contains a SPAN element"><span></span></div>
1007 <div class="unitTest isNotEmpty" title=":empty but element contains an entity reference">&nbsp;</div>
1008 </div>
1009
1010 <div class="test lang">
1011 <div id="nofragment" class="unitTest" title=":lang() where language comes from the document"></div>
1012 <div class="unitTest" lang="fr" title=":lang() where language comes from the element"></div>
1013 <div class="unitTest" lang="en-US" title=":lang() where language comes from the element but is a dialect of the language queried"></div>
1014 <div class="unitTest t1" lang="es" title=":lang() where language comes from the element but the language queried is a dialect of the element's one so it should not match"></div>
1015 </div>
1016
1017 <div class="test attrLang">
1018 <div class="unitTest t1" title="[|=] where language comes from the document"></div>
1019 <div class="unitTest" lang="fr" title="[|=] where language comes from the element"></div>
1020 <div class="unitTest t2" lang="en-US" title="[|=] where language comes from the element but is a dialect of the language queried"></div>
1021 <div class="unitTest t3" lang="es" title="[|=] where language comes from the element but the language queried is a dialect of the element's one so it should not match"></div>
1022 </div>
1023
1024 <div class="test UI">
1025 <button name="submit" type="submit" value="submit" class="t1" title=":enabled pseudo-class"><div class="unitTest"></div></button>
1026 <button name="submit" type="submit" value="submit" class="t2" disabled="true" title=":enabled pseudo-class"><div class="unitTest"></div></button>
1027 </div>
1028 <div class="test UI">
1029 <input class="t3" type="checkbox" checked="true"/><div class="unitTest" title=":checked"></div>
1030 the previous square should be green when the checkbox is checked and become red when you uncheck it
1031 </div>
1032 <div class="test UI">
1033 <input class="t4" type="checkbox"/><div class="unitTest" title=":not(:checked)"></div>
1034 the previous square should be green when the checkbox is NOT checked and become red when you check it
1035 </div>
1036
1037 <div class="test tilda">
1038 <div class="unitTest t1" title="~ combinator"></div>
1039 <div class="unitTest" title="~ combinator"></div>
1040 <div class="unitTest" title="~ combinator"></div>
1041 <div class="unitTest" title="~ combinator"></div>
1042 <span style="float:left">the three last squares should be green and become red when the pointer hovers over the white square</span>
1043 </div>
1044 <div class="test plus">
1045 <div class="unitTest t1" title="+ combinator"></div>
1046 <div class="unitTest t2" title="+ combinator"></div>
1047 <div class="unitTest" title="+ combinator"></div>
1048 <span style="float:left">the last square should be green and become red when the pointer hovers over the FIRST white square</span>
1049 </div>
1050 </div>
1051 <div id="root2">
1052 <div class="header">
1053 <h3>CSS 3 Selectors tests</h3>
1054 <p>(c) <a href="http://www.disruptive-innovations.com">Disruptive Innovations</a> 2008<br/>
1055 Last update: 2008-06-06</p>
1056 </div>
1057
1058 <div class="test">
1059 <div class="blox1 unitTest" title="childhood selector"></div>
1060 </div>
1061
1062 <div class="test attributeExistence">
1063 <div class="blox2 unitTest" align="center" title="attribute existence selector"></div>
1064 <div class="blox3 unitTest" align="" title="attribute existence selector with empty string value"></div>
1065 <div class="blox4 unitTest" valign="center" title="attribute existence selector with almost identical attribute"></div>
1066 <div class="blox5 unitTest" alignv="center" title="attribute existence selector with almost identical attribute"></div>
1067 </div>
1068
1069 <div class="test attributeValue">
1070 <div class="blox6 unitTest" align="center" title="attribute value selector"></div>
1071 <div class="blox6 unitTest" foo="&eacute;" title="attribute value selector with an entity in the attribute and an escaped value in the selector"></div>
1072 <div class="blox6 unitTest" _foo="&eacute;" title="attribute value selector with an entity in the attribute, an escaped value in the selector, and a leading underscore in the attribute name"></div>
1073 </div>
1074
1075 <div class="test attributeSpaceSeparatedValues">
1076 <div class="blox7 foo unitTest" title="[~=] attribute selector"></div>
1077 <div class="blox8 unitTest" title="[~=] attribute selector looking for empty string"></div>
1078 <div class="blox9 unitTest" foo="" title="[~=] attribute selector looking for empty string in empty attribute"></div>
1079 <div class="blox10 unitTest" foo="foobar" title="[~=] attribute selector looking for 'foo' in 'foobar'"></div>
1080 </div>
1081
1082 <div class="test attrStart">
1083 <div class="unitTest t1" title="[^=] attribute selector"></div>
1084 <div class="unitTest t2" title="[^=] attribute selector"></div>
1085 <div class="unitTest t3" align="center" title="[^=] attribute selector looking for empty string"></div>
1086 <div class="unitTest t4" foo="&eacute;tagada" title="[^=] attribute selector looking for &eacute;"></div>
1087 </div>
1088
1089 <div class="test attrEnd">
1090 <div class="unitTest t1" title="[$=] attribute selector"></div>
1091 <div class="unitTest t2" title="[$=] attribute selector"></div>
1092 <div class="unitTest t3" align="center" title="[$=] attribute selector looking for empty string"></div>
1093 <div class="unitTest t4" foo="tagada&eacute;" title="[$=] attribute selector looking for &eacute;"></div>
1094 </div>
1095
1096 <div class="test attrMiddle">
1097 <div class="unitTest t1" title="[*=] attribute selector"></div>
1098 <div class="unitTest t2" title="[*=] attribute selector"></div>
1099 <div class="unitTest t3" align="center" title="[*=] attribute selector looking for empty string"></div>
1100 <div class="unitTest t4" foo="tagada&eacute;foo" title="[*=] attribute selector looking for &eacute;"></div>
1101 </div>
1102
1103 <div class="test firstChild">
1104 <div class="unitTest" title=":first-child selector"></div>
1105 <div class="blox12 unitTest" title=":first-child selector should not match non first child"></div>
1106 <div class="blox13 unitTest" title=":first-child selector should not match non first child"></div>
1107 </div>
1108
1109 <div class="test not">
1110 <div class="blox14 unitTest" title="negation pseudo-class with argument being an element type selector"></div>
1111 <div class="blox15 unitTest" foo="blox15" title="negation pseudo-class with argument being an attribute selector"></div>
1112 <div class="blox16 unitTest" foo="blox15" title="negation pseudo-class accepts only simple selectors for argument"></div>
1113 </div>
1114
1115 <div class="test onlyOfType">
1116 <div class="blox17 unitTest" title=":only-of-type selector"></div>
1117 <p class="blox18 unitTest" title="negated :only-of-type selector"></p>
1118 <p class="blox18 unitTest" title="negated :only-of-type selector"></p>
1119 </div>
1120
1121 <div class="test nthchild1">
1122 <div class="unitTest" title=":nth-child(odd) selector"></div>
1123 <div class="unitTest" title=":nth-last-child(odd) selector"></div>
1124 <div class="unitTest" title=":nth-child(odd) selector"></div>
1125 <div class="unitTest" title=":nth-last-child(odd) selector"></div>
1126 <div class="unitTest" title=":nth-child(odd) selector"></div>
1127 <div class="unitTest" title=":nth-last-child(odd) selector"></div>
1128 </div>
1129 <div class="test nthchild2">
1130 <div class="unitTest" title=":nth-last-child(even) selector"></div>
1131 <div class="unitTest" title=":nth-child(even) selector"></div>
1132 <div class="unitTest" title=":nth-last-child(even) selector"></div>
1133 <div class="unitTest" title=":nth-child(even) selector"></div>
1134 <div class="unitTest" title=":nth-last-child(even) selector"></div>
1135 <div class="unitTest" title=":nth-child(even) selector"></div>
1136 </div>
1137 <div class="test nthchild3">
1138 <div class="unitTest no" title=":nth-last-child(3n+3) selector"></div>
1139 <div class="unitTest" title=":nth-child(3n+2) selector"></div>
1140 <div class="unitTest no" title=":nth-last-child(3n+1) selector"></div>
1141 <div class="unitTest no" title=":nth-last-child(3n+3) selector"></div>
1142 <div class="unitTest" title=":nth-child(3n+2) selector"></div>
1143 <div class="unitTest no" title=":nth-last-child(3n+1) selector"></div>
1144 </div>
1145
1146 <div class="test nthoftype1">
1147 <div class="unitTest" title=":nth-of-type(odd) selector"></div>
1148 <p class="unitTest" title=":nth-of-* selector"></p>
1149 <p class="unitTest" title=":nth-of-* selector"></p>
1150 <div class="unitTest" title=":nth-last-of-type(odd) selector"></div>
1151 <p class="unitTest" title=":nth-of-* selector"></p>
1152 <div class="unitTest" title=":nth-of-type(odd) selector"></div>
1153 <div class="unitTest" title=":nth-last-of-type(odd) selector"></div>
1154 </div>
1155 <div class="test nthoftype2">
1156 <div class="unitTest" title=":nth-last-of-type(even) selector"></div>
1157 <p class="unitTest" title=":nth-of-* selector"></p>
1158 <p class="unitTest" title=":nth-of-* selector"></p>
1159 <div class="unitTest" title=":nth-of-type(even) selector"></div>
1160 <p class="unitTest" title=":nth-of-* selector"></p>
1161 <div class="unitTest" title=":nth-last-of-type(even) selector"></div>
1162 <div class="unitTest" title=":nth-of-type(even) selector"></div>
1163 </div>
1164 <div class="test nthoftype3">
1165 <div class="unitTest" title=":nth-of-type(3n+1) selector"></div>
1166 <p class="unitTest" title=":nth-of-* selector"></p>
1167 <p class="unitTest" title=":nth-of-* selector"></p>
1168 <div class="unitTest" title=":nth-last-of-type(3n+2) selector"></div>
1169 <p class="unitTest" title=":nth-of-* selector"></p>
1170 <div class="unitTest" title=":nth-last-of-type(3n+1) selector"></div>
1171 <div class="unitTest" title=":nth-of-type(3n+1) selector"></div>
1172 <p class="unitTest" title=":nth-of-* selector"></p>
1173 <div class="unitTest" title=":nth-last-of-type(3n+2) selector"></div>
1174 <div class="unitTest" title=":nth-last-of-type(3n+1) selector"></div>
1175 </div>
1176
1177 <div class="test lastChild">
1178 <p class="unitTest" title=":not(:last-child) selector"></p>
1179 <div class="unitTest" title=":last-child selector"></div>&nbsp;
1180 </div>
1181
1182 <div class="test firstOfType">
1183 <p class="unitTest" title=":first-of-type selector"></p>
1184 <div class="unitTest" title=":first-of-type selector"></div>
1185 <p class="unitTest" title=":not(:first-of-type)"></p>
1186 <div class="unitTest" title=":not(:first-of-type)"></div>
1187 </div>
1188
1189 <div class="test lastOfType">
1190 <p class="unitTest" title=":not(:last-of-type)"></p>
1191 <div class="unitTest" title=":not(:last-of-type)"></div>
1192 <p class="unitTest" title=":last-of-type selector"></p>
1193 <div class="unitTest" title=":last-of-type selector"></div>
1194 </div>
1195
1196 <div class="test onlyChild">
1197 <div class="unitTest" title=":only-child where the element is NOT the only child"></div>
1198 <div class="unitTest" title=":only-child where the element is the only child">
1199 <div class="unitTest" title=":only-child where the element is the only child"></div>
1200 </div>
1201 </div>
1202
1203 <div class="test onlyOfType">
1204 <p class="unitTest" title=":only-of-type"></p>
1205 <div class="unitTest" title=":only-of-type">
1206 <div class="unitTest" title=":only-of-type"></div>
1207 </div>
1208 <div class="unitTest" title=":not(only-of-type)"></div>
1209 </div>
1210
1211 <div class="test empty">
1212 <div class="unitTest isEmpty" title=":empty with empty element"></div>
1213 <div class="unitTest isNotEmpty" title=":empty but element contains a whitespace"> </div>
1214 <div class="unitTest isEmpty" title=":empty and element contains an SGML comment"><!-- foo --></div>
1215 <div class="unitTest isNotEmpty" title=":empty but element contains a SPAN element"><span></span></div>
1216 <div class="unitTest isNotEmpty" title=":empty but element contains an entity reference">&nbsp;</div>
1217 </div>
1218
1219 <div class="test lang">
1220 <div id="nofragment" class="unitTest" title=":lang() where language comes from the document"></div>
1221 <div class="unitTest" lang="fr" title=":lang() where language comes from the element"></div>
1222 <div class="unitTest" lang="en-US" title=":lang() where language comes from the element but is a dialect of the language queried"></div>
1223 <div class="unitTest t1" lang="es" title=":lang() where language comes from the element but the language queried is a dialect of the element's one so it should not match"></div>
1224 </div>
1225
1226 <div class="test attrLang">
1227 <div class="unitTest t1" title="[|=] where language comes from the document"></div>
1228 <div class="unitTest" lang="fr" title="[|=] where language comes from the element"></div>
1229 <div class="unitTest t2" lang="en-US" title="[|=] where language comes from the element but is a dialect of the language queried"></div>
1230 <div class="unitTest t3" lang="es" title="[|=] where language comes from the element but the language queried is a dialect of the element's one so it should not match"></div>
1231 </div>
1232
1233 <div class="test UI">
1234 <button name="submit" type="submit" value="submit" class="t1" title=":enabled pseudo-class"><div class="unitTest"></div></button>
1235 <button name="submit" type="submit" value="submit" class="t2" disabled="true" title=":enabled pseudo-class"><div class="unitTest"></div></button>
1236 </div>
1237 <div class="test UI">
1238 <input class="t3" type="checkbox" checked="true"/><div class="unitTest" title=":checked"></div>
1239 the previous square should be green when the checkbox is checked and become red when you uncheck it
1240 </div>
1241 <div class="test UI">
1242 <input class="t4" type="checkbox"/><div class="unitTest" title=":not(:checked)"></div>
1243 the previous square should be green when the checkbox is NOT checked and become red when you check it
1244 </div>
1245
1246 <div class="test tilda">
1247 <div class="unitTest t1" title="~ combinator"></div>
1248 <div class="unitTest" title="~ combinator"></div>
1249 <div class="unitTest" title="~ combinator"></div>
1250 <div class="unitTest" title="~ combinator"></div>
1251 <span style="float:left">the three last squares should be green and become red when the pointer hovers over the white square</span>
1252 </div>
1253 <div class="test plus">
1254 <div class="unitTest t1" title="+ combinator"></div>
1255 <div class="unitTest t2" title="+ combinator"></div>
1256 <div class="unitTest" title="+ combinator"></div>
1257 <span style="float:left">the last square should be green and become red when the pointer hovers over the FIRST white square</span>
1258 </div>
1259 </div>
1260 <div id="root3">
1261 <div id="svgs">
1262 <!-- svg elements, but in the xhtml namespace -->
1263 <svg width="12cm" height="4cm" viewBox="0 0 1200 400" version="1.1" id="svg1">
1264 <desc id="desc1">Example circle01 - circle filled with red and stroked with blue</desc>
1265 <rect id="rect1" x="1" y="1" width="1198" height="398" fill="none" stroke="blue" stroke-width="2"/>
1266 <circle id="circle1" cx="600" cy="200" r="100" fill="red" stroke="blue" stroke-width="10" />
1267 </svg>
1268 <!-- svg elements using svg: -->
1269 <svg:svg width="12cm" height="4cm" viewBox="0 0 1200 400" version="1.1" id="svg2">
1270 <svg:desc id="desc2">Example circle01 - circle filled with red and stroked with blue</svg:desc>
1271 <svg:rect id="rect2" x="1" y="1" width="1198" height="398" fill="none" stroke="blue" stroke-width="2"/>
1272 <svg:circle id="circle2" cx="600" cy="200" r="100" fill="red" stroke="blue" stroke-width="10" />
1273 </svg:svg>
1274 <!-- svg using an inline xmlns -->
1275 <svg width="12cm" height="4cm" viewBox="0 0 1200 400" xmlns="http://www.w3.org/2000/svg" version="1.1" id="svg3">
1276 <desc id="desc3">Example circle01 - circle filled with red and stroked with blue</desc>
1277 <rect id="rect3" x="1" y="1" width="1198" height="398" fill="none" stroke="blue" stroke-width="2"/>
1278 <circle id="circle3" cx="600" cy="200" r="100" fill="red" stroke="blue" stroke-width="10" />
1279 </svg>
1280 </div>
1281
1282 <h1 id="header">jQuery Test Suite</h1>
1283 <h2 id="banner"></h2>
1284 <h2 id="userAgent"></h2>
1285
1286 <!-- Test HTML -->
1287 <div id="nothiddendiv" style="height:1px;background:white;">
1288
1289 <div id="nothiddendivchild"></div>
1290 </div>
1291 <!-- Test for scoping -->
1292 <nosuchtag id="outerbogustag">
1293 <nosuchtag id="innerbogustag"></nosuchtag>
1294 </nosuchtag>
1295 <!-- this iframe is outside the #main so it won't reload constantly wasting time, but it means the tests must be "safe" and clean up after themselves -->
1296 <iframe id="loadediframe" name="loadediframe" style="display:none;" src="data/iframe.html"></iframe>
1297 <dl id="dl" style="display:none;">
1298 <div id="main" style="display: none;">
1299 <p id="firstp">See <a id="simon1" href="http://simon.incutio.com/archive/2003/03/25/#getElementsBySelector" rel="bookmark">this blog entry</a> for more information.</p>
1300
1301 <p id="ap">
1302 Here are some links in a normal paragraph: <a id="google" href="http://www.google.com/" title="Google!">Google</a>,
1303 <a id="groups" href="http://groups.google.com/">Google Groups</a>.
1304 This link has <code><a href="http://smin" id="anchor1">class="blog"</a></code>:
1305 <a href="http://diveintomark.org/" class="blog" hreflang="en" id="mark">diveintomark</a>
1306
1307 </p>
1308 <div id="foo">
1309
1310 <p id="sndp">Everything inside the red border is inside a div with <code>id="foo"</code>.</p>
1311 <p lang="en" id="en">This is a normal link: <a id="yahoo" href="http://www.yahoo.com/" class="blogTest">Yahoo</a></p>
1312 <p id="sap">This link has <code><a href="#2" id="anchor2">class="blog"</a></code>: <a href="http://simon.incutio.com/" class="blog link" id="simon">Simon Willison's Weblog</a></p>
1313
1314 </div>
1315
1316 <p id="first">Try them out:</p>
1317 <ul id="firstUL"></ul>
1318 <ol id="empty"></ol>
1319 <form id="form" action="formaction">
1320 <input type="text" name="action" value="Test" id="text1" maxlength="30"/>
1321 <input type="text" name="text2" value="Test" id="text2" disabled="disabled"/>
1322 <input type="radio" name="radio1" id="radio1" value="on"/>
1323
1324 <input type="radio" name="radio2" id="radio2" checked="checked"/>
1325
1326 <input type="checkbox" name="check" id="check1" checked="checked"/>
1327 <input type="checkbox" id="check2" value="on"/>
1328
1329 <input type="hidden" name="hidden" id="hidden1"/>
1330 <input type="text" style="display:none;" name="foo[bar]" id="hidden2"/>
1331
1332 <input type="text" id="name" name="name" value="name" />
1333
1334 <button id="button" name="button">Button</button>
1335
1336 <textarea id="area1" maxlength="30">foobar</textarea>
1337
1338
1339 <select name="select1" id="select1">
1340 <option id="option1a" class="emptyopt" value="">Nothing</option>
1341 <option id="option1b" value="1">1</option>
1342 <option id="option1c" value="2">2</option>
1343 <option id="option1d" value="3">3</option>
1344 </select>
1345 <select name="select2" id="select2">
1346
1347 <option id="option2a" class="emptyopt" value="">Nothing</option>
1348 <option id="option2b" value="1">1</option>
1349 <option id="option2c" value="2">2</option>
1350 <option id="option2d" selected="selected" value="3">3</option>
1351 </select>
1352 <select name="select3" id="select3" multiple="multiple">
1353 <option id="option3a" class="emptyopt" value="">Nothing</option>
1354
1355 <option id="option3b" selected="selected" value="1">1</option>
1356 <option id="option3c" selected="selected" value="2">2</option>
1357 <option id="option3d" value="3">3</option>
1358 </select>
1359
1360 <object id="object1" codebase="stupid">
1361 <param name="p1" value="x1" />
1362 <param name="p2" value="x2" />
1363
1364 </object>
1365
1366 <span id="台北Táiběi"></span>
1367 <span id="台北" lang="中文"></span>
1368 <span id="utf8class1" class="台北Táiběi 台北"></span>
1369 <span id="utf8class2" class="台北"></span>
1370 <span id="foo:bar" class="foo:bar"></span>
1371 <span id="test.foo[5]bar" class="test.foo[5]bar"></span>
1372
1373 <foo_bar id="foobar">test element</foo_bar>
1374
1375 </form>
1376 <b id="floatTest">Float test.</b>
1377 <iframe id="iframe" name="iframe"></iframe>
1378 <form id="lengthtest">
1379 <input type="text" id="length" name="test"/>
1380 <input type="text" id="idTest" name="id"/>
1381 </form>
1382 <table id="table"></table>
1383
1384
1385 <div id="fx-queue">
1386 <div id="fadein" class='chain test'>fadeIn<div>fadeIn</div></div>
1387 <div id="fadeout" class='chain test out'>fadeOut<div>fadeOut</div></div>
1388
1389 <div id="show" class='chain test'>show<div>show</div></div>
1390 <div id="hide" class='chain test out'>hide<div>hide</div></div>
1391
1392
1393 <div id="togglein" class='chain test'>togglein<div>togglein</div></div>
1394 <div id="toggleout" class='chain test out'>toggleout<div>toggleout</div></div>
1395
1396
1397 <div id="slideup" class='chain test'>slideUp<div>slideUp</div></div>
1398 <div id="slidedown" class='chain test out'>slideDown<div>slideDown</div></div>
1399
1400 <div id="slidetogglein" class='chain test'>slideToggleIn<div>slideToggleIn</div></div>
1401
1402 <div id="slidetoggleout" class='chain test out'>slideToggleOut<div>slideToggleOut</div></div>
1403 </div>
1404
1405 <div id="fx-tests"></div>
1406
1407 <form id="testForm" action="#" method="get">
1408 <textarea name="T3" rows="2" cols="15">?
1409 Z</textarea>
1410 <input type="hidden" name="H1" value="x" />
1411 <input type="hidden" name="H2" />
1412
1413 <input name="PWD" type="password" value="" />
1414 <input name="T1" type="text" />
1415 <input name="T2" type="text" value="YES" readonly="readonly" />
1416 <input type="checkbox" name="C1" value="1" />
1417 <input type="checkbox" name="C2" />
1418 <input type="radio" name="R1" value="1" />
1419 <input type="radio" name="R1" value="2" />
1420 <input type="text" name="My Name" value="me" />
1421 <input type="reset" name="reset" value="NO" />
1422
1423 <select name="S1">
1424 <option value="abc">ABC</option>
1425 <option value="abc">ABC</option>
1426 <option value="abc">ABC</option>
1427 </select>
1428 <select name="S2" multiple="multiple" size="3">
1429 <option value="abc">ABC</option>
1430
1431 <option value="abc">ABC</option>
1432 <option value="abc">ABC</option>
1433 </select>
1434 <select name="S3">
1435 <option selected="selected">YES</option>
1436 </select>
1437 <select name="S4">
1438
1439 <option value="" selected="selected">NO</option>
1440 </select>
1441 <input type="submit" name="sub1" value="NO" />
1442 <input type="submit" name="sub2" value="NO" />
1443 <input type="image" name="sub3" value="NO" />
1444 <button name="sub4" type="submit" value="NO">NO</button>
1445 <input name="D1" type="text" value="NO" disabled="disabled" />
1446 <input type="checkbox" checked="checked" disabled="disabled" name="D2" value="NO" />
1447
1448 <input type="radio" name="D3" value="NO" checked="checked" disabled="disabled" />
1449 <select name="D4" disabled="disabled">
1450 <option selected="selected" value="NO">NO</option>
1451 </select>
1452 </form>
1453 <div id="moretests">
1454 <form>
1455 <div id="checkedtest" style="display:none;">
1456
1457 <input type="radio" name="checkedtestradios" checked="checked"/>
1458 <input type="radio" name="checkedtestradios" value="on"/>
1459 <input type="checkbox" name="checkedtestcheckboxes" checked="checked"/>
1460 <input type="checkbox" name="checkedtestcheckboxes" />
1461 </div>
1462 </form>
1463 <div id="nonnodes"><span>hi</span> there <!-- mon ami --></div>
1464
1465 <div id="t2037">
1466 <div><div class="hidden">hidden</div></div>
1467 </div>
1468 </div>
1469 </div>
1470 </dl>
1471
1472 <ol id="tests"></ol>
1473 </div>
1474 <ol id="results"></ol>
1475 </body>
1476 </html>

mercurial