4 <title>Test for CSS EOF handling
</title>
5 <script type=
"text/javascript" src=
"/MochiKit/MochiKit.js"></script>
6 <script type=
"text/javascript" src=
"/tests/SimpleTest/SimpleTest.js"></script>
7 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
11 href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=311616">bug
311616</a>,
13 href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=325064">bug
325064</a></p>
14 <iframe id=
"display"></iframe>
17 <script class=
"testbody" type=
"text/javascript">
21 ref:
"#r {background-color : orange}",
22 tst:
"#t {background-color : orange",
23 prop:
"background-color", pseudo:
""
27 ref:
"#r {background-color: rgb(0,255,0)}",
28 tst:
"#t {background-color: rgb(0,255,0",
29 prop:
"background-color", pseudo:
""
33 ref:
"#r {background-color: aqua/*marine*/}",
34 tst:
"#t {background-color: aqua/*marine",
35 prop:
"background-color", pseudo:
""
39 ref:
"@media all { #r { background-color: yellow } }",
40 tst:
"@media all { #t { background-color: yellow }",
41 prop:
"background-color", pseudo:
""
45 ref:
"@media all { #r { background-color: magenta } }",
46 tst:
"@media all { #t { background-color: magenta",
47 prop:
"background-color", pseudo:
""
51 ref:
"@import 'data:text/css,%23r%7Bbackground-color%3Agray%7D';",
52 tst:
"@import 'data:text/css,%23t%7Bbackground-color%3Agray%7D",
53 prop:
"background-color", pseudo:
""
57 ref:
"@import 'data:text/css,%23r%7Bbackground-color%3Ablack%7D' all;",
58 tst:
"@import 'data:text/css,%23t%7Bbackground-color%3Ablack%7D' all",
59 prop:
"background-color", pseudo:
""
63 ref:
"#r { background-image: url(data:image/png;base64," +
64 "iVBORw0KGgoAAAANSUhEUgAAAAQAAAAEAQAAAACBiqPTAAAADklEQVQI12NI" +
65 "YJgAhAkAB4gB4Ry+pcoAAAAASUVORK5CYII=) }",
66 tst:
"#t { background-image: url(data:image/png;base64," +
67 "iVBORw0KGgoAAAANSUhEUgAAAAQAAAAEAQAAAACBiqPTAAAADklEQVQI12NI" +
68 "YJgAhAkAB4gB4Ry+pcoAAAAASUVORK5CYII=",
69 prop:
"background-image", pseudo:
""
73 ref:
"#r { background-image: url('data:image/png;base64," +
74 "iVBORw0KGgoAAAANSUhEUgAAAAQAAAAEAQAAAACBiqPTAAAAEElEQVQI12Mo" +
75 "YNjAcIHhAQAJ2ALR4kRk1gAAAABJRU5ErkJggg==') }",
76 tst:
"#t { background-image: url('data:image/png;base64," +
77 "iVBORw0KGgoAAAANSUhEUgAAAAQAAAAEAQAAAACBiqPTAAAAEElEQVQI12Mo" +
78 "YNjAcIHhAQAJ2ALR4kRk1gAAAABJRU5ErkJggg==",
79 prop:
"background-image", pseudo:
""
83 ref:
"#r { background-image: url('data:image/png;base64," +
84 "iVBORw0KGgoAAAANSUhEUgAAAAQAAAAEAQAAAACBiqPTAAAAEElEQVQI12N4" +
85 "wHCBYQNDAQAMuALRrGb97AAAAABJRU5ErkJggg==') }",
86 tst:
"#t { background-image: url('data:image/png;base64," +
87 "iVBORw0KGgoAAAANSUhEUgAAAAQAAAAEAQAAAACBiqPTAAAAEElEQVQI12N4" +
88 "wHCBYQNDAQAMuALRrGb97AAAAABJRU5ErkJggg=='",
89 prop:
"background-image", pseudo:
""
93 ref:
"#r::before { content: counter(tr, upper-alpha) }",
94 tst:
"#t::before { content: counter(tr, upper-alpha",
95 prop:
"content", pseudo:
"::before"
99 ref:
"#r::before { content: 'B' }",
100 tst:
"#t::before { content: 'B",
101 prop:
"content", pseudo:
"::before"
104 /* For these tests, there is no visible effect on computed style;
105 instead we have to audit the DOM stylesheet object. */
108 todo:
1, /* bug
446226 */
110 ref:
"td[colspan='3'] {}",
114 todo:
1, /* bug
446226 */
116 ref:
"td[colspan='3'] {}",
117 tst:
"td[colspan='3'"
120 todo:
1, /* bug
446226 */
122 ref:
"td:lang(en) {}",
128 ref:
"@charset 'utf-8';",
129 tst:
"@charset 'utf-8"
133 ref:
"@charset 'utf-8';",
134 tst:
"@charset 'utf-8'"
138 ref:
"@media all {}",
142 name:
"@namespace 1a",
143 ref:
"@namespace foo url('http://foo.example.com/');",
144 tst:
"@namespace foo url('http://foo.example.com/')"
147 name:
"@namespace 1b",
148 ref:
"@namespace foo url(http://foo.example.com/);",
149 tst:
"@namespace foo url(http://foo.example.com/"
152 name:
"@namespace 1c",
153 ref:
"@namespace foo url('http://foo.example.com/');",
154 tst:
"@namespace foo url('http://foo.example.com/"
157 name:
"@namespace 1d",
158 ref:
"@namespace foo 'http://foo.example.com/';",
159 tst:
"@namespace foo 'http://foo.example.com/'"
162 name:
"@namespace 1e",
163 ref:
"@namespace foo 'http://foo.example.com/';",
164 tst:
"@namespace foo 'http://foo.example.com/"
167 name:
"@namespace 2a",
168 ref:
"@namespace url('http://foo.example.com/');",
169 tst:
"@namespace url('http://foo.example.com/')"
172 name:
"@namespace 2b",
173 ref:
"@namespace url('http://foo.example.com/');",
174 tst:
"@namespace url('http://foo.example.com/'"
177 name:
"@namespace 2c",
178 ref:
"@namespace url('http://foo.example.com/');",
179 tst:
"@namespace url('http://foo.example.com/"
182 name:
"@namespace 2d",
183 ref:
"@namespace 'http://foo.example.com/';",
184 tst:
"@namespace 'http://foo.example.com/'"
187 name:
"@namespace 2e",
188 ref:
"@namespace 'http://foo.example.com/';",
189 tst:
"@namespace 'http://foo.example.com/"
192 name:
"@-moz-document 1",
193 ref:
"@-moz-document domain('example.com') {}",
194 tst:
"@-moz-document domain('example.com') {"
197 name:
"@-moz-document 2",
198 ref:
"@-moz-document domain('example.com') { p {} }",
199 tst:
"@-moz-document domain('example.com') { p {"
203 const basestyle = (
"table {\n"+
204 " border-collapse: collapse;\n"+
209 " border: 1px solid black;\n"+
210 " text-align: center;\n"+
213 "tr { counter-increment: tr }\n");
215 /* This is more complicated than it might look like it needs to be,
216 because for each subtest we have to splat stuff into the iframe,
217 allow the renderer to run, and only then interrogate the computed
220 SimpleTest.waitForExplicitFinish();
222 window.onload = function() {
223 const frame = document.getElementById(
"display");
226 const prepareTest = function() {
227 var cd = frame.contentDocument;
229 cd.write('
<!DOCTYPE HTML
><html><head>' +
230 '
<style>\n' + basestyle + '
</style>\n' +
231 '
<style>\n' + tests[curTest].ref + '
</style>\n' +
232 '
<style>\n' + tests[curTest].tst + '
</style>\n' +
234 '
<table><tr><td id=
"r"><td id=
"t"></table>' +
239 const checkTest = function() {
240 var cd = frame.contentDocument;
241 var _is = tests[curTest].todo ? todo_is : is;
242 var _ok = tests[curTest].todo ? todo : ok;
244 if (cd.styleSheets[
1].cssRules.length ==
1 &&
245 cd.styleSheets[
2].cssRules.length ==
1) {
246 // If we have a .prop for this test, the .cssText of the reference
247 // and test rules will differ in the selector. Change #t to #r
249 var ref_canon = cd.styleSheets[
1].cssRules[
0].cssText;
250 var tst_canon = cd.styleSheets[
2].cssRules[
0].cssText;
251 tst_canon = tst_canon.replace(/(#|%
23)t\b/,
"$1r");
252 _is(tst_canon, ref_canon,
253 tests[curTest].name +
" (canonicalized rule)");
255 _ok(false, tests[curTest].name +
" (rule missing)");
257 if (tests[curTest].prop) {
258 var prop = tests[curTest].prop;
259 var pseudo = tests[curTest].pseudo;
261 var refElt = cd.getElementById(
"r");
262 var tstElt = cd.getElementById(
"t");
263 var refStyle = cd.defaultView.getComputedStyle(refElt, pseudo);
264 var tstStyle = cd.defaultView.getComputedStyle(tstElt, pseudo);
265 _is(tstStyle.getPropertyValue(prop),
266 refStyle.getPropertyValue(prop),
267 tests[curTest].name +
" (computed style)");
270 if (curTest < tests.length) {
277 frame.onload = function(){setTimeout(checkTest,
0);};