Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / media / mq-parsing.html
blob4dda62ad94b452f01ae6062cef3fe545d93957f7
1 <html>
2 <head>
3 <style type="text/css">
4 @media screen {
5 #console { color: black; }
7 </style>
8 <script>
9 function resultStringifier(result)
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 + "\"";
20 function printOut(expect, res) {
21 var console = document.getElementById("console");
22 var span = document.createElement('span');
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);
33 function runTests() {
34 if (window.testRunner)
35 testRunner.dumpAsText();
37 var rules = document.styleSheets[0].cssRules;
38 var mediaList = rules.item(0).media;
40 printOut("screen", mediaList.mediaText);
42 mediaList.mediaText = null;
43 printOut("", mediaList.mediaText);
45 mediaList.mediaText = "screen"
46 mediaList.mediaText = ",,all,,";
47 printOut("not all, not all, all, not all, not all", mediaList.mediaText);
49 mediaList.mediaText = ",,all,, ";
50 printOut("not all, not all, all, not all, not all", mediaList.mediaText);
52 output = "all";
53 try {
54 mediaList.mediaText = ",screen,,&invalid,,";
55 } catch(e) {
56 output = null;
58 printOut("not all, screen, not all, not all, not all, not all", mediaList.mediaText);
60 output = "all";
61 try {
62 mediaList.mediaText = ",screen,,(invalid,),,";
63 } catch(e) {
64 output = null;
66 printOut("not all, screen, not all, not all, not all, not all", mediaList.mediaText);
68 output = "all";
69 try {
70 mediaList.mediaText = ",(all,),,";
71 } catch(e) {
72 output = null;
74 printOut("not all, not all, not all, not all", mediaList.mediaText);
76 </script>
77 </head>
78 <body onload="runTests()">
79 <div id="console"></div>
80 </body>
81 </html>