summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/web-animations/resources/keyframe-tests.js
blob: 43e0d7575f2cc47294e2435f311e26c66bb52a36 (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
'use strict';

// ==============================
//
// Common keyframe test data
//
// ==============================


// ------------------------------
//  Composite values
// ------------------------------

const gGoodKeyframeCompositeValueTests = [
  'replace', 'add', 'accumulate', 'auto'
];

const gBadKeyframeCompositeValueTests = [
  'unrecognised', 'replace ', 'Replace', null
];

const gGoodOptionsCompositeValueTests = [
  'replace', 'add', 'accumulate'
];

const gBadOptionsCompositeValueTests = [
  'unrecognised', 'replace ', 'Replace', null
];

// ------------------------------
//  Keyframes
// ------------------------------

const gEmptyKeyframeListTests = [
  [],
  null,
  undefined,
];

// Helper methods to make defining computed keyframes more readable.

const offset = offset => ({
  offset,
  computedOffset: offset,
});

const computedOffset = computedOffset => ({
  offset: null,
  computedOffset,
});

const keyframe = (offset, props, easing='linear', composite) => {
  // The object spread operator is not yet available in all browsers so we use
  // Object.assign instead.
  const result = {};
  Object.assign(result, offset, props, { easing });
  result.composite = composite || 'auto';
  return result;
};

const gKeyframesTests = [

  // ----------- Property-indexed keyframes: property handling -----------

  {
    desc:   'a one property two value property-indexed keyframes specification',
    input:  { left: ['10px', '20px'] },
    output: [keyframe(computedOffset(0), { left: '10px' }),
             keyframe(computedOffset(1), { left: '20px' })],
  },
  {
    desc:   'a one shorthand property two value property-indexed keyframes'
            + ' specification',
    input:  { margin: ['10px', '10px 20px 30px 40px'] },
    output: [keyframe(computedOffset(0), { margin: '10px' }),
             keyframe(computedOffset(1), { margin: '10px 20px 30px 40px' })],
  },
  {
    desc:   'a two property (one shorthand and one of its longhand components)'
            + ' two value property-indexed keyframes specification',
    input:  { marginTop: ['50px', '60px'],
              margin: ['10px', '10px 20px 30px 40px'] },
    output: [keyframe(computedOffset(0),
                      { marginTop: '50px', margin: '10px' }),
             keyframe(computedOffset(1),
                      { marginTop: '60px', margin: '10px 20px 30px 40px' })],
  },
  {
    desc:   'a two property (one shorthand and one of its shorthand components)'
            + ' two value property-indexed keyframes specification',
    input:  { border: ['pink', '2px'],
              borderColor: ['green', 'blue'] },
    output: [keyframe(computedOffset(0),
                      { border: 'pink', borderColor: 'green' }),
             keyframe(computedOffset(1),
                      { border: '2px', borderColor: 'blue' })],
  },
  {
    desc:   'a two property two value property-indexed keyframes specification',
    input:  { left: ['10px', '20px'],
              top: ['30px', '40px'] },
    output: [keyframe(computedOffset(0), { left: '10px', top: '30px' }),
             keyframe(computedOffset(1), { left: '20px', top: '40px' })],
  },
  {
    desc:   'a two property property-indexed keyframes specification with'
            + ' different numbers of values',
    input:  { left: ['10px', '20px', '30px'],
              top: ['40px', '50px'] },
    output: [keyframe(computedOffset(0),   { left: '10px', top: '40px' }),
             keyframe(computedOffset(0.5), { left: '20px' }),
             keyframe(computedOffset(1),   { left: '30px', top: '50px' })],
  },
  {
    desc:   'a property-indexed keyframes specification with an invalid value',
    input:  { left: ['10px', '20px', '30px', '40px', '50px'],
              top:  ['15px', '25px', 'invalid', '45px', '55px'] },
    output: [keyframe(computedOffset(0),    { left: '10px', top: '15px' }),
             keyframe(computedOffset(0.25), { left: '20px', top: '25px' }),
             keyframe(computedOffset(0.5),  { left: '30px' }),
             keyframe(computedOffset(0.75), { left: '40px', top: '45px' }),
             keyframe(computedOffset(1),    { left: '50px', top: '55px' })],
  },
  {
    desc:   'a one property two value property-indexed keyframes specification'
            + ' that needs to stringify its values',
    input:  { opacity: [0, 1] },
    output: [keyframe(computedOffset(0), { opacity: '0' }),
             keyframe(computedOffset(1), { opacity: '1' })],
  },
  {
    desc:   'a property-indexed keyframes specification with a CSS variable'
            + ' reference',
    input:  { left: [ 'var(--dist)', 'calc(var(--dist) + 100px)' ] },
    output: [keyframe(computedOffset(0), { left: 'var(--dist)' }),
             keyframe(computedOffset(1), { left: 'calc(var(--dist) + 100px)' })]
  },
  {
    desc:   'a property-indexed keyframes specification with a CSS variable'
            + ' reference in a shorthand property',
    input:  { margin: [ 'var(--dist)', 'calc(var(--dist) + 100px)' ] },
    output: [keyframe(computedOffset(0),
                      { margin: 'var(--dist)' }),
             keyframe(computedOffset(1),
                      { margin: 'calc(var(--dist) + 100px)' })],
  },
  {
    desc:   'a one property one value property-indexed keyframes specification',
    input:  { left: ['10px'] },
    output: [keyframe(computedOffset(1), { left: '10px' })],
  },
  {
    desc:   'a one property one non-array value property-indexed keyframes'
            + ' specification',
    input:  { left: '10px' },
    output: [keyframe(computedOffset(1), { left: '10px' })],
  },
  {
    desc:   'a one property two value property-indexed keyframes specification'
            + ' where the first value is invalid',
    input:  { left: ['invalid', '10px'] },
    output: [keyframe(computedOffset(0), {}),
             keyframe(computedOffset(1), { left: '10px' })]
  },
  {
    desc:   'a one property two value property-indexed keyframes specification'
            + ' where the second value is invalid',
    input:  { left: ['10px', 'invalid'] },
    output: [keyframe(computedOffset(0), { left: '10px' }),
             keyframe(computedOffset(1), {})]
  },
  {
    desc:   'a property-indexed keyframes specification with a CSS variable as'
            + ' the property',
    input:  { '--custom': ['1', '2'] },
    output: [keyframe(computedOffset(0), { '--custom': '1' }),
             keyframe(computedOffset(1), { '--custom': '2' })]
  },

  // ----------- Property-indexed keyframes: offset handling -----------

  {
    desc:   'a property-indexed keyframe with a single offset',
    input:  { left: ['10px', '20px', '30px'], offset: 0.5 },
    output: [keyframe(offset(0.5),          { left: '10px' }),
             keyframe(computedOffset(0.75), { left: '20px' }),
             keyframe(computedOffset(1),    { left: '30px' })],
  },
  {
    desc:   'a property-indexed keyframe with an array of offsets',
    input:  { left: ['10px', '20px', '30px'], offset: [ 0.1, 0.25, 0.8 ] },
    output: [keyframe(offset(0.1),  { left: '10px' }),
             keyframe(offset(0.25), { left: '20px' }),
             keyframe(offset(0.8),  { left: '30px' })],
  },
  {
    desc:   'a property-indexed keyframe with an array of offsets that is too'
            + ' short',
    input:  { left: ['10px', '20px', '30px'], offset: [ 0, 0.25 ] },
    output: [keyframe(offset(0),         { left: '10px' }),
             keyframe(offset(0.25),      { left: '20px' }),
             keyframe(computedOffset(1), { left: '30px' })],
  },
  {
    desc:   'a property-indexed keyframe with an array of offsets that is too'
            + ' long',
    input:  { left: ['10px', '20px', '30px'],
              offset: [ 0, 0.25, 0.5, 0.75, 1 ] },
    output: [keyframe(offset(0),    { left: '10px' }),
             keyframe(offset(0.25), { left: '20px' }),
             keyframe(offset(0.5),  { left: '30px' })],
  },
  {
    desc:   'a property-indexed keyframe with an empty array of offsets',
    input:  { left: ['10px', '20px', '30px'], offset: [] },
    output: [keyframe(computedOffset(0),   { left: '10px' }),
             keyframe(computedOffset(0.5), { left: '20px' }),
             keyframe(computedOffset(1),   { left: '30px' })],
  },
  {
    desc:   'a property-indexed keyframe with an array of offsets with an'
            + ' embedded null value',
    input:  { left: ['10px', '20px', '30px'],
              offset: [ 0, null, 0.5 ] },
    output: [keyframe(offset(0),            { left: '10px' }),
             keyframe(computedOffset(0.25), { left: '20px' }),
             keyframe(offset(0.5),          { left: '30px' })],
  },
  {
    desc:   'a property-indexed keyframe with an array of offsets with a'
            + ' trailing null value',
    input:  { left: ['10px', '20px', '30px'],
              offset: [ 0, 0.25, null ] },
    output: [keyframe(offset(0),           { left: '10px' }),
             keyframe(offset(0.25),        { left: '20px' }),
             keyframe(computedOffset(1), { left: '30px' })],
  },
  {
    desc:   'a property-indexed keyframe with an array of offsets with leading'
            + ' and trailing null values',
    input:  { left: ['10px', '20px', '30px'],
              offset: [ null, 0.25, null ] },
    output: [keyframe(computedOffset(0), { left: '10px' }),
             keyframe(offset(0.25),      { left: '20px' }),
             keyframe(computedOffset(1), { left: '30px' })],
  },
  {
    desc:   'a property-indexed keyframe with an array of offsets with'
            + ' adjacent null values',
    input:  { left: ['10px', '20px', '30px'],
              offset: [ null, null, 0.5 ] },
    output: [keyframe(computedOffset(0),    { left: '10px' }),
             keyframe(computedOffset(0.25), { left: '20px' }),
             keyframe(offset(0.5),          { left: '30px' })],
  },
  {
    desc:   'a property-indexed keyframe with an array of offsets with'
            + ' all null values (and too many at that)',
    input:  { left: ['10px', '20px', '30px'],
              offset: [ null, null, null, null, null ] },
    output: [keyframe(computedOffset(0),   { left: '10px' }),
             keyframe(computedOffset(0.5), { left: '20px' }),
             keyframe(computedOffset(1),   { left: '30px' })],
  },
  {
    desc:   'a property-indexed keyframe with a single null offset',
    input:  { left: ['10px', '20px', '30px'], offset: null },
    output: [keyframe(computedOffset(0),   { left: '10px' }),
             keyframe(computedOffset(0.5), { left: '20px' }),
             keyframe(computedOffset(1),   { left: '30px' })],
  },
  {
    desc:   'a property-indexed keyframe with an array of offsets that is not'
            + ' strictly ascending in the unused part of the array',
    input:  { left: ['10px', '20px', '30px'],
              offset: [ 0, 0.2, 0.8, 0.6 ] },
    output: [keyframe(offset(0),   { left: '10px' }),
             keyframe(offset(0.2), { left: '20px' }),
             keyframe(offset(0.8), { left: '30px' })],
  },

  // ----------- Property-indexed keyframes: easing handling -----------

  {
    desc:   'a property-indexed keyframe without any specified easing',
    input:  { left: ['10px', '20px', '30px'] },
    output: [keyframe(computedOffset(0),   { left: '10px' }, 'linear'),
             keyframe(computedOffset(0.5), { left: '20px' }, 'linear'),
             keyframe(computedOffset(1),   { left: '30px' }, 'linear')],
  },
  {
    desc:   'a property-indexed keyframe with a single easing',
    input:  { left: ['10px', '20px', '30px'], easing: 'ease-in' },
    output: [keyframe(computedOffset(0),   { left: '10px' }, 'ease-in'),
             keyframe(computedOffset(0.5), { left: '20px' }, 'ease-in'),
             keyframe(computedOffset(1),   { left: '30px' }, 'ease-in')],
  },
  {
    desc:   'a property-indexed keyframe with an array of easings',
    input:  { left: ['10px', '20px', '30px'],
              easing: ['ease-in', 'ease-out', 'ease-in-out'] },
    output: [keyframe(computedOffset(0),   { left: '10px' }, 'ease-in'),
             keyframe(computedOffset(0.5), { left: '20px' }, 'ease-out'),
             keyframe(computedOffset(1),   { left: '30px' }, 'ease-in-out')],
  },
  {
    desc:   'a property-indexed keyframe with an array of easings that is too'
            + ' short',
    input:  { left: ['10px', '20px', '30px'],
              easing: ['ease-in', 'ease-out'] },
    output: [keyframe(computedOffset(0),   { left: '10px' }, 'ease-in'),
             keyframe(computedOffset(0.5), { left: '20px' }, 'ease-out'),
             keyframe(computedOffset(1),   { left: '30px' }, 'ease-in')],
  },
  {
    desc:   'a property-indexed keyframe with a single-element array of'
            + ' easings',
    input:  { left: ['10px', '20px', '30px'], easing: ['ease-in'] },
    output: [keyframe(computedOffset(0),   { left: '10px' }, 'ease-in'),
             keyframe(computedOffset(0.5), { left: '20px' }, 'ease-in'),
             keyframe(computedOffset(1),   { left: '30px' }, 'ease-in')],
  },
  {
    desc:   'a property-indexed keyframe with an empty array of easings',
    input:  { left: ['10px', '20px', '30px'], easing: [] },
    output: [keyframe(computedOffset(0),   { left: '10px' }, 'linear'),
             keyframe(computedOffset(0.5), { left: '20px' }, 'linear'),
             keyframe(computedOffset(1),   { left: '30px' }, 'linear')],
  },
  {
    desc:   'a property-indexed keyframe with an array of easings that is too'
            + ' long',
    input:  { left: ['10px', '20px', '30px'],
              easing: ['steps(1)', 'steps(2)', 'steps(3)', 'steps(4)'] },
    output: [keyframe(computedOffset(0),   { left: '10px' }, 'steps(1)'),
             keyframe(computedOffset(0.5), { left: '20px' }, 'steps(2)'),
             keyframe(computedOffset(1),   { left: '30px' }, 'steps(3)')],
  },

  // ----------- Property-indexed keyframes: composite handling -----------

  {
    desc:   'a property-indexed keyframe with a single composite operation',
    input:  { left: ['10px', '20px', '30px'], composite: 'add' },
    output: [keyframe(computedOffset(0),   { left: '10px' }, 'linear', 'add'),
             keyframe(computedOffset(0.5), { left: '20px' }, 'linear', 'add'),
             keyframe(computedOffset(1),   { left: '30px' }, 'linear', 'add')],
  },
  {
    desc:   'a property-indexed keyframe with a composite array',
    input:  { left: ['10px', '20px', '30px'],
              composite: ['add', 'replace', 'accumulate'] },
    output: [keyframe(computedOffset(0),   { left: '10px' },
                      'linear', 'add'),
             keyframe(computedOffset(0.5), { left: '20px' },
                      'linear', 'replace'),
             keyframe(computedOffset(1),   { left: '30px' },
                      'linear', 'accumulate')],
  },
  {
    desc:   'a property-indexed keyframe with a composite array that is too'
            + ' short',
    input:  { left: ['10px', '20px', '30px', '40px', '50px'],
              composite: ['add', 'replace'] },
    output: [keyframe(computedOffset(0),    { left: '10px' },
                      'linear', 'add'),
             keyframe(computedOffset(0.25), { left: '20px' },
                      'linear', 'replace'),
             keyframe(computedOffset(0.5),  { left: '30px' },
                      'linear', 'add'),
             keyframe(computedOffset(0.75), { left: '40px' },
                      'linear', 'replace'),
             keyframe(computedOffset(1),    { left: '50px' },
                      'linear', 'add')],
  },
  {
    desc:   'a property-indexed keyframe with a composite array that is too'
            + ' long',
    input:  { left: ['10px', '20px'],
              composite: ['add', 'replace', 'accumulate'] },
    output: [keyframe(computedOffset(0), { left: '10px' },
                      'linear', 'add'),
             keyframe(computedOffset(1), { left: '20px' },
                      'linear', 'replace')],
  },
  {
    desc:   'a property-indexed keyframe with a single-element composite array',
    input:  { left: ['10px', '20px', '30px'],
              composite: ['add'] },
    output: [keyframe(computedOffset(0),   { left: '10px' }, 'linear', 'add'),
             keyframe(computedOffset(0.5), { left: '20px' }, 'linear', 'add'),
             keyframe(computedOffset(1),   { left: '30px' }, 'linear', 'add')],
  },

  // ----------- Keyframe sequence: property handling -----------

  {
    desc:   'a one property one keyframe sequence',
    input:  [{ offset: 1, left: '10px' }],
    output: [keyframe(offset(1), { left: '10px' })],
  },
  {
    desc:   'a one property two keyframe sequence',
    input:  [{ offset: 0, left: '10px' },
             { offset: 1, left: '20px' }],
    output: [keyframe(offset(0), { left: '10px' }),
             keyframe(offset(1), { left: '20px' })],
  },
  {
    desc:   'a two property two keyframe sequence',
    input:  [{ offset: 0, left: '10px', top: '30px' },
             { offset: 1, left: '20px', top: '40px' }],
    output: [keyframe(offset(0), { left: '10px', top: '30px' }),
             keyframe(offset(1), { left: '20px', top: '40px' })],
  },
  {
    desc:   'a one shorthand property two keyframe sequence',
    input:  [{ offset: 0, margin: '10px' },
             { offset: 1, margin: '20px 30px 40px 50px' }],
    output: [keyframe(offset(0), { margin: '10px' }),
             keyframe(offset(1), { margin: '20px 30px 40px 50px' })],
  },
  {
    desc:   'a two property (a shorthand and one of its component longhands)'
            + ' two keyframe sequence',
    input:  [{ offset: 0, margin: '10px', marginTop: '20px' },
             { offset: 1, marginTop: '70px', margin: '30px 40px 50px 60px' }],
    output: [keyframe(offset(0), { margin: '10px', marginTop: '20px' }),
             keyframe(offset(1), { marginTop: '70px',
                                   margin: '30px 40px 50px 60px' })],
  },
  {
    desc:   'a two property keyframe sequence where one property is missing'
            + ' from the first keyframe',
    input:  [{ offset: 0, left: '10px' },
             { offset: 1, left: '20px', top: '30px' }],
    output: [keyframe(offset(0), { left: '10px' }),
             keyframe(offset(1), { left: '20px', top: '30px' })],
  },
  {
    desc:   'a two property keyframe sequence where one property is missing'
            + ' from the last keyframe',
    input:  [{ offset: 0, left: '10px', top: '20px' },
             { offset: 1, left: '30px' }],
    output: [keyframe(offset(0), { left: '10px', top: '20px' }),
             keyframe(offset(1), { left: '30px' })],
  },
  {
    desc:   'a one property two keyframe sequence that needs to stringify'
            + ' its values',
    input:  [{ offset: 0, opacity: 0 },
             { offset: 1, opacity: 1 }],
    output: [keyframe(offset(0), { opacity: '0' }),
             keyframe(offset(1), { opacity: '1' })],
  },
  {
    desc:   'a keyframe sequence with a CSS variable reference',
    input:  [{ left: 'var(--dist)' },
             { left: 'calc(var(--dist) + 100px)' }],
    output: [keyframe(computedOffset(0), { left: 'var(--dist)' }),
             keyframe(computedOffset(1), { left: 'calc(var(--dist) + 100px)' })]
  },
  {
    desc:   'a keyframe sequence with a CSS variable reference in a shorthand'
            + ' property',
    input:  [{ margin: 'var(--dist)' },
             { margin: 'calc(var(--dist) + 100px)' }],
    output: [keyframe(computedOffset(0),
                      { margin: 'var(--dist)' }),
             keyframe(computedOffset(1),
                      { margin: 'calc(var(--dist) + 100px)' })],
  },
  {
    desc:   'a keyframe sequence with a CSS variable as its property',
    input:  [{ '--custom': 'a' },
             { '--custom': 'b' }],
    output: [keyframe(computedOffset(0), { '--custom': 'a' }),
             keyframe(computedOffset(1), { '--custom': 'b' })]
  },

  // ----------- Keyframe sequence: offset handling -----------

  {
    desc:   'a keyframe sequence with duplicate values for a given interior'
            + ' offset',
    input:  [{ offset: 0.0, left: '10px' },
             { offset: 0.5, left: '20px' },
             { offset: 0.5, left: '30px' },
             { offset: 0.5, left: '40px' },
             { offset: 1.0, left: '50px' }],
    output: [keyframe(offset(0),   { left: '10px' }),
             keyframe(offset(0.5), { left: '20px' }),
             keyframe(offset(0.5), { left: '30px' }),
             keyframe(offset(0.5), { left: '40px' }),
             keyframe(offset(1),   { left: '50px' })],
  },
  {
    desc:   'a keyframe sequence with duplicate values for offsets 0 and 1',
    input:  [{ offset: 0, left: '10px' },
             { offset: 0, left: '20px' },
             { offset: 0, left: '30px' },
             { offset: 1, left: '40px' },
             { offset: 1, left: '50px' },
             { offset: 1, left: '60px' }],
    output: [keyframe(offset(0), { left: '10px' }),
             keyframe(offset(0), { left: '20px' }),
             keyframe(offset(0), { left: '30px' }),
             keyframe(offset(1), { left: '40px' }),
             keyframe(offset(1), { left: '50px' }),
             keyframe(offset(1), { left: '60px' })],
  },
  {
    desc:   'a two property four keyframe sequence',
    input:  [{ offset: 0, left: '10px' },
             { offset: 0, top: '20px' },
             { offset: 1, top: '30px' },
             { offset: 1, left: '40px' }],
    output: [keyframe(offset(0), { left: '10px' }),
             keyframe(offset(0), { top:  '20px' }),
             keyframe(offset(1), { top:  '30px' }),
             keyframe(offset(1), { left: '40px' })],
  },
  {
    desc:   'a single keyframe sequence with omitted offset',
    input:  [{ left: '10px' }],
    output: [keyframe(computedOffset(1), { left: '10px' })],
  },
  {
    desc:   'a single keyframe sequence with null offset',
    input:  [{ offset: null, left: '10px' }],
    output: [keyframe(computedOffset(1), { left: '10px' })],
  },
  {
    desc:   'a single keyframe sequence with string offset',
    input:  [{ offset: '0.5', left: '10px' }],
    output: [keyframe(offset(0.5), { left: '10px' })],
  },
  {
    desc:   'a one property keyframe sequence with some omitted offsets',
    input:  [{ offset: 0.00, left: '10px' },
             { offset: 0.25, left: '20px' },
             { left: '30px' },
             { left: '40px' },
             { offset: 1.00, left: '50px' }],
    output: [keyframe(offset(0),            { left: '10px' }),
             keyframe(offset(0.25),         { left: '20px' }),
             keyframe(computedOffset(0.5),  { left: '30px' }),
             keyframe(computedOffset(0.75), { left: '40px' }),
             keyframe(offset(1),            { left: '50px' })],
  },
  {
    desc:   'a one property keyframe sequence with some null offsets',
    input:  [{ offset: 0.00, left: '10px' },
             { offset: 0.25, left: '20px' },
             { offset: null, left: '30px' },
             { offset: null, left: '40px' },
             { offset: 1.00, left: '50px' }],
    output: [keyframe(offset(0),            { left: '10px' }),
             keyframe(offset(0.25),         { left: '20px' }),
             keyframe(computedOffset(0.5),  { left: '30px' }),
             keyframe(computedOffset(0.75), { left: '40px' }),
             keyframe(offset(1),            { left: '50px' })],
  },
  {
    desc:   'a two property keyframe sequence with some omitted offsets',
    input:  [{ offset: 0.00, left: '10px', top: '20px' },
             { offset: 0.25, left: '30px' },
             { left: '40px' },
             { left: '50px', top: '60px' },
             { offset: 1.00, left: '70px', top: '80px' }],
    output: [keyframe(offset(0),            { left: '10px', top: '20px' }),
             keyframe(offset(0.25),         { left: '30px' }),
             keyframe(computedOffset(0.5),  { left: '40px' }),
             keyframe(computedOffset(0.75), { left: '50px', top: '60px' }),
             keyframe(offset(1),            { left: '70px', top: '80px' })],
  },
  {
    desc:   'a one property keyframe sequence with all omitted offsets',
    input:  [{ left: '10px' },
             { left: '20px' },
             { left: '30px' },
             { left: '40px' },
             { left: '50px' }],
    output: [keyframe(computedOffset(0),    { left: '10px' }),
             keyframe(computedOffset(0.25), { left: '20px' }),
             keyframe(computedOffset(0.5),  { left: '30px' }),
             keyframe(computedOffset(0.75), { left: '40px' }),
             keyframe(computedOffset(1),    { left: '50px' })],
  },

  // ----------- Keyframe sequence: easing handling -----------

  {
    desc:   'a keyframe sequence with different easing values, but the same'
            + ' easing value for a given offset',
    input:  [{ offset: 0.0, easing: 'ease',     left: '10px'},
             { offset: 0.0, easing: 'ease',     top: '20px'},
             { offset: 0.5, easing: 'linear',   left: '30px' },
             { offset: 0.5, easing: 'linear',   top: '40px' },
             { offset: 1.0, easing: 'step-end', left: '50px' },
             { offset: 1.0, easing: 'step-end', top: '60px' }],
    output: [keyframe(offset(0),   { left: '10px' }, 'ease'),
             keyframe(offset(0),   { top:  '20px' }, 'ease'),
             keyframe(offset(0.5), { left: '30px' }, 'linear'),
             keyframe(offset(0.5), { top:  '40px' }, 'linear'),
             keyframe(offset(1),   { left: '50px' }, 'steps(1)'),
             keyframe(offset(1),   { top:  '60px' }, 'steps(1)')],
  },

  // ----------- Keyframe sequence: composite handling -----------

  {
    desc:   'a keyframe sequence with different composite values, but the'
            + ' same composite value for a given offset',
    input:  [{ offset: 0.0, composite: 'replace', left: '10px' },
             { offset: 0.0, composite: 'replace', top: '20px' },
             { offset: 0.5, composite: 'add',     left: '30px' },
             { offset: 0.5, composite: 'add',     top: '40px' },
             { offset: 1.0, composite: 'replace', left: '50px' },
             { offset: 1.0, composite: 'replace', top: '60px' }],
    output: [keyframe(offset(0),   { left: '10px' }, 'linear', 'replace'),
             keyframe(offset(0),   { top:  '20px' }, 'linear', 'replace'),
             keyframe(offset(0.5), { left: '30px' }, 'linear', 'add'),
             keyframe(offset(0.5), { top:  '40px' }, 'linear', 'add'),
             keyframe(offset(1),   { left: '50px' }, 'linear', 'replace'),
             keyframe(offset(1),   { top:  '60px' }, 'linear', 'replace')],
  },
];

const gInvalidKeyframesTests = [
  {
    desc:  'keyframes with an out-of-bounded positive offset',
    input: [ { opacity: 0 },
             { opacity: 0.5, offset: 2 },
             { opacity: 1 } ],
  },
  {
    desc:  'keyframes with an out-of-bounded negative offset',
    input: [ { opacity: 0 },
             { opacity: 0.5, offset: -1 },
             { opacity: 1 } ],
  },
  {
    desc:  'property-indexed keyframes not loosely sorted by offset',
    input: { opacity: [ 0, 1 ], offset: [ 1, 0 ] },
  },
  {
    desc:  'property-indexed keyframes not loosely sorted by offset even'
           + ' though not all offsets are specified',
    input: { opacity: [ 0, 0.5, 1 ], offset: [ 0.5, 0 ] },
  },
  {
    desc:  'property-indexed keyframes with offsets out of range',
    input: { opacity: [ 0, 0.5, 1 ], offset: [ 0, 1.1 ] },
  },
  {
    desc:  'keyframes not loosely sorted by offset',
    input: [ { opacity: 0, offset: 1 },
             { opacity: 1, offset: 0 } ],
  },
  {
    desc:  'property-indexed keyframes with an invalid easing value',
    input: { opacity: [ 0, 0.5, 1 ],
             easing: 'inherit' },
  },
  {
    desc:  'property-indexed keyframes with an invalid easing value as one of'
           + ' the array values',
    input: { opacity: [ 0, 0.5, 1 ],
             easing: [ 'ease-in', 'inherit' ] },
  },
  {
    desc:   'property-indexed keyframe with an invalid easing in the unused'
            + ' part of the array of easings',
    input:  { left: ['10px', '20px', '30px'],
              easing: ['steps(1)', 'steps(2)', 'steps(3)', 'invalid'] },
  },
  {
    desc:   'empty property-indexed keyframe with an invalid easing',
    input:  { easing: 'invalid' },
  },
  {
    desc:   'empty property-indexed keyframe with an invalid easings array',
    input:  { easing: ['invalid'] },
  },
  {
    desc:  'a keyframe sequence with an invalid easing value',
    input: [ { opacity: 0, easing: 'jumpy' },
             { opacity: 1 } ],
  },
  {
    desc:  'property-indexed keyframes with an invalid composite value',
    input: { opacity: [ 0, 0.5, 1 ],
             composite: 'alternate' },
  },
  {
    desc:  'property-indexed keyframes with an invalid composite value as one'
           + ' of the array values',
    input: { opacity: [ 0, 0.5, 1 ],
             composite: [ 'add', 'alternate' ] },
  },
  {
    desc:  'keyframes with an invalid composite value',
    input: [ { opacity: 0, composite: 'alternate' },
             { opacity: 1 } ],
  },
];


const gKeyframeSerializationTests = [
  {
    desc:   'a on keyframe sequence which requires value serilaization of its'
            + ' values',
    input:  [{offset: 0, backgroundColor: 'rgb(1,2,3)' }],
    output: [keyframe(offset(0), { backgroundColor: 'rgb(1, 2, 3)' })],
  },
];



// ------------------------------
//  KeyframeEffectOptions
// ------------------------------

const gKeyframeEffectOptionTests = [
  {
    desc:     'an empty KeyframeEffectOptions object',
    input:    { },
    expected: { },
  },
  {
    desc:     'a normal KeyframeEffectOptions object',
    input:    { delay: 1000,
                fill: 'auto',
                iterations: 5.5,
                duration: 'auto',
                direction: 'alternate' },
    expected: { delay: 1000,
                fill: 'auto',
                iterations: 5.5,
                duration: 'auto',
                direction: 'alternate' },
  },
  {
    desc:     'a double value',
    input:    3000,
    expected: { duration: 3000 },
  },
  {
    desc:     '+Infinity',
    input:    Infinity,
    expected: { duration: Infinity },
  },
  {
    desc:     'an Infinity duration',
    input:    { duration: Infinity },
    expected: { duration: Infinity },
  },
  {
    desc:     'an auto duration',
    input:    { duration: 'auto' },
    expected: { duration: 'auto' },
  },
  {
    desc:     'an Infinity iterations',
    input:    { iterations: Infinity },
    expected: { iterations: Infinity },
  },
  {
    desc:     'an auto fill',
    input:    { fill: 'auto' },
    expected: { fill: 'auto' },
  },
  {
    desc:     'a forwards fill',
    input:    { fill: 'forwards' },
    expected: { fill: 'forwards' },
  }
];

const gInvalidKeyframeEffectOptionTests = [
  { desc: '-Infinity', input: -Infinity },
  { desc: 'NaN', input: NaN },
  { desc: 'a negative value', input: -1 },
  { desc: 'a negative Infinity duration', input: { duration: -Infinity } },
  { desc: 'a NaN duration', input: { duration: NaN } },
  { desc: 'a negative duration', input: { duration: -1 } },
  { desc: 'a string duration', input: { duration: 'merrychristmas' } },
  { desc: 'a negative Infinity iterations', input: { iterations: -Infinity} },
  { desc: 'a NaN iterations', input: { iterations: NaN } },
  { desc: 'a negative iterations', input: { iterations: -1 } },
  { desc: 'a blank easing', input: { easing: '' } },
  { desc: 'an unrecognized easing', input: { easing: 'unrecognised' } },
  { desc: 'an \'initial\' easing', input: { easing: 'initial' } },
  { desc: 'an \'inherit\' easing', input: { easing: 'inherit' } },
  { desc: 'a variable easing', input: { easing: 'var(--x)' } },
  { desc: 'a multi-value easing', input: { easing: 'ease-in-out, ease-out' } },
];

// There is currently only ScrollTimeline that can be constructed and used here
// beyond document timeline. Given that ScrollTimeline is not stable as of yet
// it's tested in scroll-animations/animation-with-animatable-interface.html.
const gAnimationTimelineTests = [
  {
    expectedTimeline: document.timeline,
    expectedTimelineDescription: 'document.timeline',
    description: 'with no timeline parameter'
  },
  {
    timeline: undefined,
    expectedTimeline: document.timeline,
    expectedTimelineDescription: 'document.timeline',
    description: 'with undefined timeline'
  },
  {
    timeline: null,
    expectedTimeline: null,
    expectedTimelineDescription: 'null',
    description: 'with null timeline'
  },
  {
    timeline: document.timeline,
    expectedTimeline: document.timeline,
    expectedTimelineDescription: 'document.timeline',
    description: 'with DocumentTimeline'
  },
];