tor-browser

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

play-states.html (5835B)


      1 <!DOCTYPE html>
      2 <meta charset=utf-8>
      3 <title>Play states</title>
      4 <link rel="help" href="https://drafts.csswg.org/web-animations/#play-states">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <script src="../../testcommon.js"></script>
      8 <body>
      9 <div id="log"></div>
     10 <script>
     11 'use strict';
     12 
     13 test(t => {
     14  const animation = new Animation(
     15    new KeyframeEffect(null, {}, 100 * MS_PER_SEC)
     16  );
     17  assert_equals(animation.currentTime, null,
     18                'Current time should be initially unresolved');
     19 
     20  assert_equals(animation.playState, 'idle');
     21 }, 'reports \'idle\' for an animation with an unresolved current time'
     22   + ' and no pending tasks')
     23 
     24 test(t => {
     25  const animation = createDiv(t).animate({}, 100 * MS_PER_SEC);
     26 
     27  animation.pause();
     28 
     29  assert_equals(animation.playState, 'paused');
     30 }, 'reports \'paused\' for an animation with a pending pause task');
     31 
     32 test(t => {
     33  const animation = new Animation(
     34    new KeyframeEffect(null, {}, 100 * MS_PER_SEC)
     35  );
     36 
     37  animation.currentTime = 0;
     38  assert_equals(animation.startTime, null,
     39                'Start time should still be unresolved after setting current'
     40                + ' time');
     41 
     42  assert_equals(animation.playState, 'paused');
     43 }, 'reports \'paused\' for an animation with a resolved current time and'
     44   + ' unresolved start time')
     45 
     46 test(t => {
     47  const animation = new Animation(
     48    new KeyframeEffect(null, {}, 100 * MS_PER_SEC)
     49  );
     50 
     51  animation.startTime = document.timeline.currentTime;
     52  assert_not_equals(animation.currentTime, null,
     53                    'Current time should be resolved after setting start time');
     54 
     55  assert_equals(animation.playState, 'running');
     56 }, 'reports \'running\' for an animation with a resolved start time and'
     57   + ' current time');
     58 
     59 test(t => {
     60  const animation = new Animation(
     61    new KeyframeEffect(null, {}, 100 * MS_PER_SEC)
     62  );
     63  animation.startTime = document.timeline.currentTime;
     64 
     65  animation.currentTime = 100 * MS_PER_SEC;
     66 
     67  assert_equals(animation.playState, 'finished');
     68 }, 'reports \'finished\' when playback rate > 0 and'
     69   + ' current time = target effect end');
     70 
     71 test(t => {
     72  const animation = new Animation(
     73    new KeyframeEffect(null, {}, 100 * MS_PER_SEC)
     74  );
     75  animation.startTime = document.timeline.currentTime;
     76 
     77  animation.playbackRate = 0;
     78  animation.currentTime = 100 * MS_PER_SEC;
     79 
     80  assert_equals(animation.playState, 'running');
     81 }, 'reports \'running\' when playback rate = 0 and'
     82   + ' current time = target effect end');
     83 
     84 test(t => {
     85  const animation = new Animation(
     86    new KeyframeEffect(null, {}, 100 * MS_PER_SEC)
     87  );
     88  animation.startTime = document.timeline.currentTime;
     89 
     90  animation.playbackRate = -1;
     91  animation.currentTime = 100 * MS_PER_SEC;
     92 
     93  assert_equals(animation.playState, 'running');
     94 }, 'reports \'running\' when playback rate < 0 and'
     95   + ' current time = target effect end');
     96 
     97 test(t => {
     98  const animation = new Animation(
     99    new KeyframeEffect(null, {}, 100 * MS_PER_SEC)
    100  );
    101  animation.startTime = document.timeline.currentTime;
    102 
    103  animation.currentTime = 0;
    104 
    105  assert_equals(animation.playState, 'running');
    106 }, 'reports \'running\' when playback rate > 0 and'
    107   + ' current time = 0');
    108 
    109 test(t => {
    110  const animation = new Animation(
    111    new KeyframeEffect(null, {}, 100 * MS_PER_SEC)
    112  );
    113  animation.startTime = document.timeline.currentTime;
    114 
    115  animation.playbackRate = 0;
    116  animation.currentTime = 0;
    117 
    118  assert_equals(animation.playState, 'running');
    119 }, 'reports \'running\' when playback rate = 0 and'
    120   + ' current time = 0');
    121 
    122 test(t => {
    123  const animation = new Animation(
    124    new KeyframeEffect(null, {}, 100 * MS_PER_SEC)
    125  );
    126  animation.startTime = document.timeline.currentTime;
    127 
    128  animation.playbackRate = -1;
    129  animation.currentTime = 0;
    130 
    131  assert_equals(animation.playState, 'finished');
    132 }, 'reports \'finished\' when playback rate < 0 and'
    133   + ' current time = 0');
    134 
    135 test(t => {
    136  const animation = createDiv(t).animate({}, 0);
    137  assert_equals(animation.startTime, null,
    138                'Sanity check: start time should be unresolved');
    139 
    140  assert_equals(animation.playState, 'finished');
    141 }, 'reports \'finished\' when playback rate > 0 and'
    142   + ' current time = target effect end and there is a pending play task');
    143 
    144 test(t => {
    145  const animation = createDiv(t).animate({}, 100 * MS_PER_SEC);
    146  assert_equals(animation.startTime, null,
    147                'Sanity check: start time should be unresolved');
    148 
    149  assert_equals(animation.playState, 'running');
    150 }, 'reports \'running\' when playback rate > 0 and'
    151   + ' current time < target effect end and there is a pending play task');
    152 
    153 test(t => {
    154  const animation = createDiv(t).animate({}, 100 * MS_PER_SEC);
    155  assert_equals(animation.playState, 'running');
    156  assert_true(animation.pending);
    157 }, 'reports \'running\' for a play-pending animation');
    158 
    159 test(t => {
    160  const animation = createDiv(t).animate({}, 100 * MS_PER_SEC);
    161  animation.pause();
    162  assert_equals(animation.playState, 'paused');
    163  assert_true(animation.pending);
    164 }, 'reports \'paused\' for a pause-pending animation');
    165 
    166 test(t => {
    167  const animation = createDiv(t).animate({}, 0);
    168  assert_equals(animation.playState, 'finished');
    169  assert_true(animation.pending);
    170 }, 'reports \'finished\' for a finished-pending animation');
    171 
    172 test(t => {
    173  const animation = createDiv(t).animate({}, 100 * MS_PER_SEC);
    174  // Set up the pending playback rate
    175  animation.updatePlaybackRate(-1);
    176  // Call play again so that we seek to the end while remaining play-pending
    177  animation.play();
    178  // For a pending animation, the play state should always report what the
    179  // play state _will_ be once we finish pending.
    180  assert_equals(animation.playState, 'running');
    181  assert_true(animation.pending);
    182 }, 'reports the play state based on the pending playback rate');
    183 
    184 </script>
    185 </body>