1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/layout/style/test/test_condition_text_assignment.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,59 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=815021 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 815021</title> 1.11 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.13 + <style id="style"> 1.14 + #a { text-transform: none } 1.15 + @media all { 1.16 + #a { text-transform: lowercase } 1.17 + } 1.18 + </style> 1.19 +</head> 1.20 +<body> 1.21 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=815021">Mozilla Bug 815021</a> 1.22 +<p id="display"><span id=a></span></p> 1.23 +<div id="content" style="display: none"> 1.24 + 1.25 +</div> 1.26 +<pre id="test"> 1.27 +<script type="application/javascript"> 1.28 + 1.29 +/** Test for Bug 815021 **/ 1.30 + 1.31 +var sheet = document.getElementById("style").sheet; 1.32 +var rule = sheet.cssRules[1]; 1.33 +var a = document.getElementById("a"); 1.34 + 1.35 +function stylesApplied() { 1.36 + return window.getComputedStyle(a, "").textTransform == "lowercase"; 1.37 +} 1.38 + 1.39 +is(rule.type, CSSRule.MEDIA_RULE, "initial @media rule type"); 1.40 +is(rule.conditionText, "all", "initial @media rule conditionText"); 1.41 +ok(stylesApplied(), "initial @media rule applied"); 1.42 + 1.43 +// [value to set, value to check, whether styles should be applied] 1.44 +var media = [ 1.45 + ["not all", "not all", false], 1.46 + ["ALL ", "all", true], 1.47 + ["unknown", "unknown", false], 1.48 + ["(min-width:1px)", "(min-width: 1px)", true], 1.49 + ["(bad syntax", "not all", false], 1.50 + ["(max-width: 1px), (color)", "(max-width: 1px), (color)", true] 1.51 +]; 1.52 + 1.53 +for (var i = 0; i < media.length; i++) { 1.54 + rule.conditionText = media[i][0]; 1.55 + is(rule.conditionText, media[i][1], "value of conditionText #" + i); 1.56 + ok(rule.cssText.startsWith("@media " + media[i][1]), "value of cssText #" + i); 1.57 + ok(stylesApplied() == media[i][2], "styles applied #" + i); 1.58 +} 1.59 +</script> 1.60 +</pre> 1.61 +</body> 1.62 +</html>