File: at-function-parsing.html

package info (click to toggle)
thunderbird 1%3A144.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 4,725,312 kB
  • sloc: cpp: 7,869,225; javascript: 5,974,276; ansic: 3,946,747; python: 1,421,062; xml: 654,642; asm: 474,045; java: 183,117; sh: 110,973; makefile: 20,398; perl: 14,362; objc: 13,086; yacc: 4,583; pascal: 3,448; lex: 1,720; ruby: 999; exp: 762; sql: 731; awk: 580; php: 436; lisp: 430; sed: 69; csh: 10
file content (130 lines) | stat: -rw-r--r-- 6,210 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<!DOCTYPE html>
<title>Custom Functions: Prelude Parsing</title>
<link rel="help" href="https://drafts.csswg.org/css-mixins-1/#function-rule">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
  function test_valid_prelude(rule_without_block) {
    test(() => {
      let s = new CSSStyleSheet();
      s.replaceSync(`${rule_without_block} {}`);
      assert_equals(s.cssRules.length, 1);
    }, `${rule_without_block} is valid`);
  }

  function test_invalid_prelude(rule_without_block) {
    test(() => {
      let s = new CSSStyleSheet();
      s.replaceSync(`${rule_without_block} {}`);
      assert_equals(s.cssRules.length, 0);
    }, `${rule_without_block} is invalid`);
  }

  test_valid_prelude('@function --foo()');
  test_valid_prelude('@function --foo( )');
  test_valid_prelude('@function --foo(--x)');
  test_valid_prelude('@function --foo( --x )');

  test_invalid_prelude('@function --foo ()');
  test_invalid_prelude('@function --foo (--x)');

  // All single <syntax-component> types.
  test_valid_prelude('@function --foo(--x auto)');
  test_valid_prelude('@function --foo(--x <angle>)');
  test_valid_prelude('@function --foo(--x <color>)');
  test_valid_prelude('@function --foo(--x <custom-ident>)');
  test_valid_prelude('@function --foo(--x <image>)');
  test_valid_prelude('@function --foo(--x <integer>)');
  test_valid_prelude('@function --foo(--x <length>)');
  test_valid_prelude('@function --foo(--x <length-percentage>)');
  test_valid_prelude('@function --foo(--x <number>)');
  test_valid_prelude('@function --foo(--x <percentage>)');
  test_valid_prelude('@function --foo(--x <resolution>)');
  test_valid_prelude('@function --foo(--x <string>)');
  test_valid_prelude('@function --foo(--x <time>)');
  test_valid_prelude('@function --foo(--x <url>)');
  test_valid_prelude('@function --foo(--x <transform-function>)');
  test_valid_prelude('@function --foo(--x <transform-list>)');

  test_valid_prelude('@function --foo(--x type(auto))');
  test_valid_prelude('@function --foo(--x type(<length>))');
  test_valid_prelude('@function --foo(--x type(<length> | auto))');
  test_valid_prelude('@function --foo(--x type(none | auto))');
  test_valid_prelude('@function --foo(--x type(*))');

  // Multiple parameters.
  test_valid_prelude('@function --foo(--x, --y)');
  test_valid_prelude('@function --foo(--x, --y, --z)');
  test_valid_prelude('@function --foo(--x <length>, --y, --z)');
  test_valid_prelude('@function --foo(--x, --y <number>, --z <angle>)');

  // Defaults.
  test_valid_prelude('@function --foo(--x : 10px)');
  test_valid_prelude('@function --foo(--x type(*): 10px)');
  test_valid_prelude('@function --foo(--x <length>: 10px)');
  test_valid_prelude('@function --foo(--x <length>: 10px, --y)');
  test_valid_prelude('@function --foo(--x, --y <length>: 10px)');
  test_valid_prelude('@function --foo(--x type(<length> | auto): auto)');
  test_valid_prelude('@function --foo(--x type(<length> | auto) : auto)');
  // A parameter without a default may appear after a parameter with
  // a default, even though there's no way to actually call --foo()
  // with just --y:
  test_valid_prelude('@function --foo(--x:1px, --y, --z:2px)');

  test_invalid_prelude('@function --foo(--x: 10px !important)');

  // Default type mismatch.
  test_invalid_prelude('@function --foo(--x <length>: 10deg)');
  test_invalid_prelude('@function --foo(--x <angle>: 10px)');
  test_invalid_prelude('@function --foo(--x <color>: 10px)');
  test_invalid_prelude('@function --foo(--x type(<color>+): red 5)');
  test_invalid_prelude('@function --foo(--x type(auto | none): thing)');

  // Lists.
  test_valid_prelude('@function --foo(--x <length>#)');
  test_valid_prelude('@function --foo(--x <length>+)');
  test_valid_prelude('@function --foo(--x type(<length>+))');
  test_valid_prelude('@function --foo(--x <transform-function>#)');
  test_valid_prelude('@function --foo(--x <transform-function>+)');
  // <transform-list> is special: a multiplier cannot follow it.
  test_invalid_prelude('@function --foo(--x <transform-list>#)');
  test_invalid_prelude('@function --foo(--x <transform-list>+)');

  test_invalid_prelude('@function --foo(--x *)');
  test_invalid_prelude('@function --foo(--x !)');
  test_invalid_prelude('@function --foo(--x 50px)');
  test_invalid_prelude('@function --foo(--x <length> | auto)');
  test_invalid_prelude('@function --foo(--x none | auto)');
  test_invalid_prelude('@function --foo(--x <dino>)');
  test_invalid_prelude('@function --foo(!)');
  test_invalid_prelude('@function --foo(--x: !)');
  test_invalid_prelude('@function --foo(--x type(!))');
  test_invalid_prelude('@function --foo(,)');
  test_invalid_prelude('@function --foo(,,,)');
  test_invalid_prelude('@function --foo(--x, ;)');
  test_invalid_prelude('@function --foo(;)');
  test_invalid_prelude('@function --foo(])');
  test_invalid_prelude('@function --foo(, --x])');

  // Return value types.
  test_valid_prelude('@function --foo(--x) returns type(*)');
  test_valid_prelude('@function --foo(--x) returns <length>');
  test_valid_prelude('@function --foo(--x) returns <length>+');
  test_valid_prelude('@function --foo(--x) returns type(<length>)');
  test_valid_prelude('@function --foo(--x) returns type(<length> | auto)');
  test_valid_prelude('@function --foo(--x) returns type(foo | bar)');

  test_invalid_prelude('@function --foo(--x) !');
  test_invalid_prelude('@function --foo(--x) ! <length>');
  test_invalid_prelude('@function --foo(--x) returns <length>!');
  test_invalid_prelude('@function --foo(--x) length');
  test_invalid_prelude('@function --foo(--x) returns');
  test_invalid_prelude('@function --foo(--x) returns ');
  test_invalid_prelude('@function --foo(--x) returns *');
  test_invalid_prelude('@function --foo(--x) returns <transform-list>#');
  test_invalid_prelude('@function --foo(--x) returns <transform-list>+');
  test_invalid_prelude('@function --foo(--x) returns auto | none');
  test_invalid_prelude('@function --foo(--x): <length>');
  test_invalid_prelude('@function --foo(--x): length');
  test_invalid_prelude('@function --foo(--x) returneth <length>');
</script>