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