Index: LayoutTests/fast/media/mq-parsing.html |
diff --git a/LayoutTests/fast/media/mq-parsing.html b/LayoutTests/fast/media/mq-parsing.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4dda62ad94b452f01ae6062cef3fe545d93957f7 |
--- /dev/null |
+++ b/LayoutTests/fast/media/mq-parsing.html |
@@ -0,0 +1,81 @@ |
+<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> |