tizen beta release
[framework/web/webkit-efl.git] / LayoutTests / fast / css / css-selector-text.html
1 <html>
2 <head id="head">
3 <script src="../js/resources/js-test-pre.js"></script>
4 </head>
5 <body>
6 <script>
7
8 description("This tests parsing and re-serialization of some CSS selectors.");
9
10 function parseThenSerializeRule(rule)
11 {
12     var styleElement = document.getElementById("style");
13     var head = document.getElementById("head");
14     if (styleElement)
15         head.removeChild(styleElement);
16
17     styleElement = document.createElement("style");
18     styleElement.id = "style";
19     var head = document.getElementById("head");
20     head.appendChild(styleElement);
21     
22     styleElement.appendChild(document.createTextNode(rule));
23     return styleElement.sheet.cssRules[0].cssText;
24 }
25
26 function testSelectorRoundTrip(selector)
27 {
28     shouldBe("parseThenSerializeRule('" + selector + " { }')", "'" + selector + " { }'");
29 }
30
31 testSelectorRoundTrip('*');
32 testSelectorRoundTrip('a');
33 testSelectorRoundTrip('#a');
34 testSelectorRoundTrip('.a');
35 testSelectorRoundTrip(':active');
36 testSelectorRoundTrip('[a]');
37 testSelectorRoundTrip('[a="b"]');
38 testSelectorRoundTrip('[a~="b"]');
39 testSelectorRoundTrip('[a|="b"]');
40 testSelectorRoundTrip('[a^="b"]');
41 testSelectorRoundTrip('[a$="b"]');
42 testSelectorRoundTrip('[a*="b"]');
43
44 debug('');
45
46 testSelectorRoundTrip('*|a');
47 testSelectorRoundTrip('n|a');
48 testSelectorRoundTrip('*|*');
49 testSelectorRoundTrip('n|*');
50 testSelectorRoundTrip('[*|a]');
51 testSelectorRoundTrip('[n|a]');
52
53 debug('');
54
55 testSelectorRoundTrip('a:active');
56 testSelectorRoundTrip('a b');
57 testSelectorRoundTrip('a + b');
58 testSelectorRoundTrip('a ~ b');
59 testSelectorRoundTrip('a > b');
60
61 debug('');
62
63 testSelectorRoundTrip(":active");
64 testSelectorRoundTrip(":checked");
65 testSelectorRoundTrip(":disabled");
66 testSelectorRoundTrip(":empty");
67 testSelectorRoundTrip(":enabled");
68 testSelectorRoundTrip(":first-child");
69 testSelectorRoundTrip(":first-of-type");
70 testSelectorRoundTrip(":focus");
71 testSelectorRoundTrip(":hover");
72 testSelectorRoundTrip(":indeterminate");
73 testSelectorRoundTrip(":link");
74 testSelectorRoundTrip(":root");
75 testSelectorRoundTrip(":target");
76 testSelectorRoundTrip(":visited");
77
78 debug('');
79
80 testSelectorRoundTrip(":lang(a)");
81 testSelectorRoundTrip(":not(a)");
82 testSelectorRoundTrip(":-webkit-any(a,b,p)");
83
84 debug('');
85
86 testSelectorRoundTrip("::after");
87 testSelectorRoundTrip("::before");
88 testSelectorRoundTrip("::first-letter");
89 testSelectorRoundTrip("::first-line");
90 testSelectorRoundTrip("::selection");
91
92 debug('');
93
94 testSelectorRoundTrip(":-webkit-any-link");
95 testSelectorRoundTrip(":-webkit-autofill");
96 testSelectorRoundTrip(":-webkit-drag");
97
98 debug('');
99
100 testSelectorRoundTrip("::-webkit-file-upload-button");
101 testSelectorRoundTrip("::-webkit-search-cancel-button");
102 testSelectorRoundTrip("::-webkit-search-decoration");
103 testSelectorRoundTrip("::-webkit-search-results-button");
104 testSelectorRoundTrip("::-webkit-search-results-decoration");
105 testSelectorRoundTrip("::-webkit-slider-thumb");
106
107 debug('');
108
109 testSelectorRoundTrip('input:not([type="file"]):focus');
110 testSelectorRoundTrip(':-webkit-any([type="file"])');
111 testSelectorRoundTrip(':-webkit-any(:hover)');
112 testSelectorRoundTrip('input:-webkit-any([type="file"],:hover,:focus):enabled');
113 testSelectorRoundTrip(':-webkit-any(input[type="file"],a:hover,button:focus)');
114 testSelectorRoundTrip(':-webkit-any(.class1.class2.class3)');
115 testSelectorRoundTrip(':-webkit-any(.class1:hover)');
116 testSelectorRoundTrip(':-webkit-any(a.class1.class2.class3:hover)');
117
118 debug('');
119
120 shouldBe("parseThenSerializeRule('*:active { }')", "':active { }'");
121 shouldBe("parseThenSerializeRule('|a { }')", "'a { }'");
122
123 debug('');
124
125 shouldBe("parseThenSerializeRule('input[type=file]:focus { }')", "'input[type=\"file\"]:focus { }'");
126
127 debug('');
128
129 shouldBe("parseThenSerializeRule('a+b { }')", "'a + b { }'");
130 shouldBe("parseThenSerializeRule('a~b { }')", "'a ~ b { }'");
131 shouldBe("parseThenSerializeRule('a>b { }')", "'a > b { }'");
132
133 debug('');
134
135 shouldBe("parseThenSerializeRule(':after { }')", "'::after { }'");
136 shouldBe("parseThenSerializeRule(':before { }')", "'::before { }'");
137 shouldBe("parseThenSerializeRule(':first-letter { }')", "'::first-letter { }'");
138 shouldBe("parseThenSerializeRule(':first-line { }')", "'::first-line { }'");
139 shouldBe("parseThenSerializeRule(':-webkit-any(    a.class1  ,          #id,[attr]  ) { }')","':-webkit-any(a.class1,#id,[attr]) { }'");
140
141 debug('');
142
143 </script>
144 <script src="../js/resources/js-test-post.js"></script>
145 </body>
146 </html>