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
|
<!doctype html>
<meta charset=utf-8>
<title>AnimationEffect.updateTiming() for CSS animations</title>
<!-- TODO: Add a more specific link for this once it is specified. -->
<link rel="help" href="https://drafts.csswg.org/css-animations-2/">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support/testcommon.js"></script>
<style>
@keyframes anim-empty { }
</style>
<body>
<div id="log"></div>
<script>
"use strict";
test(t => {
const div = addDiv(t);
div.style.animation = 'anim-empty 100s';
const animation = div.getAnimations()[0];
animation.effect.updateTiming({ duration: 2 * MS_PER_SEC });
div.style.animationDuration = '4s';
div.style.animationDelay = '6s';
assert_equals(
animation.effect.getTiming().duration,
2 * MS_PER_SEC,
'Duration should be the value set by the API'
);
assert_equals(
animation.effect.getTiming().delay,
6 * MS_PER_SEC,
'Delay should be the value set by style'
);
}, 'AnimationEffect.updateTiming({ duration }) causes changes to the'
+ ' animation-duration to be ignored');
// The above test covers duration (with delay as a control). The remaining
// properties are:
//
// iterations - animation-iteration-count
// direction - animation-direction
// delay - animation-delay
// fill - animation-fill-mode
//
// Which we test in two batches, overriding two properties each time and using
// the remaining two properties as control values to check they are NOT
// overridden.
test(t => {
const div = addDiv(t);
div.style.animation = 'anim-empty 100s';
const animation = div.getAnimations()[0];
animation.effect.updateTiming({ iterations: 2, direction: 'reverse' });
div.style.animationIterationCount = '4';
div.style.animationDirection = 'alternate';
div.style.animationDelay = '6s';
div.style.animationFillMode = 'both';
assert_equals(
animation.effect.getTiming().iterations,
2,
'Iterations should be the value set by the API'
);
assert_equals(
animation.effect.getTiming().direction,
'reverse',
'Direction should be the value set by the API'
);
assert_equals(
animation.effect.getTiming().delay,
6 * MS_PER_SEC,
'Delay should be the value set by style'
);
assert_equals(
animation.effect.getTiming().fill,
'both',
'Fill should be the value set by style'
);
}, 'AnimationEffect.updateTiming({ iterations, direction }) causes changes to'
+ ' the animation-iteration-count and animation-direction to be ignored');
test(t => {
const div = addDiv(t);
div.style.animation = 'anim-empty 100s';
const animation = div.getAnimations()[0];
animation.effect.updateTiming({ delay: 2 * MS_PER_SEC, fill: 'both' });
div.style.animationDelay = '4s';
div.style.animationFillMode = 'forwards';
div.style.animationIterationCount = '6';
div.style.animationDirection = 'reverse';
assert_equals(
animation.effect.getTiming().delay,
2 * MS_PER_SEC,
'Delay should be the value set by the API'
);
assert_equals(
animation.effect.getTiming().fill,
'both',
'Fill should be the value set by the API'
);
assert_equals(
animation.effect.getTiming().iterations,
6,
'Iterations should be the value set by style'
);
assert_equals(
animation.effect.getTiming().direction,
'reverse',
'Direction should be the value set by style'
);
}, 'AnimationEffect.updateTiming({ delay, fill }) causes changes to'
+ ' the animation-delay and animation-fill-mode to be ignored');
test(t => {
const div = addDiv(t);
div.style.animation = 'anim-empty 100s';
const animation = div.getAnimations()[0];
assert_throws_js(TypeError, () => {
animation.effect.updateTiming({ duration: 2 * MS_PER_SEC, iterations: -1 });
}, 'Negative iteration count should cause an error to be thrown');
div.style.animationDuration = '4s';
assert_equals(
animation.effect.getTiming().duration,
4 * MS_PER_SEC,
'Duration should be the value set by style'
);
}, 'AnimationEffect.updateTiming() does override to changes from animation-*'
+ ' properties if there is an error');
test(t => {
const div = addDiv(t);
div.style.animation = 'anim-empty 100s';
const animation = div.getAnimations()[0];
animation.effect.updateTiming({
easing: 'steps(4)',
endDelay: 2 * MS_PER_SEC,
iterationStart: 4,
});
div.style.animationDuration = '6s';
div.style.animationTimingFunction = 'ease-in';
assert_equals(
animation.effect.getTiming().easing,
'steps(4)',
'endDelay should be the value set by the API'
);
assert_equals(
animation.effect.getTiming().endDelay,
2 * MS_PER_SEC,
'endDelay should be the value set by the API'
);
assert_equals(
animation.effect.getTiming().iterationStart,
4,
'iterationStart should be the value set by style'
);
}, 'AnimationEffect properties that do not map to animation-* properties'
+ ' should not be changed when animation-* style is updated');
</script>
</body>
|