test_bug511909.html (4424B)
1 <html><!-- 2 https://bugzilla.mozilla.org/show_bug.cgi?id=511909 3 --><head> 4 <meta http-equiv="content-type" content="text/html; charset=UTF-8"> 5 <title>@media and @-moz-document testcases</title> 6 7 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 8 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/> 9 10 <style type="text/css"> 11 a { 12 font-weight: bold; 13 } 14 #pink { 15 color: pink; 16 } 17 18 #green { 19 color: green; 20 } 21 22 #blue { 23 color: blue; 24 } 25 26 pre { 27 border: 1px solid black; 28 } 29 </style> 30 31 <style type="text/css"> 32 @-moz-document regexp(".*test_bug511909.*"){ 33 #d { 34 color: pink; 35 } 36 } 37 </style> 38 39 <style type="text/css"> 40 @media screen { 41 #m { 42 color: green; 43 } 44 } 45 </style> 46 47 <style type="text/css"> 48 @-moz-document regexp(".*test_bug511909.*"){ 49 @media screen { 50 #dm { 51 color: blue; 52 } 53 } 54 } 55 </style> 56 57 <!-- should parse --> 58 <style type="text/css"> 59 @media print { 60 @-moz-document regexp("not_this_url"),} 61 #mx { 62 color: pink; 63 } 64 } 65 } 66 </style> 67 68 <!-- should parse --> 69 <style type="text/css"> 70 @-moz-document regexp("not_this_url"){ 71 @media print ,} 72 #mxx { 73 color: blue; 74 } 75 } 76 } 77 </style> 78 79 <style type="text/css"> 80 @media screen { 81 @-moz-document regexp(".*test_bug511909.*"){ 82 #md { 83 color: green; 84 } 85 } 86 } 87 </style> 88 89 <style type="text/css"> 90 @media screen { 91 @-moz-document regexp(".*test_bug511909.*"){ 92 @media screen { 93 @-moz-document regexp(".*test_bug511909.*"){ 94 @media screen { 95 #me { 96 color: blue; 97 } 98 } 99 } 100 } 101 } 102 } 103 </style> 104 </head> 105 <body> 106 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=511909">Mozilla Bug 511909</a> 107 <p id="display"></p> 108 <div id="content" style="display: none"> 109 </div> 110 111 <script class="testbody" type="text/javascript"> 112 SimpleTest.waitForExplicitFinish(); 113 114 addLoadEvent(function() { 115 // Ensure all the sheets are re-parsed, so that the pref applies. 116 for (const sheet of Array.from(document.querySelectorAll('style'))) { 117 sheet.textContent += "/* dummy */"; 118 } 119 120 var pink = getComputedStyle(document.getElementById("pink"), ""); 121 var green = getComputedStyle(document.getElementById("green"), ""); 122 var blue = getComputedStyle(document.getElementById("blue"), ""); 123 124 var cs1 = getComputedStyle(document.getElementById("d"), ""); 125 var cs2 = getComputedStyle(document.getElementById("m"), ""); 126 var cs3 = getComputedStyle(document.getElementById("dm"), ""); 127 var cs4 = getComputedStyle(document.getElementById("md"), ""); 128 var cs5 = getComputedStyle(document.getElementById("mx"), ""); 129 var cs6 = getComputedStyle(document.getElementById("mxx"), ""); 130 var cs7 = getComputedStyle(document.getElementById("me"), ""); 131 132 is(cs1.color, pink.color, "@-moz-document applies"); 133 is(cs2.color, green.color, "@media applies"); 134 is(cs3.color, blue.color, "@media nested in @-moz-document applies"); 135 is(cs4.color, green.color, "@-moz-document nested in @media applies"); 136 is(cs5.color, pink.color, "broken @media nested in @-moz-document correctly handled"); 137 is(cs6.color, blue.color, "broken @-moz-document nested in @media correctly handled"); 138 is(cs7.color, blue.color, "@media nested in @-moz-document nested in @media applies"); 139 SimpleTest.finish(); 140 }); 141 </script> 142 <div> 143 <pre>default style 144 </pre> 145 <a id="pink">This line should be pink</a><br> 146 147 <a id="green">This line should be green</a><br> 148 149 <a id="blue">This line should be blue</a><br> 150 151 <pre>@-moz-document {...} 152 </pre> 153 <a id="d">This line should be pink</a><br> 154 <pre>@media screen {...} 155 </pre> 156 <a id="m">This line should be green</a><br> 157 <pre>@-moz-document { 158 @media screen {...} 159 } 160 </pre> 161 <a id="dm">This line should be blue</a><br> 162 <pre>@media print { 163 @-moz-document regexp("not_this_url"),} 164 #mx { 165 color: pink; 166 } 167 } 168 } 169 </pre> 170 <a id="mx">This line should be pink</a><br></div> 171 <pre>@-moz-document regexp("not_this_url"){ 172 @media print ,} 173 #mxx { 174 color: blue; 175 } 176 } 177 } 178 </pre> 179 <a id="mxx">This line should be blue</a><br> 180 <pre>@media screen { 181 @-moz-documen {...} 182 } 183 </pre> 184 <a id="md">This line should be green</a><br> 185 <pre>@media screen { 186 @-moz-document { 187 @media screen {...} 188 } 189 } 190 </pre> 191 <a id="me">This line should be blue</a><br> 192 193 194 </body></html>