<html>
<head>
<title>CSS3 media query test: @media css rule media.mediaText property parsing, media query syntax error should be handled correctly (,,,,).</title>
<link rel="help" href="http://www.w3.org/TR/CSS21/media.html">
<link rel="help" href="http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSMediaRule">
<!-- this test shows there there is no disconnect between CSS media queries and HTML5 media descriptors -->
<style type="text/css">
p#result { color: red }
@media braille {
/* query will be modified from javascript */
/* the manipulation contains syntax error, and should fail */
p#result { color: red }
}
</style>
<script>
function test() {
try {
// This shouldn't throw.
document.styleSheets[0].media.mediaText = ",,,,";
document.getElementById("result").innerHTML = "Success. This text should not be red.";
} catch (e) {
document.getElementById("result").innerHTML = "Failure. ,,,, should be valid media descriptor.";
document.getElementById("details").innerHTML = "Caught exception: " + e;
return;
}
try {
// This shouldn't throw.
document.styleSheets[0].cssRules[1].media.mediaText = ",,,,";
document.getElementById("result").innerHTML = "Success. This text should not be red.";
} catch (e) {
document.getElementById("result").innerHTML = "Failure. Exception thrown.";
document.getElementById("details").innerHTML = "Caught exception: " + e;
}
}
</script>
</head>
<body onload="test()">
<p id="result">Failure: test not run</p>
<p id="details"></p>
</body>
</html>