summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/scroll-animations/css/animation-shorthand.html
blob: b7d5947a212b67a5e9a0ce1b53785b562e622554 (plain)
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<!DOCTYPE html>
<link rel="help" href="https://drafts.csswg.org/css-animations-2/#animation-shorthand">
<link rel="help" href="https://drafts.csswg.org/css-animations-2/#animation-timeline">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/css/support/computed-testcommon.js"></script>
<script src="/css/support/parsing-testcommon.js"></script>
<script src="/css/support/shorthand-testcommon.js"></script>
<div id="target"></div>
<script>
test_valid_value('animation',
  '1s linear 1s 2 reverse forwards paused anim');

test_invalid_value('animation',
  '1s linear 1s 2 reverse forwards paused anim initial');
test_invalid_value('animation',
  '1s linear 1s 2 reverse forwards paused anim 2000');
test_invalid_value('animation',
  '1s linear 1s 2 reverse forwards paused anim scroll()');
test_invalid_value('animation',
  '1s linear 1s 2 reverse forwards paused anim view()');
test_invalid_value('animation',
  '1s linear 1s 2 reverse forwards paused anim timeline');

test_computed_value('animation',
  '1s linear 1s 2 reverse forwards paused anim');

test_shorthand_value('animation',
  `1s linear 1s 2 reverse forwards paused anim1,
   1s linear 1s 2 reverse forwards paused anim2,
   1s linear 1s 2 reverse forwards paused anim3`,
{
  'animation-duration': '1s, 1s, 1s',
  'animation-timing-function': 'linear, linear, linear',
  'animation-delay': '1s, 1s, 1s',
  'animation-iteration-count': '2, 2, 2',
  'animation-direction': 'reverse, reverse, reverse',
  'animation-fill-mode': 'forwards, forwards, forwards',
  'animation-play-state': 'paused, paused, paused',
  'animation-name': 'anim1, anim2, anim3',
  'animation-timeline': 'auto',
  'animation-range-start': 'normal',
  'animation-range-end': 'normal',
});

test((t) => {
  t.add_cleanup(() => {
    target.style = '';
  });

  target.style.animation = 'anim 1s';
  target.style.animationTimeline = '--timeline';
  assert_equals(target.style.animation, '');
  assert_equals(target.style.animationName, 'anim');
  assert_equals(target.style.animationDuration, '1s');

  target.style.animationTimeline = 'auto, auto';
  assert_equals(target.style.animation, '');
}, 'Animation shorthand can not represent non-initial timelines (specified)');

test((t) => {
  t.add_cleanup(() => {
    target.style = '';
  });

  target.style.animation = 'anim 1s';
  target.style.animationTimeline = '--timeline';
  assert_equals(getComputedStyle(target).animation, '');
  assert_equals(getComputedStyle(target).animationName, 'anim');
  assert_equals(getComputedStyle(target).animationDuration, '1s');

  target.style.animationTimeline = 'auto, auto';
  assert_equals(getComputedStyle(target).animation, '');
}, 'Animation shorthand can not represent non-initial timelines (computed)');

test((t) => {
  t.add_cleanup(() => {
    target.style = '';
  });

  target.style.animation = 'anim 1s';
  target.style.animationDelayEnd = '42s';
  assert_equals(target.style.animation, '');
  assert_equals(target.style.animationName, 'anim');
  assert_equals(target.style.animationDuration, '1s');

  target.style.animationDelayEnd = '0s, 0s';
  assert_equals(target.style.animation, '');
}, 'Animation shorthand can not represent non-initial animation-delay-end (specified)');

test((t) => {
  t.add_cleanup(() => {
    target.style = '';
  });

  target.style.animation = 'anim 1s';
  target.style.animationDelayEnd = '42s';
  assert_equals(getComputedStyle(target).animation, '');
  assert_equals(getComputedStyle(target).animationName, 'anim');
  assert_equals(getComputedStyle(target).animationDuration, '1s');

  target.style.animationDelayEnd = '0s, 0s';
  assert_equals(getComputedStyle(target).animation, '');
}, 'Animation shorthand can not represent non-initial animation-delay-end (computed)');

test((t) => {
  t.add_cleanup(() => {
    target.style = '';
  });

  target.style.animation = 'anim 1s';
  target.style.animationRangeStart = 'entry';
  assert_equals(target.style.animation, '');
  assert_equals(target.style.animationName, 'anim');
  assert_equals(target.style.animationDuration, '1s');

  target.style.animationRangeStart = 'normal, normal';
  assert_equals(target.style.animation, '');
}, 'Animation shorthand can not represent non-initial animation-range-start (specified)');

test((t) => {
  t.add_cleanup(() => {
    target.style = '';
  });

  target.style.animation = 'anim 1s';
  target.style.animationRangeStart = 'entry';
  assert_equals(getComputedStyle(target).animation, '');
  assert_equals(getComputedStyle(target).animationName, 'anim');
  assert_equals(getComputedStyle(target).animationDuration, '1s');

  target.style.animationRangeStart = 'normal, normal';
  assert_equals(getComputedStyle(target).animation, '');
}, 'Animation shorthand can not represent non-initial animation-range-start (computed)');

test((t) => {
  t.add_cleanup(() => {
    target.style = '';
  });

  target.style.animation = 'anim 1s';
  target.style.animationRangeEnd = 'entry';
  assert_equals(target.style.animation, '');
  assert_equals(target.style.animationName, 'anim');
  assert_equals(target.style.animationDuration, '1s');

  target.style.animationRangeEnd = 'normal, normal';
  assert_equals(target.style.animation, '');
}, 'Animation shorthand can not represent non-initial animation-range-end (specified)');

test((t) => {
  t.add_cleanup(() => {
    target.style = '';
  });

  target.style.animation = 'anim 1s';
  target.style.animationRangeEnd = 'entry';
  assert_equals(getComputedStyle(target).animation, '');
  assert_equals(getComputedStyle(target).animationName, 'anim');
  assert_equals(getComputedStyle(target).animationDuration, '1s');

  target.style.animationRangeEnd = 'normal, normal';
  assert_equals(getComputedStyle(target).animation, '');
}, 'Animation shorthand can not represent non-initial animation-range-end (computed)');

</script>