test_condition_text.html 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=814907
  5. -->
  6. <head>
  7. <title>Test for Bug 814907</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. @-moz-document url(http://www.example.com/) {}
  12. @-moz-document url('http://www.example.com/') {}
  13. @-moz-document url("http://www.example.com/") {}
  14. @-moz-document url-prefix('http://www.example.com/') {}
  15. @-moz-document url-prefix("http://www.example.com/") {}
  16. @-moz-document domain('example.com') {}
  17. @-moz-document domain("example.com") {}
  18. @-moz-document regexp('http://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/') {}
  19. @-moz-document regexp("http://www.w3.org/TR/\\d{4}/[^/]*-CSS2-\\d{8}/") {}
  20. @media all {}
  21. @media only color {}
  22. @media (color ) {}
  23. @media color \0061ND ( monochrome ) {}
  24. @media (max-width: 200px), (color) {}
  25. @supports(color: green){}
  26. @supports (color: green) {}
  27. @supports ((color: green)) {}
  28. @supports (color: green) and (color: blue) {}
  29. @supports ( Font: 20px serif ! Important) {}
  30. </style>
  31. </head>
  32. <body>
  33. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=814907">Mozilla Bug 814907</a>
  34. <p id="display"></p>
  35. <div id="content" style="display: none">
  36. </div>
  37. <pre id="test">
  38. <script type="application/javascript">
  39. /** Test for Bug 814907 **/
  40. function runTest()
  41. {
  42. // re-parse the style sheet with the pref turned on
  43. var style = document.getElementById("style");
  44. style.textContent += " ";
  45. var sheet = style.sheet;
  46. var conditions = [
  47. "url(\"http://www.example.com/\")",
  48. "url(\"http://www.example.com/\")",
  49. "url(\"http://www.example.com/\")",
  50. "url-prefix(\"http://www.example.com/\")",
  51. "url-prefix(\"http://www.example.com/\")",
  52. "domain(\"example.com\")",
  53. "domain(\"example.com\")",
  54. "regexp(\"http://www.w3.org/TR/\\\\d{4}/[^/]*-CSS2-\\\\d{8}/\")",
  55. "regexp(\"http://www.w3.org/TR/\\\\d{4}/[^/]*-CSS2-\\\\d{8}/\")",
  56. "all",
  57. "only color",
  58. "(color)",
  59. "color and (monochrome)",
  60. "(max-width: 200px), (color)",
  61. "(color: green)",
  62. "(color: green)",
  63. "((color: green))",
  64. "(color: green) and (color: blue)",
  65. "( Font: 20px serif ! Important)"
  66. ];
  67. is(sheet.cssRules.length, conditions.length);
  68. for (var i = 0; i < sheet.cssRules.length; i++) {
  69. var rule = sheet.cssRules[i];
  70. is(rule.conditionText, conditions[i], "rule " + i + " has expected conditionText");
  71. if (rule.type == CSSRule.MEDIA_RULE) {
  72. is(rule.conditionText, rule.media.mediaText, "rule " + i + " conditionText matches media.mediaText");
  73. }
  74. }
  75. SimpleTest.finish();
  76. }
  77. SimpleTest.waitForExplicitFinish();
  78. runTest();
  79. </script>
  80. </pre>
  81. </body>
  82. </html>