tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

the-current-time-of-an-animation.html (2588B)


      1 <!DOCTYPE html>
      2 <meta charset=utf-8>
      3 <title>The current time of an animation</title>
      4 <link rel="help" href="https://drafts.csswg.org/web-animations/#the-current-time-of-an-animation">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <script src="../../testcommon.js"></script>
      8 <script src="../../resources/timing-override.js"></script>
      9 <body>
     10 <div id="log"></div>
     11 <script>
     12 'use strict';
     13 
     14 test(t => {
     15  const animation =
     16    new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
     17                  document.timeline);
     18 
     19  animation.play();
     20  assert_equals(animation.currentTime, 0,
     21    'Current time returns the hold time set when entering the play-pending ' +
     22    'state');
     23 }, 'The current time returns the hold time when set');
     24 
     25 promise_test(async t => {
     26  const animation =
     27    new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
     28                  null);
     29 
     30  await animation.ready;
     31  assert_equals(animation.currentTime, null);
     32 }, 'The current time is unresolved when there is no associated timeline ' +
     33   '(and no hold time is set)');
     34 
     35 // FIXME: Test that the current time is unresolved when we have an inactive
     36 // timeline if we find a way of creating an inactive timeline!
     37 
     38 test(t => {
     39  const animation =
     40    new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
     41                  document.timeline);
     42 
     43  animation.startTime = null;
     44  assert_equals(animation.currentTime, null);
     45 }, 'The current time is unresolved when the start time is unresolved ' +
     46   '(and no hold time is set)');
     47 
     48 test(t => {
     49  const animation =
     50    new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
     51                  document.timeline);
     52 
     53  animation.playbackRate = 2;
     54  animation.startTime = document.timeline.currentTime - 25 * MS_PER_SEC;
     55 
     56  const timelineTime = document.timeline.currentTime;
     57  const startTime = animation.startTime;
     58  const playbackRate = animation.playbackRate;
     59  assert_times_equal(animation.currentTime,
     60                     (timelineTime - startTime) * playbackRate,
     61                     'Animation has a unresolved start time');
     62 }, 'The current time is calculated from the timeline time, start time and ' +
     63   'playback rate');
     64 
     65 promise_test(async t => {
     66  const animation = createDiv(t).animate(null, 100 * MS_PER_SEC);
     67  animation.playbackRate = 0;
     68 
     69  await animation.ready;
     70  await waitForAnimationFrames(1);
     71  assert_time_equals_literal(animation.currentTime, 0);
     72 }, 'The current time does not progress if playback rate is 0');
     73 
     74 </script>
     75 </body>