| <html> |
| <head> |
| <style type="text/css"> |
| @media screen { |
| #console { color: black; } |
| } |
| </style> |
| <script> |
| function resultStringifier(result) |
| { |
| if (result === "") |
| return "<b>\"\"</b>"; |
| else if (result === undefined) |
| return "<b>undefined</b>"; |
| else if (result === null) |
| return "<b>null</b>"; |
| return "\"" + result + "\""; |
| } |
| |
| function printOut(expect, res) { |
| var console = document.getElementById("console"); |
| var span = document.createElement('span'); |
| |
| var a = resultStringifier(expect); |
| var b = resultStringifier(res); |
| if (a === b) |
| span.innerHTML += "PASS: Got " + b + " as expected.<br>"; |
| else |
| span.innerHTML += "FAIL: Got " + b + " but was expecting " + a + "<br>"; |
| console.appendChild(span); |
| } |
| |
| function runTests() { |
| if (window.testRunner) |
| testRunner.dumpAsText(); |
| |
| var rules = document.styleSheets[0].cssRules; |
| var mediaList = rules.item(0).media; |
| |
| printOut("screen", mediaList.mediaText); |
| |
| mediaList.mediaText = null; |
| printOut("", mediaList.mediaText); |
| |
| mediaList.mediaText = "screen" |
| mediaList.mediaText = ",,all,,"; |
| printOut("not all, not all, all, not all, not all", mediaList.mediaText); |
| |
| mediaList.mediaText = ",,all,, "; |
| printOut("not all, not all, all, not all, not all", mediaList.mediaText); |
| |
| output = "all"; |
| try { |
| mediaList.mediaText = ",screen,,&invalid,,"; |
| } catch(e) { |
| output = null; |
| } |
| printOut("not all, screen, not all, not all, not all, not all", mediaList.mediaText); |
| |
| output = "all"; |
| try { |
| mediaList.mediaText = ",screen,,(invalid,),,"; |
| } catch(e) { |
| output = null; |
| } |
| printOut("not all, screen, not all, not all, not all, not all", mediaList.mediaText); |
| |
| output = "all"; |
| try { |
| mediaList.mediaText = ",(all,),,"; |
| } catch(e) { |
| output = null; |
| } |
| printOut("not all, not all, not all, not all", mediaList.mediaText); |
| } |
| </script> |
| </head> |
| <body onload="runTests()"> |
| <div id="console"></div> |
| </body> |
| </html> |