4 https://bugzilla.mozilla.org/show_bug.cgi?id=156716
8 This is test 46 from the Acid3 test, http://acid3.acidtests.org/
9 extracted from the test framework there and put into Mochitest.
11 (from irc.mozilla.org, developers)
12 [2008-05-14 18:07:38] <Hixie> dbaron: I hereby grant all files available from the server http://acid3.acidtests.org/ under the following license: (c) copyright 2008 Ian Hickson. These documents may be used under the terms of any of the following licenses: MPL. GPL. LGPL. BSD.
16 <title>Test for Bug
156716</title>
17 <script type=
"text/javascript" src=
"/MochiKit/MochiKit.js"></script>
18 <script type=
"text/javascript" src=
"/tests/SimpleTest/SimpleTest.js"></script>
19 <style type=
"text/css">
20 iframe#selectors
{ width: 0; height: 0; }
22 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
25 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=156716">Mozilla Bug
156716</a>
27 <iframe src=
"empty.html" id=
"selectors"></iframe>
29 <div id=
"content" style=
"display: none">
33 <script class=
"testbody" type=
"text/javascript">
35 /** Test for Bug
156716 **/
37 function getTestDocument() {
38 var iframe = document.getElementById(
"selectors");
39 var doc = iframe.contentDocument;
40 for (var i = doc.documentElement.childNodes.length-
1; i
>=
0; i -=
1)
41 doc.documentElement.removeChild(doc.documentElement.childNodes[i]);
42 doc.documentElement.appendChild(doc.createElement('head'));
43 doc.documentElement.firstChild.appendChild(doc.createElement('title'));
44 doc.documentElement.appendChild(doc.createElement('body'));
48 // test
46: media queries
49 var doc = getTestDocument();
50 var style = doc.createElement('style');
51 style.setAttribute('type', 'text/css');
52 style.appendChild(doc.createTextNode('@media all and (min-color:
0) { #a { text-transform: uppercase; } }')); // matches
53 style.appendChild(doc.createTextNode('@media not all and (min-color:
0) { #b { text-transform: uppercase; } }'));
54 style.appendChild(doc.createTextNode('@media only all and (min-color:
0) { #c { text-transform: uppercase; } }')); // matches
55 style.appendChild(doc.createTextNode('@media (bogus) { #d { text-transform: uppercase; } }'));
56 style.appendChild(doc.createTextNode('@media all and (bogus) { #e { text-transform: uppercase; } }'));
57 style.appendChild(doc.createTextNode('@media not all and (bogus) { #f { text-transform: uppercase; } }')); // matches
58 style.appendChild(doc.createTextNode('@media only all and (bogus) { #g { text-transform: uppercase; } }'));
59 style.appendChild(doc.createTextNode('@media (bogus), all { #h { text-transform: uppercase; } }')); // matches
60 style.appendChild(doc.createTextNode('@media all and (bogus), all { #i { text-transform: uppercase; } }')); // matches
61 style.appendChild(doc.createTextNode('@media not all and (bogus), all { #j { text-transform: uppercase; } }')); // matches
62 style.appendChild(doc.createTextNode('@media only all and (bogus), all { #k { text-transform: uppercase; } }')); // matches
63 style.appendChild(doc.createTextNode('@media all, (bogus) { #l { text-transform: uppercase; } }')); // matches
64 style.appendChild(doc.createTextNode('@media all, all and (bogus) { #m { text-transform: uppercase; } }')); // matches
65 style.appendChild(doc.createTextNode('@media all, not all and (bogus) { #n { text-transform: uppercase; } }')); // matches
66 style.appendChild(doc.createTextNode('@media all, only all and (bogus) { #o { text-transform: uppercase; } }')); // matches
67 style.appendChild(doc.createTextNode('@media all and color { #p { text-transform: uppercase; } }'));
68 style.appendChild(doc.createTextNode('@media all and min-color:
0 { #q { text-transform: uppercase; } }'));
69 style.appendChild(doc.createTextNode('@media all, all and color { #r { text-transform: uppercase; } }'));
70 style.appendChild(doc.createTextNode('@media all, all and min-color:
0 { #s { text-transform: uppercase; } }'));
71 style.appendChild(doc.createTextNode('@media all and min-color:
0, all { #t { text-transform: uppercase; } }'));
72 style.appendChild(doc.createTextNode('@media (max-color:
0) and (max-monochrome:
0) { #u { text-transform: uppercase; } }'));
73 style.appendChild(doc.createTextNode('@media (min-color:
1), (min-monochrome:
1) { #v { text-transform: uppercase; } }')); // matches
74 style.appendChild(doc.createTextNode('@media all and (min-color:
0) and (min-monochrome:
0) { #w { text-transform: uppercase; } }')); // matches
75 style.appendChild(doc.createTextNode('@media not all and (min-color:
1), not all and (min-monochrome:
1) { #x { text-transform: uppercase; } }')); // matches
76 style.appendChild(doc.createTextNode('@media all and (min-height:
1em) and (min-width:
1em) { #y1 { text-transform: uppercase; } }'));
77 style.appendChild(doc.createTextNode('@media all and (max-height:
1em) and (min-width:
1em) { #y2 { text-transform: uppercase; } }'));
78 style.appendChild(doc.createTextNode('@media all and (min-height:
1em) and (max-width:
1em) { #y3 { text-transform: uppercase; } }'));
79 style.appendChild(doc.createTextNode('@media all and (max-height:
1em) and (max-width:
1em) { #y4 { text-transform: uppercase; } }')); // matches
80 doc.getElementsByTagName('head')[
0].appendChild(style);
81 var names = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y1', 'y2', 'y3', 'y4'];
82 for (var i in names) {
83 var p = doc.createElement('p');
85 doc.body.appendChild(p);
88 var check = function (c, e) {
90 var p = doc.getElementById(c);
91 is(doc.defaultView.getComputedStyle(p, '').textTransform, e ? 'uppercase' : 'none',
"case " + c +
" failed (index " + count +
")");
93 check('a', true); //
1
98 check('f', false); // true in old spec; commented out in real Acid3
102 check('j', true); //
10
110 check('r', true); // false in old spec
111 check('s', true); // false in old spec
112 check('t', true); //
20 - false in old spec
117 // here the viewport is
0x0
118 check('y1', false); //
25
122 document.getElementById(
"selectors").setAttribute(
"style",
"height: 100px; width: 100px");
123 // now the viewport is more than
1em by
1em
124 check('y1', true); //
29
128 document.getElementById(
"selectors").removeAttribute(
"style");
129 // here the viewport is
0x0 again
130 check('y1', false); //
33