tor-browser

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

pause.html (3327B)


      1 <!DOCTYPE html>
      2 <meta charset=utf-8>
      3 <title>Animation.pause</title>
      4 <link rel="help" href="https://drafts.csswg.org/web-animations/#dom-animation-pause">
      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 promise_test(t => {
     14  const div = createDiv(t);
     15  const animation = div.animate({}, 1000 * MS_PER_SEC);
     16  let previousCurrentTime = animation.currentTime;
     17 
     18  return animation.ready.then(waitForAnimationFrames(1)).then(() => {
     19    assert_true(animation.currentTime >= previousCurrentTime,
     20                'currentTime is initially increasing');
     21    animation.pause();
     22    return animation.ready;
     23  }).then(() => {
     24    previousCurrentTime = animation.currentTime;
     25    return waitForAnimationFrames(1);
     26  }).then(() => {
     27    assert_equals(animation.currentTime, previousCurrentTime,
     28                  'currentTime does not increase after calling pause()');
     29  });
     30 }, 'pause() a running animation');
     31 
     32 promise_test(t => {
     33  const div = createDiv(t);
     34  const animation = div.animate({}, 1000 * MS_PER_SEC);
     35 
     36  // Go to idle state then pause
     37  animation.cancel();
     38  animation.pause();
     39 
     40  assert_equals(animation.currentTime, 0, 'currentTime is set to 0');
     41  assert_equals(animation.startTime, null, 'startTime is not set');
     42  assert_equals(animation.playState, 'paused', 'in paused play state');
     43  assert_true(animation.pending, 'initially pause-pending');
     44 
     45  // Check it still resolves as expected
     46  return animation.ready.then(() => {
     47    assert_false(animation.pending, 'no longer pending');
     48    assert_equals(animation.currentTime, 0,
     49                  'keeps the initially set currentTime');
     50  });
     51 }, 'pause() from idle');
     52 
     53 promise_test(t => {
     54  const div = createDiv(t);
     55  const animation = div.animate({}, 1000 * MS_PER_SEC);
     56  animation.cancel();
     57  animation.playbackRate = -1;
     58  animation.pause();
     59 
     60  assert_equals(animation.currentTime, 1000 * MS_PER_SEC,
     61                'currentTime is set to the effect end');
     62 
     63  return animation.ready.then(() => {
     64    assert_equals(animation.currentTime, 1000 * MS_PER_SEC,
     65                  'keeps the initially set currentTime');
     66  });
     67 }, 'pause() from idle with a negative playbackRate');
     68 
     69 test(t => {
     70  const div = createDiv(t);
     71  const animation = div.animate({}, {duration: 1000 * MS_PER_SEC,
     72                                   iterations: Infinity});
     73  animation.cancel();
     74  animation.playbackRate = -1;
     75 
     76  assert_throws_dom('InvalidStateError',
     77                    () => { animation.pause(); },
     78                    'Expect InvalidStateError exception on calling pause() ' +
     79                    'from idle with a negative playbackRate and ' +
     80                'infinite-duration animation');
     81 }, 'pause() from idle with a negative playbackRate and endless effect');
     82 
     83 promise_test(t => {
     84  const div = createDiv(t);
     85  const animation = div.animate({}, 1000 * MS_PER_SEC);
     86  return animation.ready
     87    .then(animation => {
     88      animation.finish();
     89      animation.pause();
     90      return animation.ready;
     91    }).then(animation => {
     92      assert_equals(animation.currentTime, 1000 * MS_PER_SEC,
     93                    'currentTime after pausing finished animation');
     94    });
     95 }, 'pause() on a finished animation');
     96 
     97 </script>
     98 </body>