2 var mode = CodeMirror.getMode({tabSize: 4}, "css");
3 function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
5 // Requires at least one media query
7 "[def @media] [error {] }");
10 "[def @media] [keyword not] [attribute screen] [operator and] ([property color]), [keyword not] [attribute print] [operator and] ([property color]) { }");
12 MT("atMediaCheckStack",
13 "[def @media] [attribute screen] { } [tag foo] { }");
15 MT("atMediaCheckStack",
16 "[def @media] [attribute screen] ([property color]) { } [tag foo] { }");
18 MT("atMediaPropertyOnly",
19 "[def @media] ([property color]) { } [tag foo] { }");
21 MT("atMediaCheckStackInvalidAttribute",
22 "[def @media] [attribute&error foobarhello] { [tag foo] { } }");
24 MT("atMediaCheckStackInvalidAttribute",
25 "[def @media] [attribute&error foobarhello] { } [tag foo] { }");
27 // Error, because "and" is only allowed immediately preceding a media expression
28 MT("atMediaInvalidAttribute",
29 "[def @media] [attribute&error foobarhello] { }");
31 // Error, because "and" is only allowed immediately preceding a media expression
32 MT("atMediaInvalidAnd",
33 "[def @media] [error and] [attribute screen] { }");
35 // Error, because "not" is only allowed as the first item in each media query
36 MT("atMediaInvalidNot",
37 "[def @media] [attribute screen] [error not] ([error not]) { }");
39 // Error, because "only" is only allowed as the first item in each media query
40 MT("atMediaInvalidOnly",
41 "[def @media] [attribute screen] [error only] ([error only]) { }");
43 // Error, because "foobarhello" is neither a known type or property, but
44 // property was expected (after "and"), and it should be in parenthese.
45 MT("atMediaUnknownType",
46 "[def @media] [attribute screen] [operator and] [error foobarhello] { }");
48 // Error, because "color" is not a known type, but is a known property, and
49 // should be in parentheses.
50 MT("atMediaInvalidType",
51 "[def @media] [attribute screen] [operator and] [error color] { }");
53 // Error, because "print" is not a known property, but is a known type,
54 // and should not be in parenthese.
55 MT("atMediaInvalidProperty",
56 "[def @media] [attribute screen] [operator and] ([error print]) { }");
58 // Soft error, because "foobarhello" is not a known property or type.
59 MT("atMediaUnknownProperty",
60 "[def @media] [attribute screen] [operator and] ([property&error foobarhello]) { }");
62 // Make sure nesting works with media queries
63 MT("atMediaMaxWidthNested",
64 "[def @media] [attribute screen] [operator and] ([property max-width][operator :] [number 25px]) { [tag foo] { } }");
70 "[qualifier .foo-bar_hello] { }");
73 "[builtin #foo] { [error #foo] }");
75 MT("tagSelectorUnclosed",
76 "[tag foo] { [property margin][operator :] [number 0] } [tag bar] { }");
78 MT("tagStringNoQuotes",
79 "[tag foo] { [property font-family][operator :] [variable-2 hello] [variable-2 world]; }");
82 "[tag foo] { [property font-family][operator :] [string \"hello world\"]; }");
85 "[tag foo] { [property font-family][operator :] [string 'hello world']; }");
89 "[property color][operator :] [keyword black];" +
90 "[property color][operator :] [keyword navy];" +
91 "[property color][operator :] [keyword yellow];" +
95 "[tag foo] { [property background][operator :] [atom #fff]; }");
98 "[tag foo] { [property background][operator :] [atom #ffffff]; }");
101 "[tag foo] { [property background][operator :] [atom&error #ffff]; }");
103 MT("tagColorHexInvalid",
104 "[tag foo] { [property background][operator :] [atom&error #ffg]; }");
106 MT("tagNegativeNumber",
107 "[tag foo] { [property margin][operator :] [number -5px]; }");
109 MT("tagPositiveNumber",
110 "[tag foo] { [property padding][operator :] [number 5px]; }");
113 "[tag foo] { [meta -foo-][property box-sizing][operator :] [meta -foo-][string-2 border-box]; }");
115 MT("tagBogusProperty",
116 "[tag foo] { [property&error barhelloworld][operator :] [number 0]; }");
118 MT("tagTwoProperties",
119 "[tag foo] { [property margin][operator :] [number 0]; [property padding][operator :] [number 0]; }");
121 MT("tagTwoPropertiesURL",
122 "[tag foo] { [property background][operator :] [string-2 url]([string //example.com/foo.png]); [property padding][operator :] [number 0]; }");
125 "[comment <!--comment-->]");