summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/css/css-animations/KeyframeEffect-getKeyframes.tentative.html
blob: 6de6e318adee4a4415f7335bc4c4d586d4cbbbc8 (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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
<!doctype html>
<meta charset=utf-8>
<title>KeyframeEffect.getKeyframes() for CSS animations</title>
<!-- TODO: Add a more specific link for this once it is specified. -->
<link rel="help" href="https://drafts.csswg.org/css-animations-2/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support/testcommon.js"></script>
<style>
@keyframes anim-empty { }

@keyframes anim-empty-frames {
  from { }
  to   { }
}

@keyframes anim-only-timing {
  from { animation-timing-function: linear; }
  to   { }
}

@keyframes anim-only-non-animatable {
  from { animation-duration: 3s; }
  to   { animation-duration: 5s; }
}

@keyframes anim-simple {
  from { color: rgb(0, 0, 0); }
  to   { color: rgb(255, 255, 255); }
}

@keyframes anim-simple-three {
  from { color: rgb(0, 0, 0); }
  50%  { color: rgb(0, 0, 255); }
  to   { color: rgb(255, 255, 255); }
}

@keyframes anim-simple-timing {
  from { color: rgb(0, 0, 0); animation-timing-function: linear; }
  50%  { color: rgb(0, 0, 255); animation-timing-function: ease-in-out; }
  to   { color: rgb(255, 255, 255); animation-timing-function: step-end; }
}

@keyframes anim-simple-timing-some {
  from { color: rgb(0, 0, 0); animation-timing-function: linear; }
  50%  { color: rgb(0, 0, 255); }
  to   { color: rgb(255, 255, 255); }
}

@keyframes anim-simple-composite {
  from { color: rgb(0, 0, 0); animation-composition: replace; }
  50%  { color: rgb(0, 0, 255); animation-composition: add; }
  to   { color: rgb(255, 255, 255); animation-composition: accumulate; }
}

@keyframes anim-simple-composite-some {
  from { color: rgb(0, 0, 0); animation-composition: add; }
  50%  { color: rgb(0, 0, 255); }
  to   { color: rgb(255, 255, 255); }
}

@keyframes anim-simple-shorthand {
  from { margin: 8px; }
  to   { margin: 16px; }
}

@keyframes anim-omit-to {
  from { color: rgb(0, 0, 255); }
}

@keyframes anim-omit-from {
  to   { color: rgb(0, 0, 255); }
}

@keyframes anim-omit-from-to {
  50%  { color: rgb(0, 0, 255); }
}

@keyframes anim-partially-omit-to {
  from { margin-top: 50px;
         margin-bottom: 100px; }
  to   { margin-top: 150px !important; /* ignored */
         margin-bottom: 200px; }
}

@keyframes anim-different-props {
  from { color: rgb(0, 0, 0); margin-top: 8px; }
  25%  { color: rgb(0, 0, 255); }
  75%  { margin-top: 12px; }
  to   { color: rgb(255, 255, 255); margin-top: 16px }
}

@keyframes anim-different-props-and-easing {
  from { color: rgb(0, 0, 0); margin-top: 8px; animation-timing-function: linear; }
  25%  { color: rgb(0, 0, 255); animation-timing-function: step-end; }
  75%  { margin-top: 12px; animation-timing-function: ease-in; }
  to   { color: rgb(255, 255, 255); margin-top: 16px }
}

@keyframes anim-merge-offset {
  from { color: rgb(0, 0, 0); }
  to   { color: rgb(255, 255, 255); }
  from { margin-top: 8px; }
  to   { margin-top: 16px; }
}

@keyframes anim-merge-offset-and-easing {
  from { color: rgb(0, 0, 0); animation-timing-function: step-end; }
  to   { color: rgb(255, 255, 255); }
  from { margin-top: 8px; animation-timing-function: linear; }
  to   { margin-top: 16px; }
  from { font-size: 16px; animation-timing-function: step-end; }
  to   { font-size: 32px; }
  from { padding-left: 2px; animation-timing-function: linear; }
  to   { padding-left: 4px; }
}

@keyframes anim-no-merge-equiv-easing {
  from { margin-top: 0px; animation-timing-function: steps(1, end); }
  from { margin-right: 0px; animation-timing-function: step-end; }
  from { margin-bottom: 0px; animation-timing-function: steps(1); }
  50%  { margin-top: 10px; animation-timing-function: step-end; }
  50%  { margin-right: 10px; animation-timing-function: step-end; }
  50%  { margin-bottom: 10px; animation-timing-function: step-end; }
  to   { margin-top: 20px; margin-right: 20px; margin-bottom: 20px; }
}

@keyframes anim-merge-offset-and-composite {
  from { color: rgb(0, 0, 0); animation-composition: add; }
  to   { color: rgb(255, 255, 255); }
  from { margin-top: 8px; animation-composition: accumulate; }
  to   { margin-top: 16px; }
  from { font-size: 16px; animation-composition: add; }
  to   { font-size: 32px; }
  from { padding-left: 2px; animation-composition: accumulate; }
  to   { padding-left: 4px; }
}

@keyframes anim-merge-offset-easing-and-composite {
  from { color: rgb(0, 0, 0); animation-composition: add; }
  to   { color: rgb(255, 255, 255); }
  from { margin-top: 8px; animation-composition: accumulate; }
  to   { margin-top: 16px; }
  from { font-size: 16px; animation-composition: add; animation-timing-function: linear; }
  to   { font-size: 32px; }
  from { padding-left: 2px; animation-composition: accumulate; }
  to   { padding-left: 4px; }
}

@keyframes anim-overriding {
  from          { padding-top: 50px }
  50%, from     { padding-top: 30px } /* wins: 0% */
  75%, 85%, 50% { padding-top: 20px } /* wins: 75%, 50% */
  100%, 85%     { padding-top: 70px } /* wins: 100% */
  85.1%         { padding-top: 60px } /* wins: 85.1% */
  85%           { padding-top: 30px } /* wins: 85% */
}

@keyframes anim-filter {
  to { filter: blur(5px) sepia(60%) saturate(30%); }
}

@keyframes anim-filter-drop-shadow {
  from { filter: drop-shadow(10px 10px 10px rgb(0, 255, 0)); }
  to { filter: drop-shadow(50px 30px 10px rgb(255, 0, 0)); }
}

@keyframes anim-text-shadow {
  to { text-shadow: none; }
}

@keyframes anim-background-size {
  to { background-size: 50%, 6px, contain }
}

:root {
  --var-100px: 100px;
  --end-color: rgb(255, 0, 0);
}
@keyframes anim-variables {
  to { transform: translate(var(--var-100px), 0) }
}
@keyframes anim-variables-shorthand {
  to { margin: var(--var-100px) }
}
@keyframes anim-custom-property-in-keyframe {
  to { --end-color: rgb(0, 255, 0); color: var(--end-color) }
}
@keyframes anim-only-custom-property-in-keyframe {
  from { transform: translate(100px, 0) }
  to { --not-used: 200px }
}

@keyframes anim-only-timing-function-for-from-and-to {
    from, to { animation-timing-function: linear }
    50% { left: 10px }
}

</style>
<body>
<div id="log"></div>
<script>
"use strict";

const getKeyframes = elem => elem.getAnimations()[0].effect.getKeyframes();

// animation-timing-function values to test with, where the value
// is exactly the same as its serialization, sorted by the order
// getKeyframes() will group frames with the same easing function
// together (by nsTimingFunction::Compare).
const kTimingFunctionValues = [
  "ease",
  "linear",
  "ease-in",
  "ease-out",
  "ease-in-out",
  "steps(1, start)",
  "steps(2, start)",
  "steps(1)",
  "steps(2)",
  "cubic-bezier(0, 0, 1, 1)",
  "cubic-bezier(0, 0.25, 0.75, 1)"
];

const kCompositeValues = [
  "replace",
  "add",
  "accumulate"
];

test(t => {
  const div = addDiv(t);

  div.style.animation = 'anim-empty 100s';
  assert_equals(getKeyframes(div).length, 0,
                "number of frames with empty @keyframes");

  div.style.animation = 'anim-empty-frames 100s';
  assert_equals(getKeyframes(div).length, 0,
                "number of frames when @keyframes has empty keyframes");

  div.style.animation = 'anim-only-timing 100s';
  assert_equals(getKeyframes(div).length, 0,
                "number of frames when @keyframes only has keyframes with " +
                "animation-timing-function");

  div.style.animation = 'anim-only-non-animatable 100s';
  assert_equals(getKeyframes(div).length, 0,
                "number of frames when @keyframes only has frames with " +
                "non-animatable properties");
}, 'KeyframeEffect.getKeyframes() returns no frames for various kinds'
   + ' of empty animations');

test(t => {
  const div = addDiv(t);
  div.style.animation = 'anim-simple 100s';

  const frames = getKeyframes(div);

  const expected = [
    { offset: 0, computedOffset: 0, easing: "ease",
      color: "rgb(0, 0, 0)", composite: "auto" },
    { offset: 1, computedOffset: 1, easing: "ease",
      color: "rgb(255, 255, 255)", composite: "auto" },
  ];
  assert_frame_lists_equal(frames, expected);
}, 'KeyframeEffect.getKeyframes() returns expected frames for a simple'
   + ' animation');

test(t => {
  for (const easing of kTimingFunctionValues) {
    const div = addDiv(t);

    div.style.animation = 'anim-simple-three 100s ' + easing;
    const frames = getKeyframes(div);

    assert_equals(frames.length, 3, "number of frames");

    for (let i = 0; i < frames.length; i++) {
      assert_equals(frames[i].easing, easing,
                    "value for 'easing' on ComputedKeyframe #" + i);
    }
  }
}, 'KeyframeEffect.getKeyframes() returns frames with expected easing'
   + ' values, when the easing comes from animation-timing-function on the'
   + ' element');

test(t => {
  const div = addDiv(t);

  div.style.animation = 'anim-simple-timing 100s';
  const frames = getKeyframes(div);

  assert_equals(frames.length, 3, "number of frames");
  assert_equals(frames[0].easing, "linear",
                "value of 'easing' on ComputedKeyframe #0");
  assert_equals(frames[1].easing, "ease-in-out",
                "value of 'easing' on ComputedKeyframe #1");
  assert_equals(frames[2].easing, "steps(1)",
                "value of 'easing' on ComputedKeyframe #2");
}, 'KeyframeEffect.getKeyframes() returns frames with expected easing'
   + ' values, when the easing is specified on each keyframe');

test(t => {
  const div = addDiv(t);

  div.style.animation = 'anim-simple-timing-some 100s step-start';
  const frames = getKeyframes(div);

  assert_equals(frames.length, 3, "number of frames");
  assert_equals(frames[0].easing, "linear",
                "value of 'easing' on ComputedKeyframe #0");
  assert_equals(frames[1].easing, "steps(1, start)",
                "value of 'easing' on ComputedKeyframe #1");
  assert_equals(frames[2].easing, "steps(1, start)",
                "value of 'easing' on ComputedKeyframe #2");
}, 'KeyframeEffect.getKeyframes() returns frames with expected easing'
   + ' values, when the easing is specified on some keyframes');

test(t => {
  for (const composite of kCompositeValues) {
    const div = addDiv(t);

    div.style.animation = 'anim-simple-three 100s';
    div.style.animationComposition = composite;
    const frames = getKeyframes(div);

    assert_equals(frames.length, 3, "number of frames");

    for (let i = 0; i < frames.length; i++) {
      assert_equals(frames[i].composite, "auto",
                    "value for 'composite' on ComputedKeyframe #" + i);
    }
  }
}, 'KeyframeEffect.getKeyframes() returns frames with expected composite'
   + ' values, when the composite is set on the effect using animation-composition on the'
   + ' element');

test(t => {
  const div = addDiv(t);

  div.style.animation = 'anim-simple-composite 100s';
  const frames = getKeyframes(div);

  assert_equals(frames.length, 3, "number of frames");
  assert_equals(frames[0].composite, "replace",
                "value of 'composite' on ComputedKeyframe #0");
  assert_equals(frames[1].composite, "add",
                "value of 'composite' on ComputedKeyframe #1");
  assert_equals(frames[2].composite, "accumulate",
                "value of 'composite' on ComputedKeyframe #2");
}, 'KeyframeEffect.getKeyframes() returns frames with expected composite'
   + ' values, when the composite is specified on each keyframe');

test(t => {
  const div = addDiv(t);

  div.style.animation = 'anim-simple-composite-some 100s';
  div.style.animationComposition = 'accumulate';
  const frames = getKeyframes(div);

  assert_equals(frames.length, 3, "number of frames");
  assert_equals(frames[0].composite, "add",
                "value of 'composite' on ComputedKeyframe #0");
  assert_equals(frames[1].composite, "auto",
                "value of 'composite' on ComputedKeyframe #1");
  assert_equals(frames[2].composite, "auto",
                "value of 'composite' on ComputedKeyframe #2");
}, 'KeyframeEffect.getKeyframes() returns frames with expected composite'
   + ' values, when the composite is specified on some keyframes');

test(t => {
  const div = addDiv(t);
  div.style.animation = 'anim-simple-shorthand 100s';

  const frames = getKeyframes(div);

  const expected = [
    { offset: 0, computedOffset: 0, easing: "ease", composite: "auto",
      marginBottom: "8px", marginLeft: "8px",
      marginRight: "8px", marginTop: "8px" },
    { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",
      marginBottom: "16px", marginLeft: "16px",
      marginRight: "16px", marginTop: "16px" },
  ];
  assert_frame_lists_equal(frames, expected);
}, 'KeyframeEffect.getKeyframes() returns expected frames for a simple'
   + ' animation that specifies a single shorthand property');

test(t => {
  const div = addDiv(t);
  div.style.animation = 'anim-omit-to 100s';
  div.style.color = 'rgb(255, 255, 255)';

  const frames = getKeyframes(div);

  // Final keyframe should be replace as per sections 7 and 8 of
  // https://drafts.csswg.org/css-animations-2/#keyframes
  const expected = [
    { offset: 0, computedOffset: 0, easing: "ease", composite: "auto",
      color: "rgb(0, 0, 255)" },
    { offset: 1, computedOffset: 1, easing: "ease", composite: "replace",
      color: "rgb(255, 255, 255)" },
  ];
  assert_frame_lists_equal(frames, expected);
}, 'KeyframeEffect.getKeyframes() returns expected frames for an ' +
   'animation with a 0% keyframe and no 100% keyframe');

test(t => {
  const div = addDiv(t);
  div.style.animation = 'anim-omit-from 100s';
  div.style.color = 'rgb(255, 255, 255)';

  const frames = getKeyframes(div);

  // Initial keyframe should be replace as per sections 7 and 8 of
  // https://drafts.csswg.org/css-animations-2/#keyframes
  const expected = [
    { offset: 0, computedOffset: 0, easing: "ease", composite: "replace",
      color: "rgb(255, 255, 255)" },
    { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",
      color: "rgb(0, 0, 255)" },
  ];
  assert_frame_lists_equal(frames, expected);
}, 'KeyframeEffect.getKeyframes() returns expected frames for an ' +
   'animation with a 100% keyframe and no 0% keyframe');

test(t => {
  const div = addDiv(t);
  div.style.animation = 'anim-omit-from-to 100s';
  div.style.color = 'rgb(255, 255, 255)';

  const frames = getKeyframes(div);

  // Initial and final keyframes should be replace as per sections 7 and 8 of
  // https://drafts.csswg.org/css-animations-2/#keyframes
  const expected = [
    { offset: 0,   computedOffset: 0,   easing: "ease", composite: "replace",
      color: "rgb(255, 255, 255)" },
    { offset: 0.5, computedOffset: 0.5, easing: "ease", composite: "auto",
      color: "rgb(0, 0, 255)" },
    { offset: 1,   computedOffset: 1,   easing: "ease", composite: "replace",
      color: "rgb(255, 255, 255)" },
  ];
  assert_frame_lists_equal(frames, expected);
}, 'KeyframeEffect.getKeyframes() returns expected frames for an ' +
   'animation with no 0% or 100% keyframe but with a 50% keyframe');

test(t => {
  const div = addDiv(t);
  div.style.animation = 'anim-partially-omit-to 100s';
  div.style.marginTop = '250px';

  const frames = getKeyframes(div);

  const expected = [
    { offset: 0, computedOffset: 0, easing: "ease", composite: "auto",
      marginTop: '50px', marginBottom: '100px' },
    { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",
      marginTop: '250px', marginBottom: '200px' },
  ];
  assert_frame_lists_equal(frames, expected);
}, 'KeyframeEffect.getKeyframes() returns expected frames for an ' +
   'animation with a partially complete 100% keyframe (because the ' +
   '!important rule is ignored)');

test(t => {
  const div = addDiv(t);
  div.style.animation = 'anim-different-props 100s';

  const frames = getKeyframes(div);

  const expected = [
    { offset: 0, computedOffset: 0, easing: "ease", composite: "auto",
      color: "rgb(0, 0, 0)", marginTop: "8px" },
    { offset: 0.25, computedOffset: 0.25, easing: "ease", composite: "auto",
      color: "rgb(0, 0, 255)" },
    { offset: 0.75, computedOffset: 0.75, easing: "ease", composite: "auto",
      marginTop: "12px" },
    { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",
      color: "rgb(255, 255, 255)", marginTop: "16px" },
  ];
  assert_frame_lists_equal(frames, expected);
}, 'KeyframeEffect.getKeyframes() returns expected frames for an ' +
   'animation with different properties on different keyframes, all ' +
   'with the same easing function');

test(t => {
  const div = addDiv(t);
  div.style.animation = 'anim-different-props-and-easing 100s';

  const frames = getKeyframes(div);

  const expected = [
    { offset: 0, computedOffset: 0, easing: "linear", composite: "auto",
      color: "rgb(0, 0, 0)", marginTop: "8px" },
    { offset: 0.25, computedOffset: 0.25, easing: "steps(1)", composite: "auto",
      color: "rgb(0, 0, 255)" },
    { offset: 0.75, computedOffset: 0.75, easing: "ease-in", composite: "auto",
      marginTop: "12px" },
    { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",
      color: "rgb(255, 255, 255)", marginTop: "16px" },
  ];
  assert_frame_lists_equal(frames, expected);
}, 'KeyframeEffect.getKeyframes() returns expected frames for an ' +
   'animation with different properties on different keyframes, with ' +
   'a different easing function on each');

test(t => {
  const div = addDiv(t);
  div.style.animation = 'anim-merge-offset 100s';

  const frames = getKeyframes(div);

  const expected = [
    { offset: 0, computedOffset: 0, easing: "ease", composite: "auto",
      color: "rgb(0, 0, 0)", marginTop: "8px" },
    { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",
      color: "rgb(255, 255, 255)", marginTop: "16px" },
  ];
  assert_frame_lists_equal(frames, expected);
}, 'KeyframeEffect.getKeyframes() returns expected frames for an ' +
   'animation with multiple keyframes for the same time, and all with ' +
   'the same easing function');

test(t => {
  const div = addDiv(t);
  div.style.animation = 'anim-merge-offset-and-easing 100s';

  const frames = getKeyframes(div);

  const expected = [
    { offset: 0, computedOffset: 0, easing: "steps(1)", composite: "auto",
      color: "rgb(0, 0, 0)", fontSize: "16px" },
    { offset: 0, computedOffset: 0, easing: "linear", composite: "auto",
      marginTop: "8px", paddingLeft: "2px" },
    { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",
      color: "rgb(255, 255, 255)", fontSize: "32px", marginTop: "16px",
      paddingLeft: "4px" },
  ];
  assert_frame_lists_equal(frames, expected);
}, 'KeyframeEffect.getKeyframes() returns expected frames for an ' +
   'animation with multiple keyframes for the same time and with ' +
   'different easing functions');

test(t => {
  const div = addDiv(t);
  div.style.animation = 'anim-no-merge-equiv-easing 100s';

  const frames = getKeyframes(div);

  const expected = [
    { offset: 0, computedOffset: 0, easing: "steps(1)", composite: "auto",
      marginTop: "0px", marginRight: "0px", marginBottom: "0px" },
    { offset: 0.5, computedOffset: 0.5, easing: "steps(1)", composite: "auto",
      marginTop: "10px", marginRight: "10px", marginBottom: "10px" },
    { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",
      marginTop: "20px", marginRight: "20px", marginBottom: "20px" },
  ];
  assert_frame_lists_equal(frames, expected);
}, 'KeyframeEffect.getKeyframes() returns expected frames for an ' +
   'animation with multiple keyframes for the same time and with ' +
   'different but equivalent easing functions');

test(t => {
  const div = addDiv(t);
  div.style.animation = 'anim-merge-offset-and-composite 100s';

  const frames = getKeyframes(div);

  const expected = [
    { offset: 0, computedOffset: 0, easing: "ease", composite: "add",
      color: "rgb(0, 0, 0)", fontSize: "16px" },
    { offset: 0, computedOffset: 0, easing: "ease", composite: "accumulate",
      marginTop: "8px", paddingLeft: "2px" },
    { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",
      color: "rgb(255, 255, 255)", fontSize: "32px", marginTop: "16px",
      paddingLeft: "4px" },
  ];
  assert_frame_lists_equal(frames, expected);
}, 'KeyframeEffect.getKeyframes() returns expected frames for an ' +
   'animation with multiple keyframes for the same time and with ' +
   'different composite operations');

test(t => {
  const div = addDiv(t);
  div.style.animation = 'anim-merge-offset-easing-and-composite 100s';

  const frames = getKeyframes(div);

  const expected = [
    { offset: 0, computedOffset: 0, easing: "ease", composite: "add",
      color: "rgb(0, 0, 0)" },
    { offset: 0, computedOffset: 0, easing: "ease", composite: "accumulate",
      marginTop: "8px", paddingLeft: "2px" },
    { offset: 0, computedOffset: 0, easing: "linear", composite: "add",
      fontSize: "16px" },
    { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",
      color: "rgb(255, 255, 255)", fontSize: "32px", marginTop: "16px",
      paddingLeft: "4px" },
  ];
  assert_frame_lists_equal(frames, expected);
}, 'KeyframeEffect.getKeyframes() returns expected frames for an ' +
   'animation with multiple keyframes for the same time and with ' +
   'different easing functions and composite operations');

test(t => {
  const div = addDiv(t);
  div.style.animation = 'anim-overriding 100s';

  const frames = getKeyframes(div);

  const expected = [
    { offset: 0, computedOffset: 0, easing: "ease", composite: "auto",
      paddingTop: "30px" },
    { offset: 0.5, computedOffset: 0.5, easing: "ease", composite: "auto",
      paddingTop: "20px" },
    { offset: 0.75, computedOffset: 0.75, easing: "ease", composite: "auto",
      paddingTop: "20px" },
    { offset: 0.85, computedOffset: 0.85, easing: "ease", composite: "auto",
      paddingTop: "30px" },
    { offset: 0.851, computedOffset: 0.851, easing: "ease", composite: "auto",
      paddingTop: "60px" },
    { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",
      paddingTop: "70px" },
  ];
  assert_frame_lists_equal(frames, expected);
}, 'KeyframeEffect.getKeyframes() returns expected frames for ' +
   'overlapping keyframes');

// Gecko-specific test case: We are specifically concerned here that the
// computed value for filter, "none", is correctly represented.

test(t => {
  const div = addDiv(t);
  div.style.animation = 'anim-filter 100s';

  const frames = getKeyframes(div);

  // Initial keyframe should be replace as per sections 7 and 8 of
  // https://drafts.csswg.org/css-animations-2/#keyframes
  const expected = [
    { offset: 0, computedOffset: 0, easing: "ease", composite: "replace",
      filter: "none" },
    { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",
      filter: "blur(5px) sepia(60%) saturate(30%)" },
  ];
  assert_frame_lists_equal(frames, expected);
}, 'KeyframeEffect.getKeyframes() returns expected values for ' +
   'animations with filter properties and missing keyframes');

test(t => {
  const div = addDiv(t);
  div.style.animation = 'anim-filter-drop-shadow 100s';

  const frames = getKeyframes(div);

  const expected = [
    { offset: 0, computedOffset: 0, easing: "ease", composite: "auto",
      filter: "drop-shadow(rgb(0, 255, 0) 10px 10px 10px)" },
    { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",
      filter: "drop-shadow(rgb(255, 0, 0) 50px 30px 10px)" },
  ];
  assert_frame_lists_equal(frames, expected);
}, 'KeyframeEffect.getKeyframes() returns expected values for ' +
   'animation with drop-shadow of filter property');

// Gecko-specific test case: We are specifically concerned here that the
// computed value for text-shadow and a "none" specified on a keyframe
// are correctly represented.

test(t => {
  const div = addDiv(t);
  div.style.textShadow = '1px 1px 2px rgb(0, 0, 0), ' +
                         '0 0 16px rgb(0, 0, 255), ' +
                         '0 0 3.2px rgb(0, 0, 255)';
  div.style.animation = 'anim-text-shadow 100s';

  const frames = getKeyframes(div);

  // Initial keyframe should be replace as per sections 7 and 8 of
  // https://drafts.csswg.org/css-animations-2/#keyframes
  const expected = [
    { offset: 0, computedOffset: 0, easing: "ease", composite: "replace",
      textShadow: "rgb(0, 0, 0) 1px 1px 2px,"
                  + " rgb(0, 0, 255) 0px 0px 16px,"
                  + " rgb(0, 0, 255) 0px 0px 3.2px" },
    { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",
      textShadow: "none" },
  ];
  assert_frame_lists_equal(frames, expected);
}, 'KeyframeEffect.getKeyframes() returns expected values for ' +
   'animations with text-shadow properties and missing keyframes');

// Gecko-specific test case: We are specifically concerned here that the
// initial value for background-size and the specified list are correctly
// represented.

test(t => {
  const div = addDiv(t);

  div.style.animation = 'anim-background-size 100s';
  let frames = getKeyframes(div);

  assert_equals(frames.length, 2, "number of frames");

  // Initial keyframe should be replace as per sections 7 and 8 of
  // https://drafts.csswg.org/css-animations-2/#keyframes
  const expected = [
    { offset: 0, computedOffset: 0, easing: "ease", composite: "replace",
      backgroundSize: "auto" },
    { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",
      backgroundSize: "50% auto, 6px auto, contain" },
  ];

  for (let i = 0; i < frames.length; i++) {
    assert_frames_equal(frames[i], expected[i], "ComputedKeyframe #" + i);
  }

  // Test inheriting a background-size value

  expected[0].backgroundSize = div.style.backgroundSize =
    "30px auto, 40% auto, auto";
  frames = getKeyframes(div);

  for (let i = 0; i < frames.length; i++) {
    assert_frames_equal(frames[i], expected[i], "ComputedKeyframe #" + i
                        + " after updating current style");
  }
}, 'KeyframeEffect.getKeyframes() returns expected values for ' +
   'animations with background-size properties and missing keyframes');

test(t => {
  const div = addDiv(t);
  div.style.animation = 'anim-variables 100s';

  const frames = getKeyframes(div);

  // Initial keyframe should be replace as per sections 7 and 8 of
  // https://drafts.csswg.org/css-animations-2/#keyframes
  const expected = [
    { offset: 0, computedOffset: 0, easing: "ease", composite: "replace",
      transform: "none" },
    { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",
      transform: "translate(100px)" },
  ];
  assert_frame_lists_equal(frames, expected);
}, 'KeyframeEffect.getKeyframes() returns expected values for ' +
   'animations with CSS variables as keyframe values');

test(t => {
  const div = addDiv(t);
  div.style.animation = 'anim-variables-shorthand 100s';

  const frames = getKeyframes(div);

  // Initial keyframe should be replace as per sections 7 and 8 of
  // https://drafts.csswg.org/css-animations-2/#keyframes
  const expected = [
    { offset: 0, computedOffset: 0, easing: "ease", composite: "replace",
      marginBottom: "0px",
      marginLeft: "0px",
      marginRight: "0px",
      marginTop: "0px" },
    { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",
      marginBottom: "100px",
      marginLeft: "100px",
      marginRight: "100px",
      marginTop: "100px" },
  ];
  assert_frame_lists_equal(frames, expected);
}, 'KeyframeEffect.getKeyframes() returns expected values for ' +
   'animations with CSS variables as keyframe values in a shorthand property');

test(t => {
  const div = addDiv(t);
  div.style.animation = 'anim-custom-property-in-keyframe 100s steps(2, start)';

  const frames = getKeyframes(div);

  // Initial keyframe should be replace as per sections 7 and 8 of
  // https://drafts.csswg.org/css-animations-2/#keyframes
  const expected = [
    { offset: 0, computedOffset: 0, easing: "steps(2, start)", composite: "replace",
      color: "rgb(0, 0, 0)" },
    { offset: 1, computedOffset: 1, easing: "steps(2, start)", composite: "auto",
      color: "rgb(0, 255, 0)" },
  ];
  assert_frame_lists_equal(frames, expected);
}, 'KeyframeEffect.getKeyframes() returns expected values for ' +
   'animations with a CSS variable which is overriden by the value in keyframe');

test(t => {
  const div = addDiv(t);
  div.style.animation = 'anim-only-custom-property-in-keyframe 100s';

  const frames = getKeyframes(div);

  const expected = [
    { offset: 0, computedOffset: 0, easing: "ease", composite: "auto",
      transform: "translate(100px)" },
    { offset: 1, computedOffset: 1, easing: "ease", composite: "auto",
      transform: "none" },
  ];
  assert_frame_lists_equal(frames, expected);
}, 'KeyframeEffect.getKeyframes() returns expected values for ' +
   'animations with only custom property in a keyframe');

test(t => {
  const div = addDiv(t);

  // Add custom @keyframes rule
  const stylesheet = document.styleSheets[0];
  const keyframes = '@keyframes anim-custom { to { left: 100px } }';
  const ruleIndex = stylesheet.insertRule(keyframes, 0);
  const keyframesRule = stylesheet.cssRules[ruleIndex];

  t.add_cleanup(function() {
    stylesheet.deleteRule(ruleIndex);
  });

  div.style.animation = 'anim-custom 100s';

  // Sanity check the initial result
  let frames = getKeyframes(div);
  assert_frames_equal(
    frames[frames.length - 1],
    {
      offset: 1,
      computedOffset: 1,
      easing: 'ease',
      composite: 'auto',
      left: '100px',
    },
    'Keyframes reflect the initial @keyframes rule'
  );

  // Update the @keyframes rule
  keyframesRule.deleteRule(0);
  keyframesRule.appendRule('to { left: 200px }');

  // Check the result from getKeyframes() is updated
  frames = getKeyframes(div);
  assert_frames_equal(
    frames[frames.length - 1],
    {
      offset: 1,
      computedOffset: 1,
      easing: 'ease',
      composite: 'auto',
      left: '200px',
    },
    'Keyframes reflects the updated @keyframes rule'
  );
}, 'KeyframeEffect.getKeyframes() reflects changes to @keyframes rules');

test(t => {
  const div = addDiv(t);
  div.style.animation = 'anim-only-timing-function-for-from-and-to 100s';

  const frames = getKeyframes(div);

  // Implicit initial and final keyframes should be replace as per sections
  // 7 and 8 of https://drafts.csswg.org/css-animations-2/#keyframes
  const expected = [
    { offset: 0,   computedOffset: 0,   easing: "linear", composite: "auto" },
    { offset: 0,   computedOffset: 0,   easing: "ease",   composite: "replace", left: "auto" },
    { offset: 0.5, computedOffset: 0.5, easing: "ease",   composite: "auto", left: "10px" },
    { offset: 1,   computedOffset: 1,   easing: "linear", composite: "auto" },
    { offset: 1,   computedOffset: 1,   easing: "ease",   composite: "replace", left: "auto" }
  ];
  assert_frame_lists_equal(frames, expected);
}, 'KeyframeEffect.getKeyframes() returns expected values for ' +
   'animations with implicit values and a non-default timing' +
   'function specified for 0% and 100%');

</script>
</body>