OLD | NEW |
(Empty) | |
| 1 <html> |
| 2 <head> |
| 3 <style type="text/css"> |
| 4 @media screen { |
| 5 #console { color: black; } |
| 6 } |
| 7 </style> |
| 8 <script> |
| 9 function resultStringifier(result) |
| 10 { |
| 11 if (result === "") |
| 12 return "<b>\"\"</b>"; |
| 13 else if (result === undefined) |
| 14 return "<b>undefined</b>"; |
| 15 else if (result === null) |
| 16 return "<b>null</b>"; |
| 17 return "\"" + result + "\""; |
| 18 } |
| 19 |
| 20 function printOut(expect, res) { |
| 21 var console = document.getElementById("console"); |
| 22 var span = document.createElement('span'); |
| 23 |
| 24 var a = resultStringifier(expect); |
| 25 var b = resultStringifier(res); |
| 26 if (a === b) |
| 27 span.innerHTML += "PASS: Got " + b + " as expected.<br>"; |
| 28 else |
| 29 span.innerHTML += "FAIL: Got " + b + " but was expecting " + a +
"<br>"; |
| 30 console.appendChild(span); |
| 31 } |
| 32 |
| 33 function runTests() { |
| 34 if (window.testRunner) |
| 35 testRunner.dumpAsText(); |
| 36 |
| 37 var rules = document.styleSheets[0].cssRules; |
| 38 var mediaList = rules.item(0).media; |
| 39 |
| 40 printOut("screen", mediaList.mediaText); |
| 41 |
| 42 mediaList.mediaText = null; |
| 43 printOut("", mediaList.mediaText); |
| 44 |
| 45 mediaList.mediaText = "screen" |
| 46 mediaList.mediaText = ",,all,,"; |
| 47 printOut("not all, not all, all, not all, not all", mediaList.mediaT
ext); |
| 48 |
| 49 mediaList.mediaText = ",,all,, "; |
| 50 printOut("not all, not all, all, not all, not all", mediaList.mediaT
ext); |
| 51 |
| 52 output = "all"; |
| 53 try { |
| 54 mediaList.mediaText = ",screen,,&invalid,,"; |
| 55 } catch(e) { |
| 56 output = null; |
| 57 } |
| 58 printOut("not all, screen, not all, not all, not all, not all", medi
aList.mediaText); |
| 59 |
| 60 output = "all"; |
| 61 try { |
| 62 mediaList.mediaText = ",screen,,(invalid,),,"; |
| 63 } catch(e) { |
| 64 output = null; |
| 65 } |
| 66 printOut("not all, screen, not all, not all, not all, not all", medi
aList.mediaText); |
| 67 |
| 68 output = "all"; |
| 69 try { |
| 70 mediaList.mediaText = ",(all,),,"; |
| 71 } catch(e) { |
| 72 output = null; |
| 73 } |
| 74 printOut("not all, not all, not all, not all", mediaList.mediaText); |
| 75 } |
| 76 </script> |
| 77 </head> |
| 78 <body onload="runTests()"> |
| 79 <div id="console"></div> |
| 80 </body> |
| 81 </html> |
OLD | NEW |