test_css_supports.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=779917
  5. -->
  6. <head>
  7. <title>Test for Bug 779917</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. </head>
  11. <body>
  12. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=779917">Mozilla Bug 779917</a>
  13. <p id="display"></p>
  14. <div id="content" style="display: none">
  15. </div>
  16. <pre id="test">
  17. <script type="application/javascript">
  18. /** Test for Bug 779917 **/
  19. function runTest()
  20. {
  21. var passingConditions = [
  22. "(color: green)",
  23. "((color: green))",
  24. "(color: green !important)",
  25. "(color: rainbow) or (color: green)",
  26. "(color: green) or (color: rainbow)",
  27. "(color: green) and (color: blue)",
  28. "(color: rainbow) or (color: iridescent) or (color: green)",
  29. "(color: red) and (color: green) and (color: blue)",
  30. "(color:green)",
  31. "not (color: rainbow)",
  32. "not (not (color: green))",
  33. "(unknown:) or (color: green)",
  34. "(unknown) or (color: green)",
  35. "(font: 16px serif)",
  36. "(color:) or (color: green)",
  37. "not (@page)",
  38. "not ({ something @with [ balanced ] brackets })",
  39. "an-extension(of some kind) or (color: green)",
  40. "not ()",
  41. "( Font: 20px serif ! Important) ",
  42. "(color: /* comment */ green)",
  43. "(/* comment */ color: green)",
  44. "(color: green /* comment */)",
  45. "(color: green) /* comment */",
  46. "/* comment */ (color: green)",
  47. "(color /* comment */: green)",
  48. "(color: green) /* unclosed comment",
  49. "(color: green",
  50. "(((((((color: green",
  51. "(font-family: 'Helvetica"
  52. ];
  53. var failingConditions = [
  54. "(color: rainbow)",
  55. "(color: rainbow) and (color: green)",
  56. "(color: blue) and (color: rainbow)",
  57. "(color: green) and (color: green) or (color: green)",
  58. "(color: green) or (color: green) and (color: green)",
  59. "not not (color: green)",
  60. "not (color: rainbow) and not (color: iridescent)",
  61. "not (color: rainbow) or (color: green)",
  62. "(not (color: rainbow) or (color: green))",
  63. "(unknown: green)",
  64. "not ({ something @with (unbalanced brackets })",
  65. "(color: green) or an-extension(that is [unbalanced)",
  66. "not(unknown: unknown)",
  67. "(color: green) or(color: blue)",
  68. "color: green",
  69. "(color: green;)",
  70. "(font-family: 'Helvetica\n",
  71. "(font-family: 'Helvetica\n')",
  72. "()",
  73. ""
  74. ];
  75. var passingDeclarations = [
  76. ["color", "green"],
  77. ["color", " green "],
  78. ["Color", "Green"],
  79. ["color", "green /* comment */"],
  80. ["color", "/* comment */ green"],
  81. ["color", "green /* unclosed comment"],
  82. ["font", "16px serif"],
  83. ["font", "16px /* comment */ serif"],
  84. ["font", "16px\nserif"],
  85. ["color", "\\0067reen"]
  86. ];
  87. var failingDeclarations = [
  88. ["color ", "green"],
  89. ["color", "rainbow"],
  90. ["color", "green green"],
  91. ["color", "green !important"],
  92. ["\\0063olor", "green"],
  93. ["/* comment */color", "green"],
  94. ["color/* comment */", "green"],
  95. ["font-family", "'Helvetica\n"],
  96. ["font-family", "'Helvetica\n'"],
  97. ["color", "green;"],
  98. ["color", ""],
  99. ["unknown", "unknown"],
  100. ["", "green"],
  101. ["", ""]
  102. ];
  103. passingConditions.forEach(function(aCondition) {
  104. is(CSS.supports(aCondition), true, "CSS.supports returns true for passing condition \"" + aCondition + "\"");
  105. });
  106. failingConditions.forEach(function(aCondition) {
  107. is(CSS.supports(aCondition), false, "CSS.supports returns false for failing condition \"" + aCondition + "\"");
  108. });
  109. passingDeclarations.forEach(function(aDeclaration) {
  110. is(CSS.supports(aDeclaration[0], aDeclaration[1]), true, "CSS.supports returns true for supported declaration \"" + aDeclaration.join(":") + "\"");
  111. });
  112. failingDeclarations.forEach(function(aDeclaration) {
  113. is(CSS.supports(aDeclaration[0], aDeclaration[1]), false, "CSS.supports returns false for unsupported declaration \"" + aDeclaration.join(":") + "\"");
  114. });
  115. SimpleTest.finish();
  116. }
  117. SimpleTest.waitForExplicitFinish();
  118. runTest();
  119. </script>
  120. </pre>
  121. </body>
  122. </html>