| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../../resources/testharness.js"></script> |
| <script src="../../../resources/testharnessreport.js"></script> |
| </head> |
| <body> |
| <p>This test checks select attribute of content element is valid.</p> |
| <pre id="console"></pre> |
| <div id="container"></div> |
| |
| <script> |
| var container = document.getElementById("container"); |
| |
| var content; |
| function runTest(select, valid) { |
| content = document.createElement('content'); |
| if (select != null) |
| content.setAttribute('select', select); |
| |
| test(() => { |
| assert_own_property(window, 'internals', |
| 'This test requires internals.isValidContentSelect'); |
| assert_equals(internals.isValidContentSelect(content), valid); |
| }, `${select} ${valid}`); |
| } |
| |
| var dataOfValidCases = [ |
| null, '', '*|div', '|div', 'div', '*|*', '|*', '*', |
| '.elem', 'p.elem', 'foo.elem', '*.right', |
| '#elem', 'p#elem', 'foo#elem', '*#something', |
| 'div[title]', 'div[class="example"]', 'div[hello="Cleveland"][goodbye="Columbus"]', |
| 'div[rel~="copyright"]', 'div[href="http://www.example.com/"]', |
| 'div[hreflang|="en"]', 'div[character=romeo]', |
| 'div, div', ' div, div ', |
| 'div:not(div)', |
| ]; |
| |
| var dataOfInvalidCases = [ |
| 'div div', 'div > div', 'div + div', 'div ~ div', |
| 'ns|div', 'ns|*', 'div:root', 'div:lang(en)', |
| 'div::before', 'div::after', 'div::first-line', 'div::first-letter', |
| 'div:active', 'div:hover', 'div:focus', |
| 'div div:not(div)', 'div:not(div) div', 'div span div', |
| 'div < div', 'div - dvi', '< div', '+div', '~div', 'div:!', '!:!', 'div::!', 'div::first_of_type', |
| 'pe;ro', '@screen', '@import "style.css"', 'div :first-of-type', 'div::first-of-type', |
| ' div, ,div', 'div \'\'', |
| 'div:link', 'div:visited', 'div:target', 'div:enabled', 'div:checked', |
| 'div:indeterminate', 'div:nth-child(1)', 'div:nth-last-child(1)', 'div:nth-of-type(1)', |
| 'div:nth-last-of-type(1)', 'div:first-child', 'div:last-child', 'div:first-of-type', |
| 'div:last-of-type', 'div:only-of-type', |
| 'div:first-of-type:last-of-type', 'div.elem:visited', '*:visited', |
| '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)', |
| ]; |
| |
| function doTest() { |
| for (var i = 0; i < dataOfValidCases.length; ++i) { |
| runTest(dataOfValidCases[i], true); |
| } |
| for (var i = 0; i < dataOfInvalidCases.length; ++i) { |
| runTest(dataOfInvalidCases[i], false); |
| } |
| } |
| |
| doTest(); |
| </script> |
| </body> |
| </html> |