summaryrefslogtreecommitdiffstats
path: root/dom/animation/test/style/test_missing-keyframe-on-compositor.html
blob: 8b92a891685c57c80c827008856b005615631a0c (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
<!doctype html>
<meta charset=utf-8>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../testcommon.js"></script>
<script src="/tests/SimpleTest/paint_listener.js"></script>
<style>
div {
  /* Element needs geometry to be eligible for layerization */
  width: 100px;
  height: 100px;
  background-color: white;
}
</style>
<body>
<div id="log"></div>
<script>
'use strict';

if (!SpecialPowers.DOMWindowUtils.layerManagerRemote ||
    !SpecialPowers.getBoolPref(
      'layers.offmainthreadcomposition.async-animations')) {
  // If OMTA is disabled, nothing to run.
  done();
}

function waitForPaintsFlushed() {
  return new Promise(function(resolve, reject) {
    waitForAllPaintsFlushed(resolve);
  });
}

// Note that promise tests run in sequence so this ensures the document is
// loaded before any of the other tests run.
promise_test(t => {
  // Without this, the first test case fails on Android.
  return waitForDocumentLoad();
}, 'Ensure document has been loaded');

promise_test(t => {
  var div;
  return useTestRefreshMode(t).then(() => {
    div = addDiv(t, { style: 'opacity: 0.1' });
    div.animate({ opacity: 1 }, 100 * MS_PER_SEC);
    return waitForPaintsFlushed();
  }).then(() => {
    var opacity =
      SpecialPowers.DOMWindowUtils.getOMTAStyle(div, 'opacity');
    assert_equals(opacity, '0.1',
                  'The initial opacity value should be the base value');
  });
}, 'Initial opacity value for animation with no no keyframe at offset 0');

promise_test(t => {
  var div;
  return useTestRefreshMode(t).then(() => {
    div = addDiv(t, { style: 'opacity: 0.1' });
    div.animate({ opacity: [ 0.5, 1 ] }, 100 * MS_PER_SEC);
    div.animate({ opacity: 1 }, 100 * MS_PER_SEC);

    return waitForPaintsFlushed();
  }).then(() => {
    var opacity =
      SpecialPowers.DOMWindowUtils.getOMTAStyle(div, 'opacity');
    assert_equals(opacity, '0.5',
                  'The initial opacity value should be the value of ' +
                  'lower-priority animation value');
  });
}, 'Initial opacity value for animation with no keyframe at offset 0 when ' +
   'there is a lower-priority animation');

promise_test(t => {
  var div;
  return useTestRefreshMode(t).then(() => {
    div = addDiv(t, { style: 'opacity: 0.1; transition: opacity 100s linear' });
    getComputedStyle(div).opacity;

    div.style.opacity = '0.5';
    getComputedStyle(div).opacity;

    div.animate({ opacity: 1 }, 100 * MS_PER_SEC);

    return waitForPaintsFlushed();
  }).then(() => {
    var opacity =
      SpecialPowers.DOMWindowUtils.getOMTAStyle(div, 'opacity');
    assert_equals(opacity, '0.1',
                  'The initial opacity value should be the initial value of ' +
                  'the transition');
  });
}, 'Initial opacity value for animation with no keyframe at offset 0 when ' +
   'there is a transition on the same property');

promise_test(t => {
  var div;
  return useTestRefreshMode(t).then(() => {
    div = addDiv(t, { style: 'opacity: 0' });
    div.animate([{ offset: 0, opacity: 1 }], 100 * MS_PER_SEC);

    return waitForPaintsFlushed();
  }).then(() => {
    SpecialPowers.DOMWindowUtils.advanceTimeAndRefresh(50 * MS_PER_SEC);

    var opacity =
      SpecialPowers.DOMWindowUtils.getOMTAStyle(div, 'opacity');
    assert_equals(opacity, '0.5',
                  'Opacity value at 50% should be composed onto the base ' +
                  'value');
  });
}, 'Opacity value for animation with no keyframe at offset 1 at 50% ');

promise_test(t => {
  var div;
  return useTestRefreshMode(t).then(() => {
    div = addDiv(t, { style: 'opacity: 0' });
    div.animate({ opacity: [ 0.5, 0.5 ] }, 100 * MS_PER_SEC);
    div.animate([{ offset: 0, opacity: 1 }], 100 * MS_PER_SEC);

    return waitForPaintsFlushed();
  }).then(() => {
    SpecialPowers.DOMWindowUtils.advanceTimeAndRefresh(50 * MS_PER_SEC);

    var opacity =
      SpecialPowers.DOMWindowUtils.getOMTAStyle(div, 'opacity');
    assert_equals(opacity, '0.75', // (0.5 + 1) * 0.5
                  'Opacity value at 50% should be composed onto the value ' +
                  'of middle of lower-priority animation');
  });
}, 'Opacity value for animation with no keyframe at offset 1 at 50% when ' +
   'there is a lower-priority animation');

promise_test(t => {
  var div;
  return useTestRefreshMode(t).then(() => {
    div = addDiv(t, { style: 'opacity: 0; transition: opacity 100s linear' });
    getComputedStyle(div).opacity;

    div.style.opacity = '0.5';
    getComputedStyle(div).opacity;

    div.animate([{ offset: 0, opacity: 1 }], 100 * MS_PER_SEC);

    return waitForPaintsFlushed();
  }).then(() => {
    SpecialPowers.DOMWindowUtils.advanceTimeAndRefresh(50 * MS_PER_SEC);

    var opacity =
      SpecialPowers.DOMWindowUtils.getOMTAStyle(div, 'opacity');
    assert_equals(opacity, '0.625', // ((0 + 0.5) * 0.5 + 1) * 0.5
                  'Opacity value at 50% should be composed onto the value ' +
                  'of middle of transition');
  });
}, 'Opacity value for animation with no keyframe at offset 1 at 50% when ' +
   'there is a transition on the same property');

promise_test(t => {
  var div;
  var lowerAnimation;
  return useTestRefreshMode(t).then(() => {
    div = addDiv(t);
    lowerAnimation = div.animate({ opacity: [ 0.5, 1 ] }, 100 * MS_PER_SEC);
    var higherAnimation = div.animate({ opacity: 1 }, 100 * MS_PER_SEC);

    return waitForPaintsFlushed();
  }).then(() => {
    lowerAnimation.pause();
    return waitForPaintsFlushed();
  }).then(() => {
    SpecialPowers.DOMWindowUtils.advanceTimeAndRefresh(50 * MS_PER_SEC);

    var opacity =
      SpecialPowers.DOMWindowUtils.getOMTAStyle(div, 'opacity');
    // The underlying value is the value that is staying at 0ms of the
    // lowerAnimation, that is 0.5.
    // (0.5 + 1.0) * (50 * MS_PER_SEC / 100 * MS_PER_SEC) = 0.75.
    assert_equals(opacity, '0.75',
                  'Composed opacity value should be composed onto the value ' +
                  'of lower-priority paused animation');
  });
}, 'Opacity value for animation with no keyframe at offset 0 at 50% when ' +
   'composed onto a paused underlying animation');

promise_test(t => {
  var div;
  var lowerAnimation;
  return useTestRefreshMode(t).then(() => {
    div = addDiv(t);
    lowerAnimation = div.animate({ opacity: [ 0.5, 1 ] }, 100 * MS_PER_SEC);
    var higherAnimation = div.animate({ opacity: 1 }, 100 * MS_PER_SEC);

    return waitForPaintsFlushed();
  }).then(() => {
    lowerAnimation.playbackRate = 0;
    return waitForPaintsFlushed();
  }).then(() => {
    SpecialPowers.DOMWindowUtils.advanceTimeAndRefresh(50 * MS_PER_SEC);

    var opacity =
      SpecialPowers.DOMWindowUtils.getOMTAStyle(div, 'opacity');
    // The underlying value is the value that is staying at 0ms of the
    // lowerAnimation, that is 0.5.
    // (0.5 + 1.0) * (50 * MS_PER_SEC / 100 * MS_PER_SEC) = 0.75.
    assert_equals(opacity, '0.75',
                  'Composed opacity value should be composed onto the value ' +
                  'of lower-priority zero playback rate animation');
  });
}, 'Opacity value for animation with no keyframe at offset 0 at 50% when ' +
   'composed onto a zero playback rate underlying animation');

promise_test(t => {
  var div;
  var lowerAnimation;
  return useTestRefreshMode(t).then(() => {
    div = addDiv(t);
    lowerAnimation = div.animate({ opacity: [ 1, 0.5 ] }, 100 * MS_PER_SEC);
    var higherAnimation = div.animate({ opacity: 1 }, 100 * MS_PER_SEC);

    return waitForPaintsFlushed();
  }).then(() => {
    lowerAnimation.effect.updateTiming({
      duration: 0,
      fill: 'forwards',
    });
    return waitForPaintsFlushed();
  }).then(() => {
    SpecialPowers.DOMWindowUtils.advanceTimeAndRefresh(50 * MS_PER_SEC);

    var opacity =
      SpecialPowers.DOMWindowUtils.getOMTAStyle(div, 'opacity');
    // The underlying value is the value that is filling forwards state of the
    // lowerAnimation, that is 0.5.
    // (0.5 + 1.0) * (50 * MS_PER_SEC / 100 * MS_PER_SEC) = 0.75.
    assert_equals(opacity, '0.75',
                  'Composed opacity value should be composed onto the value ' +
                  'of lower-priority zero active duration animation');
  });
}, 'Opacity value for animation with no keyframe at offset 0 at 50% when ' +
   'composed onto a zero active duration underlying animation');

promise_test(t => {
  var div;
  return useTestRefreshMode(t).then(() => {
    div = addDiv(t, { style: 'transform: translateX(100px)' });
    div.animate({ transform: 'translateX(200px)' }, 100 * MS_PER_SEC);

    return waitForPaintsFlushed();
  }).then(() => {
    var transform =
      SpecialPowers.DOMWindowUtils.getOMTAStyle(div, 'transform');
    assert_matrix_equals(transform, 'matrix(1, 0, 0, 1, 100, 0)',
      'The initial transform value should be the base value');
  });
}, 'Initial transform value for animation with no keyframe at offset 0');

promise_test(t => {
  var div;
  return useTestRefreshMode(t).then(() => {
    div = addDiv(t, { style: 'transform: translateX(100px)' });
    div.animate({ transform: [ 'translateX(200px)', 'translateX(300px)' ] },
                100 * MS_PER_SEC);
    div.animate({ transform: 'translateX(400px)' }, 100 * MS_PER_SEC);

    return waitForPaintsFlushed();
  }).then(() => {
    var transform =
      SpecialPowers.DOMWindowUtils.getOMTAStyle(div, 'transform');
    assert_matrix_equals(transform, 'matrix(1, 0, 0, 1, 200, 0)',
      'The initial transform value should be lower-priority animation value');
  });
}, 'Initial transform value for animation with no keyframe at offset 0 when ' +
   'there is a lower-priority animation');

promise_test(t => {
  var div;
  return useTestRefreshMode(t).then(() => {
    div = addDiv(t, { style: 'transform: translateX(100px);' +
                             'transition: transform 100s linear' });
    getComputedStyle(div).transform;

    div.style.transform = 'translateX(200px)';
    getComputedStyle(div).transform;

    div.animate({ transform: 'translateX(400px)' }, 100 * MS_PER_SEC);

    return waitForPaintsFlushed();
  }).then(() => {
    var transform =
      SpecialPowers.DOMWindowUtils.getOMTAStyle(div, 'transform');
    assert_matrix_equals(transform, 'matrix(1, 0, 0, 1, 100, 0)',
      'The initial transform value should be the initial value of the ' +
      'transition');
  });
}, 'Initial transform value for animation with no keyframe at offset 0 when ' +
   'there is a transition');

promise_test(t => {
  var div;
  return useTestRefreshMode(t).then(() => {
    div = addDiv(t, { style: 'transform: translateX(100px)' });
    div.animate([{ offset: 0, transform: 'translateX(200pX)' }],
                100 * MS_PER_SEC);

    return waitForPaintsFlushed();
  }).then(() => {
    SpecialPowers.DOMWindowUtils.advanceTimeAndRefresh(50 * MS_PER_SEC);

    var transform =
      SpecialPowers.DOMWindowUtils.getOMTAStyle(div, 'transform');
    assert_matrix_equals(transform, 'matrix(1, 0, 0, 1, 150, 0)',
      'Transform value at 50% should be the base value');
  });
}, 'Transform value for animation with no keyframe at offset 1 at 50%');

promise_test(t => {
  var div;
  return useTestRefreshMode(t).then(() => {
    div = addDiv(t, { style: 'transform: translateX(100px)' });
    div.animate({ transform: [ 'translateX(200px)', 'translateX(200px)' ] },
                100 * MS_PER_SEC);
    div.animate([{ offset: 0, transform: 'translateX(300px)' }],
                100 * MS_PER_SEC);

    return waitForPaintsFlushed();
  }).then(() => {
    SpecialPowers.DOMWindowUtils.advanceTimeAndRefresh(50 * MS_PER_SEC);

    var transform =
      SpecialPowers.DOMWindowUtils.getOMTAStyle(div, 'transform');
    assert_matrix_equals(transform, 'matrix(1, 0, 0, 1, 250, 0)',
      'The final transform value should be the base value');
  });
}, 'Transform value for animation with no keyframe at offset 1 at 50% when ' +
   'there is a lower-priority animation');

promise_test(t => {
  var div;
  return useTestRefreshMode(t).then(() => {
    div = addDiv(t, { style: 'transform: translateX(100px);' +
                             'transition: transform 100s linear' });
    getComputedStyle(div).transform;

    div.style.transform = 'translateX(200px)';
    getComputedStyle(div).transform;

    div.animate([{ offset: 0, transform: 'translateX(300px)' }],
                100 * MS_PER_SEC);

    return waitForPaintsFlushed();
  }).then(() => {
    SpecialPowers.DOMWindowUtils.advanceTimeAndRefresh(50 * MS_PER_SEC);

    var transform =
      SpecialPowers.DOMWindowUtils.getOMTAStyle(div, 'transform');
                                                   // (150px + 300px) * 0.5
    assert_matrix_equals(transform, 'matrix(1, 0, 0, 1, 225, 0)',
      'The final transform value should be the final value of the transition');
  });
}, 'Transform value for animation with no keyframe at offset 1 at 50% when ' +
   'there is a transition');

promise_test(t => {
  var div;
  var lowerAnimation;
  return useTestRefreshMode(t).then(() => {
    div = addDiv(t);
    lowerAnimation =
      div.animate({ transform: [ 'translateX(100px)', 'translateX(200px)' ] },
                  100 * MS_PER_SEC);
    var higherAnimation = div.animate({ transform: 'translateX(300px)' },
                                      100 * MS_PER_SEC);

    return waitForPaintsFlushed();
  }).then(() => {
    lowerAnimation.pause();
    return waitForPaintsFlushed();
  }).then(() => {
    SpecialPowers.DOMWindowUtils.advanceTimeAndRefresh(50 * MS_PER_SEC);

    var transform =
      SpecialPowers.DOMWindowUtils.getOMTAStyle(div, 'transform');
    // The underlying value is the value that is staying at 0ms of the
    // lowerAnimation, that is 100px.
    // (100px + 300px) * (50 * MS_PER_SEC / 100 * MS_PER_SEC) = 200px.
    assert_matrix_equals(transform, 'matrix(1, 0, 0, 1, 200, 0)',
      'Composed transform value should be composed onto the value of ' +
      'lower-priority paused animation');
  });
}, 'Transform value for animation with no keyframe at offset 0 at 50% when ' +
   'composed onto a paused underlying animation');

promise_test(t => {
  var div;
  var lowerAnimation;
  return useTestRefreshMode(t).then(() => {
    div = addDiv(t);
    lowerAnimation =
      div.animate({ transform: [ 'translateX(100px)', 'translateX(200px)' ] },
                  100 * MS_PER_SEC);
    var higherAnimation = div.animate({ transform: 'translateX(300px)' },
                                      100 * MS_PER_SEC);

    return waitForPaintsFlushed();
  }).then(() => {
    lowerAnimation.playbackRate = 0;
    return waitForPaintsFlushed();
  }).then(() => {
    SpecialPowers.DOMWindowUtils.advanceTimeAndRefresh(50 * MS_PER_SEC);

    var transform =
      SpecialPowers.DOMWindowUtils.getOMTAStyle(div, 'transform');
    // The underlying value is the value that is staying at 0ms of the
    // lowerAnimation, that is 100px.
    // (100px + 300px) * (50 * MS_PER_SEC / 100 * MS_PER_SEC) = 200px.
    assert_matrix_equals(transform, 'matrix(1, 0, 0, 1, 200, 0)',
      'Composed transform value should be composed onto the value of ' +
      'lower-priority zero playback rate animation');
  });
}, 'Transform value for animation with no keyframe at offset 0 at 50% when ' +
   'composed onto a zero playback rate underlying animation');

promise_test(t => {
  var div;
  return useTestRefreshMode(t).then(() => {
    div = addDiv(t);
    var lowerAnimation =
      div.animate({ transform: [ 'translateX(100px)', 'translateX(200px)' ] },
                  { duration: 10 * MS_PER_SEC,
                    fill: 'forwards' });
    var higherAnimation = div.animate({ transform: 'translateX(300px)' },
                                      100 * MS_PER_SEC);

    return waitForPaintsFlushed();
  }).then(() => {
    SpecialPowers.DOMWindowUtils.advanceTimeAndRefresh(50 * MS_PER_SEC);

    // We need to wait for a paint so that we can send the state of the lower
    // animation that is actually finished at this point.
    return waitForPaintsFlushed();
  }).then(() => {
    var transform =
      SpecialPowers.DOMWindowUtils.getOMTAStyle(div, 'transform');
    // (200px + 300px) * (50 * MS_PER_SEC / 100 * MS_PER_SEC) = 250px.
    assert_matrix_equals(transform, 'matrix(1, 0, 0, 1, 250, 0)',
      'Composed transform value should be composed onto the value of ' +
      'lower-priority animation with fill:forwards');
  });
}, 'Transform value for animation with no keyframe at offset 0 at 50% when ' +
   'composed onto a underlying animation with fill:forwards');

promise_test(t => {
  var div;
  return useTestRefreshMode(t).then(() => {
    div = addDiv(t);
    var lowerAnimation =
      div.animate({ transform: [ 'translateX(100px)', 'translateX(200px)' ] },
                  { duration: 10 * MS_PER_SEC,
                    endDelay: -5 * MS_PER_SEC,
                    fill: 'forwards' });
    var higherAnimation = div.animate({ transform: 'translateX(300px)' },
                                      100 * MS_PER_SEC);

    return waitForPaintsFlushed();
  }).then(() => {
    SpecialPowers.DOMWindowUtils.advanceTimeAndRefresh(50 * MS_PER_SEC);

    // We need to wait for a paint just like the above test.
    return waitForPaintsFlushed();
  }).then(() => {
    var transform =
      SpecialPowers.DOMWindowUtils.getOMTAStyle(div, 'transform');
    // (150px + 300px) * (50 * MS_PER_SEC / 100 * MS_PER_SEC) = 225px.
    assert_matrix_equals(transform, 'matrix(1, 0, 0, 1, 225, 0)',
      'Composed transform value should be composed onto the value of ' +
      'lower-priority animation with fill:forwards and negative endDelay');
  });
}, 'Transform value for animation with no keyframe at offset 0 at 50% when ' +
   'composed onto a underlying animation with fill:forwards and negative ' +
   'endDelay');

promise_test(t => {
  var div;
  return useTestRefreshMode(t).then(() => {
    div = addDiv(t);
    var lowerAnimation =
      div.animate({ transform: [ 'translateX(100px)', 'translateX(200px)' ] },
                  { duration: 10 * MS_PER_SEC,
                    endDelay: 100 * MS_PER_SEC,
                    fill: 'forwards' });
    var higherAnimation = div.animate({ transform: 'translateX(300px)' },
                                      100 * MS_PER_SEC);

    return waitForPaintsFlushed();
  }).then(() => {
    SpecialPowers.DOMWindowUtils.advanceTimeAndRefresh(50 * MS_PER_SEC);

    var transform =
      SpecialPowers.DOMWindowUtils.getOMTAStyle(div, 'transform');
    // (200px + 300px) * 0.5
    assert_matrix_equals(transform, 'matrix(1, 0, 0, 1, 250, 0)',
      'Composed transform value should be composed onto the value of ' +
      'lower-priority animation with fill:forwards during positive endDelay');
  });
}, 'Transform value for animation with no keyframe at offset 0 at 50% when ' +
   'composed onto a underlying animation with fill:forwards during positive ' +
   'endDelay');

promise_test(t => {
  var div;
  return useTestRefreshMode(t).then(() => {
    div = addDiv(t, { style: 'transform: translateX(100px)' });
    div.animate({ transform: 'translateX(200px)' },
                { duration: 100 * MS_PER_SEC, delay: 50 * MS_PER_SEC });

    return waitForPaintsFlushed();
  }).then(() => {
    SpecialPowers.DOMWindowUtils.advanceTimeAndRefresh(100 * MS_PER_SEC);

    var transform =
      SpecialPowers.DOMWindowUtils.getOMTAStyle(div, 'transform');
    assert_matrix_equals(transform, 'matrix(1, 0, 0, 1, 150, 0)',
      'Transform value for animation with positive delay should be composed ' +
      'onto the base style');
  });
}, 'Transform value for animation with no keyframe at offset 0 and with ' +
   'positive delay');

promise_test(t => {
  var div;
  return useTestRefreshMode(t).then(() => {
    div = addDiv(t, { style: 'transform: translateX(100px)' });

    div.animate([{ offset: 0, transform: 'translateX(200px)'}],
                { duration: 100 * MS_PER_SEC,
                  iterationStart: 1,
                  iterationComposite: 'accumulate' });

    return waitForPaintsFlushed();
  }).then(() => {
    var transform =
      SpecialPowers.DOMWindowUtils.getOMTAStyle(div, 'transform');
    assert_matrix_equals(transform, 'matrix(1, 0, 0, 1, 300, 0)',
      'Transform value for animation with no keyframe at offset 1 and its ' +
      'iterationComposite is accumulate');
  });
}, 'Transform value for animation with no keyframe at offset 1 and its ' +
   'iterationComposite is accumulate');

promise_test(t => {
  var div;
  return useTestRefreshMode(t).then(() => {
    div = addDiv(t);
    var lowerAnimation =
      div.animate({ transform: [ 'translateX(100px)', 'translateX(200px)' ] },
                  100 * MS_PER_SEC);
    var higherAnimation = div.animate({ transform: 'translateX(300px)' },
                                      100 * MS_PER_SEC);

    lowerAnimation.timeline = null;
    // Set current time at 50% duration.
    lowerAnimation.currentTime = 50 * MS_PER_SEC;

    return waitForPaintsFlushed();
  }).then(() => {
    SpecialPowers.DOMWindowUtils.advanceTimeAndRefresh(50 * MS_PER_SEC);

    var transform =
      SpecialPowers.DOMWindowUtils.getOMTAStyle(div, 'transform');
    // (150px + 300px) * (50 * MS_PER_SEC / 100 * MS_PER_SEC) = 225px.
    assert_matrix_equals(transform, 'matrix(1, 0, 0, 1, 225, 0)',
      'Composed transform value should be composed onto the value of ' +
      'lower-priority animation without timeline');
  });
}, 'Transform value for animation with no keyframe at offset 0 at 50% when ' +
   'composed onto an animation without timeline');

</script>
</body>