1
0

test.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. (function() {
  2. var mode = CodeMirror.getMode({tabSize: 4}, "css");
  3. function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
  4. // Requires at least one media query
  5. MT("atMediaEmpty",
  6. "[def @media] [error {] }");
  7. MT("atMediaMultiple",
  8. "[def @media] [keyword not] [attribute screen] [operator and] ([property color]), [keyword not] [attribute print] [operator and] ([property color]) { }");
  9. MT("atMediaCheckStack",
  10. "[def @media] [attribute screen] { } [tag foo] { }");
  11. MT("atMediaCheckStack",
  12. "[def @media] [attribute screen] ([property color]) { } [tag foo] { }");
  13. MT("atMediaCheckStackInvalidAttribute",
  14. "[def @media] [attribute&error foobarhello] { } [tag foo] { }");
  15. // Error, because "and" is only allowed immediately preceding a media expression
  16. MT("atMediaInvalidAttribute",
  17. "[def @media] [attribute&error foobarhello] { }");
  18. // Error, because "and" is only allowed immediately preceding a media expression
  19. MT("atMediaInvalidAnd",
  20. "[def @media] [error and] [attribute screen] { }");
  21. // Error, because "not" is only allowed as the first item in each media query
  22. MT("atMediaInvalidNot",
  23. "[def @media] [attribute screen] [error not] ([error not]) { }");
  24. // Error, because "only" is only allowed as the first item in each media query
  25. MT("atMediaInvalidOnly",
  26. "[def @media] [attribute screen] [error only] ([error only]) { }");
  27. // Error, because "foobarhello" is neither a known type or property, but
  28. // property was expected (after "and"), and it should be in parenthese.
  29. MT("atMediaUnknownType",
  30. "[def @media] [attribute screen] [operator and] [error foobarhello] { }");
  31. // Error, because "color" is not a known type, but is a known property, and
  32. // should be in parentheses.
  33. MT("atMediaInvalidType",
  34. "[def @media] [attribute screen] [operator and] [error color] { }");
  35. // Error, because "print" is not a known property, but is a known type,
  36. // and should not be in parenthese.
  37. MT("atMediaInvalidProperty",
  38. "[def @media] [attribute screen] [operator and] ([error print]) { }");
  39. // Soft error, because "foobarhello" is not a known property or type.
  40. MT("atMediaUnknownProperty",
  41. "[def @media] [attribute screen] [operator and] ([property&error foobarhello]) { }");
  42. MT("tagSelector",
  43. "[tag foo] { }");
  44. MT("classSelector",
  45. "[qualifier .foo-bar_hello] { }");
  46. MT("idSelector",
  47. "[builtin #foo] { [error #foo] }");
  48. MT("tagSelectorUnclosed",
  49. "[tag foo] { [property margin][operator :] [number 0] } [tag bar] { }");
  50. MT("tagStringNoQuotes",
  51. "[tag foo] { [property font-family][operator :] [variable-2 hello] [variable-2 world]; }");
  52. MT("tagStringDouble",
  53. "[tag foo] { [property font-family][operator :] [string \"hello world\"]; }");
  54. MT("tagStringSingle",
  55. "[tag foo] { [property font-family][operator :] [string 'hello world']; }");
  56. MT("tagColorKeyword",
  57. "[tag foo] {" +
  58. "[property color][operator :] [keyword black];" +
  59. "[property color][operator :] [keyword navy];" +
  60. "[property color][operator :] [keyword yellow];" +
  61. "}");
  62. MT("tagColorHex3",
  63. "[tag foo] { [property background][operator :] [atom #fff]; }");
  64. MT("tagColorHex6",
  65. "[tag foo] { [property background][operator :] [atom #ffffff]; }");
  66. MT("tagColorHex4",
  67. "[tag foo] { [property background][operator :] [atom&error #ffff]; }");
  68. MT("tagColorHexInvalid",
  69. "[tag foo] { [property background][operator :] [atom&error #ffg]; }");
  70. MT("tagNegativeNumber",
  71. "[tag foo] { [property margin][operator :] [number -5px]; }");
  72. MT("tagPositiveNumber",
  73. "[tag foo] { [property padding][operator :] [number 5px]; }");
  74. MT("tagVendor",
  75. "[tag foo] { [meta -foo-][property box-sizing][operator :] [meta -foo-][string-2 border-box]; }");
  76. MT("tagBogusProperty",
  77. "[tag foo] { [property&error barhelloworld][operator :] [number 0]; }");
  78. MT("tagTwoProperties",
  79. "[tag foo] { [property margin][operator :] [number 0]; [property padding][operator :] [number 0]; }");
  80. MT("commentSGML",
  81. "[comment <!--comment-->]");
  82. })();