4 <script src="../../../resources/js-test.js"></script>
7 <p>This test checks select attribute of content element is valid.</p>
8 <pre id="console"></pre>
9 <div id="container"></div>
12 var container = document.getElementById("container");
15 function test(select, valid) {
16 content = document.createElement('content');
18 content.setAttribute('select', select);
22 shouldBe("internals.isValidContentSelect(content)", "true");
24 shouldBe("internals.isValidContentSelect(content)", "false");
27 var dataOfValidCases = [
29 'ns|div', '*|div', '|div', 'div',
30 'ns|*', '*|*', '|*', '*',
31 '.elem', 'p.elem', 'foo.elem', '*.right',
32 '#elem', 'p#elem', 'foo#elem', '*#something',
33 'div[title]', 'div[class="example"]', 'div[hello="Cleveland"][goodbye="Columbus"]',
34 'div[rel~="copyright"]', 'div[href="http://www.example.com/"]',
35 'div[hreflang|="en"]', 'div[character=romeo]',
36 'div, div', ' div, div ',
40 var dataOfInvalidCases = [
41 'div div', 'div > div', 'div + div', 'div ~ div',
42 'div:root', 'div:lang(en)',
43 'div::before', 'div::after', 'div::first-line', 'div::first-letter',
44 'div:active', 'div:hover', 'div:focus',
45 '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',
47 'pe;ro', '@screen', '@import "style.css"', 'div :first-of-type', 'div::first-of-type',
48 ' div, ,div', 'div \'\'',
49 'div:link', 'div:visited', 'div:target', 'div:enabled', 'div:checked',
50 'div:indeterminate', 'div:nth-child(1)', 'div:nth-last-child(1)', 'div:nth-of-type(1)',
51 'div:nth-last-of-type(1)', 'div:first-child', 'div:last-child', 'div:first-of-type',
52 'div:last-of-type', 'div:only-of-type',
53 'div:first-of-type:last-of-type', 'div.elem:visited', '*:visited',
54 'div:first-of-type, div', 'div, div:first-of-type', 'div:first-of-type, div:last-of-type', 'div:not(:not(div))', 'div:not(:hover)', 'div:not(div div)', 'div:not(div div:not)', 'div:not(div div:hover)', 'div div:not(:hover)',
57 var dataOfValidCasesIfPseudoClassIsAllowed = [
59 'ns|div', '*|div', '|div', 'div',
60 'ns|*', '*|*', '|*', '*',
61 '.elem', 'p.elem', 'foo.elem', '*.right',
62 '#elem', 'p#elem', 'foo#elem', '*#something',
63 'div[title]', 'div[class="example"]', 'div[hello="Cleveland"][goodbye="Columbus"]',
64 'div[rel~="copyright"]', 'div[href="http://www.example.com/"]',
65 'div[hreflang|="en"]', 'div[character=romeo]',
66 'div:link', 'div:visited', 'div:target', 'div:enabled', 'div:checked',
67 'div:indeterminate', 'div:nth-child(1)', 'div:nth-last-child(1)', 'div:nth-of-type(1)',
68 'div:nth-last-of-type(1)', 'div:first-child', 'div:last-child', 'div:first-of-type',
69 'div:last-of-type', 'div:only-of-type',
70 'div:first-of-type:last-of-type', 'div.elem:visited', '*:visited',
71 'div:first-of-type, div', 'div, div:first-of-type', 'div:first-of-type, div:last-of-type',
72 'div, div', ' div, div ',
76 var dataOfInvalidCasesIfPseudoClassIsAllowed = [
77 'div div', 'div > div', 'div + div', 'div ~ div',
78 'div:root', 'div:lang(en)',
79 'div::before', 'div::after', 'div::first-line', 'div::first-letter',
80 'div:active', 'div:hover', 'div:focus',
81 'div div:not(div)', 'div:not(div) div', 'div span div',
82 'div < div', 'div - dvi', '< div', '+div', '~div', 'div:!', '!:!', 'div::!', 'div::first_of_type',
83 'pe;ro', '@screen', '@import "style.css"', 'div :first-of-type', 'div::first-of-type',
84 ' div, ,div', 'div \'\''
88 if (!window.testRunner || !window.internals) {
92 testRunner.dumpAsText();
94 if (window.internals) {
95 internals.settings.setPseudoClassesInMatchingCriteriaInAuthorShadowTreesEnabled(false);
97 for (var i = 0; i < dataOfValidCases.length; ++i) {
98 test(dataOfValidCases[i], true);
100 for (var i = 0; i < dataOfInvalidCases.length; ++i) {
101 test(dataOfInvalidCases[i], false);
104 if (window.internals) {
105 internals.settings.setPseudoClassesInMatchingCriteriaInAuthorShadowTreesEnabled(true);
107 for (var i = 0; i < dataOfValidCasesIfPseudoClassIsAllowed.length; ++i) {
108 test(dataOfValidCases[i], true);
110 for (var i = 0; i < dataOfInvalidCasesIfPseudoClassIsAllowed.length; ++i) {
111 test(dataOfInvalidCases[i], false);
116 var successfullyParsed = true;