OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../../../resources/js-test.js"></script> | 4 <script src="../../../resources/js-test.js"></script> |
5 </head> | 5 </head> |
6 <body> | 6 <body> |
7 <p>This test checks select attribute of content element is valid.</p> | 7 <p>This test checks select attribute of content element is valid.</p> |
8 <pre id="console"></pre> | 8 <pre id="console"></pre> |
9 <div id="container"></div> | 9 <div id="container"></div> |
10 | 10 |
11 <script> | 11 <script> |
12 var container = document.getElementById("container"); | 12 var container = document.getElementById("container"); |
13 | 13 |
14 var content; | 14 var content; |
15 function test(select, valid) { | 15 function test(select, valid) { |
16 content = document.createElement('content'); | 16 content = document.createElement('content'); |
17 if (select != null) | 17 if (select != null) |
18 content.setAttribute('select', select); | 18 content.setAttribute('select', select); |
19 | 19 |
20 debug(select); | 20 debug(select); |
21 if (valid) | 21 if (valid) |
22 shouldBe("internals.isValidContentSelect(content)", "true"); | 22 shouldBe("internals.isValidContentSelect(content)", "true"); |
23 else | 23 else |
24 shouldBe("internals.isValidContentSelect(content)", "false"); | 24 shouldBe("internals.isValidContentSelect(content)", "false"); |
25 } | 25 } |
26 | 26 |
27 var dataOfValidCases = [ | 27 var dataOfValidCases = [ |
28 null, '', | 28 null, '', '*|div', '|div', 'div', '*|*', '|*', '*', |
29 'ns|div', '*|div', '|div', 'div', | |
30 'ns|*', '*|*', '|*', '*', | |
31 '.elem', 'p.elem', 'foo.elem', '*.right', | 29 '.elem', 'p.elem', 'foo.elem', '*.right', |
32 '#elem', 'p#elem', 'foo#elem', '*#something', | 30 '#elem', 'p#elem', 'foo#elem', '*#something', |
33 'div[title]', 'div[class="example"]', 'div[hello="Cleveland"][goodbye="Colum
bus"]', | 31 'div[title]', 'div[class="example"]', 'div[hello="Cleveland"][goodbye="Colum
bus"]', |
34 'div[rel~="copyright"]', 'div[href="http://www.example.com/"]', | 32 'div[rel~="copyright"]', 'div[href="http://www.example.com/"]', |
35 'div[hreflang|="en"]', 'div[character=romeo]', | 33 'div[hreflang|="en"]', 'div[character=romeo]', |
36 'div, div', ' div, div ', | 34 'div, div', ' div, div ', |
37 'div:not(div)', | 35 'div:not(div)', |
38 ]; | 36 ]; |
39 | 37 |
40 var dataOfInvalidCases = [ | 38 var dataOfInvalidCases = [ |
41 'div div', 'div > div', 'div + div', 'div ~ div', | 39 'div div', 'div > div', 'div + div', 'div ~ div', |
42 'div:root', 'div:lang(en)', | 40 'ns|div', 'ns|*', 'div:root', 'div:lang(en)', |
43 'div::before', 'div::after', 'div::first-line', 'div::first-letter', | 41 'div::before', 'div::after', 'div::first-line', 'div::first-letter', |
44 'div:active', 'div:hover', 'div:focus', | 42 'div:active', 'div:hover', 'div:focus', |
45 'div div:not(div)', 'div:not(div) div', 'div span div', | 43 'div div:not(div)', 'div:not(div) div', 'div span div', |
46 'div < div', 'div - dvi', '< div', '+div', '~div', 'div:!', '!:!', 'div::!',
'div::first_of_type', | 44 'div < div', 'div - dvi', '< div', '+div', '~div', 'div:!', '!:!', 'div::!',
'div::first_of_type', |
47 'pe;ro', '@screen', '@import "style.css"', 'div :first-of-type', 'div::first
-of-type', | 45 'pe;ro', '@screen', '@import "style.css"', 'div :first-of-type', 'div::first
-of-type', |
48 ' div, ,div', 'div \'\'', | 46 ' div, ,div', 'div \'\'', |
49 'div:link', 'div:visited', 'div:target', 'div:enabled', 'div:checked', | 47 'div:link', 'div:visited', 'div:target', 'div:enabled', 'div:checked', |
50 'div:indeterminate', 'div:nth-child(1)', 'div:nth-last-child(1)', 'div:nth-o
f-type(1)', | 48 'div:indeterminate', 'div:nth-child(1)', 'div:nth-last-child(1)', 'div:nth-o
f-type(1)', |
51 'div:nth-last-of-type(1)', 'div:first-child', 'div:last-child', 'div:first-o
f-type', | 49 'div:nth-last-of-type(1)', 'div:first-child', 'div:last-child', 'div:first-o
f-type', |
52 'div:last-of-type', 'div:only-of-type', | 50 'div:last-of-type', 'div:only-of-type', |
(...skipping 11 matching lines...) Expand all Loading... |
64 for (var i = 0; i < dataOfInvalidCases.length; ++i) { | 62 for (var i = 0; i < dataOfInvalidCases.length; ++i) { |
65 test(dataOfInvalidCases[i], false); | 63 test(dataOfInvalidCases[i], false); |
66 } | 64 } |
67 } | 65 } |
68 | 66 |
69 doTest(); | 67 doTest(); |
70 var successfullyParsed = true; | 68 var successfullyParsed = true; |
71 </script> | 69 </script> |
72 </body> | 70 </body> |
73 </html> | 71 </html> |
OLD | NEW |