blob: 9d06b8209598080a54c01a60370b63cf59ad76e8 [file] [log] [blame]
<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 slight disconnect between css media queries and html4 media descriptors -->
<style type="text/css">
p#result {color: green}
@media braille {
/* query will be modified from javascript */
/* the manipulation contains syntax error, and should fail */
p#result {color: red}
}
}
</style>
<script language="javascript">
function test() {
try {
// this shouldn't throw
document.styleSheets[0].media.mediaText = ",,,,";
} 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 be green.";
} 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>