tor-browser

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

setKeyframes.html (1843B)


      1 <!DOCTYPE html>
      2 <meta charset=utf-8>
      3 <title>KeyframeEffect.setKeyframes</title>
      4 <link rel="help" href="https://drafts.csswg.org/web-animations/#dom-keyframeeffect-setkeyframes">
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <script src="../../testcommon.js"></script>
      8 <script src="../../resources/keyframe-utils.js"></script>
      9 <script src="../../resources/keyframe-tests.js"></script>
     10 <body>
     11 <div id="log"></div>
     12 <div id="target"></div>
     13 <script>
     14 'use strict';
     15 
     16 const target = document.getElementById('target');
     17 
     18 test(t => {
     19  for (const frame of gEmptyKeyframeListTests) {
     20    const effect = new KeyframeEffect(target, {});
     21    effect.setKeyframes(frame);
     22    assert_frame_lists_equal(effect.getKeyframes(), []);
     23  }
     24 }, 'Keyframes can be replaced with an empty keyframe');
     25 
     26 for (const subtest of gKeyframesTests) {
     27  test(t => {
     28    const effect = new KeyframeEffect(target, {});
     29    effect.setKeyframes(subtest.input);
     30    assert_frame_lists_equal(effect.getKeyframes(), subtest.output);
     31  }, `Keyframes can be replaced with ${subtest.desc}`);
     32 }
     33 
     34 for (const subtest of gInvalidKeyframesTests) {
     35  test(t => {
     36    const effect = new KeyframeEffect(target, {});
     37    assert_throws_js(TypeError, () => {
     38      effect.setKeyframes(subtest.input);
     39    });
     40  }, `KeyframeEffect constructor throws with ${subtest.desc}`);
     41 }
     42 
     43 test(t => {
     44  const frames1 = [ { left: '100px' }, { left: '200px' } ];
     45  const frames2 = [ { left: '200px' }, { left: '300px' } ];
     46 
     47  const animation = target.animate(frames1, 1000);
     48  animation.currentTime = 500;
     49  assert_equals(getComputedStyle(target).left, "150px");
     50 
     51  animation.effect.setKeyframes(frames2);
     52  assert_equals(getComputedStyle(target).left, "250px");
     53 }, 'Changes made via setKeyframes should be immediately visible in style');
     54 </script>
     55 </body>