Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / dom / shadow / content-selector-query.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <p>This test checks select attribute of content element is valid.</p>
8 <pre id="console"></pre>
9 <div id="container"></div>
10
11 <script>
12 var container = document.getElementById("container");
13
14 var content;
15 function test(select, valid) {
16     content = document.createElement('content');
17     if (select != null)
18         content.setAttribute('select', select);
19
20     debug(select);
21     if (valid)
22         shouldBe("internals.isValidContentSelect(content)", "true");
23     else
24         shouldBe("internals.isValidContentSelect(content)", "false");
25 }
26
27 var dataOfValidCases = [
28     null, '',
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     ',
37     'div:not(div)',
38 ];
39
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)',
55 ];
56
57 var dataOfValidCasesIfPseudoClassIsAllowed = [
58     null, '',
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     ',
73     'div:not(div)',
74 ];
75
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 \'\''
85 ]
86
87 function doTest() {
88     if (!window.testRunner || !window.internals) {
89         return;
90     }
91
92     testRunner.dumpAsText();
93
94     if (window.internals) {
95         internals.settings.setPseudoClassesInMatchingCriteriaInAuthorShadowTreesEnabled(false);
96     }
97     for (var i = 0; i < dataOfValidCases.length; ++i) {
98         test(dataOfValidCases[i], true);
99     }
100     for (var i = 0; i < dataOfInvalidCases.length; ++i) {
101         test(dataOfInvalidCases[i], false);
102     }
103
104     if (window.internals) {
105         internals.settings.setPseudoClassesInMatchingCriteriaInAuthorShadowTreesEnabled(true);
106     }
107     for (var i = 0; i < dataOfValidCasesIfPseudoClassIsAllowed.length; ++i) {
108         test(dataOfValidCases[i], true);
109     }
110     for (var i = 0; i < dataOfInvalidCasesIfPseudoClassIsAllowed.length; ++i) {
111         test(dataOfInvalidCases[i], false);
112     }
113 }
114
115 doTest();
116 var successfullyParsed = true;
117 </script>
118 </body>
119 </html>