test_condition_text_assignment.html 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=815021
  5. -->
  6. <head>
  7. <title>Test for Bug 815021</title>
  8. <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  9. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  10. <style id="style">
  11. #a { text-transform: none }
  12. @media all {
  13. #a { text-transform: lowercase }
  14. }
  15. </style>
  16. </head>
  17. <body>
  18. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=815021">Mozilla Bug 815021</a>
  19. <p id="display"><span id=a></span></p>
  20. <div id="content" style="display: none">
  21. </div>
  22. <pre id="test">
  23. <script type="application/javascript">
  24. /** Test for Bug 815021 **/
  25. var sheet = document.getElementById("style").sheet;
  26. var rule = sheet.cssRules[1];
  27. var a = document.getElementById("a");
  28. function stylesApplied() {
  29. return window.getComputedStyle(a, "").textTransform == "lowercase";
  30. }
  31. is(rule.type, CSSRule.MEDIA_RULE, "initial @media rule type");
  32. is(rule.conditionText, "all", "initial @media rule conditionText");
  33. ok(stylesApplied(), "initial @media rule applied");
  34. // [value to set, value to check, whether styles should be applied]
  35. var media = [
  36. ["not all", "not all", false],
  37. ["ALL ", "all", true],
  38. ["unknown", "unknown", false],
  39. ["(min-width:1px)", "(min-width: 1px)", true],
  40. ["(bad syntax", "not all", false],
  41. ["(max-width: 1px), (color)", "(max-width: 1px), (color)", true]
  42. ];
  43. for (var i = 0; i < media.length; i++) {
  44. rule.conditionText = media[i][0];
  45. is(rule.conditionText, media[i][1], "value of conditionText #" + i);
  46. ok(rule.cssText.startsWith("@media " + media[i][1]), "value of cssText #" + i);
  47. ok(stylesApplied() == media[i][2], "styles applied #" + i);
  48. }
  49. </script>
  50. </pre>
  51. </body>
  52. </html>