gecko-dev/testing/web-platform/tests/web-animations/interfaces/KeyframeEffect/setKeyframes.html
Stephen McGruer 7c797649ee Bug 1456650 [wpt PR 10618] - Make KeyframeEffectReadOnly::setKeyframes take effect immediately, a=testonly
Automatic update from web-platform-testsMake KeyframeEffectReadOnly::setKeyframes take effect immediately

Previously we wouldn't notice that the keyframes had changed until the
next animation update. This CL fixes that by clearing any cached sampled
effects and notifying the owning Animation that it needs to invalidate
it's information.

This also fixes updating composited animations; invalidating the effect
on the animation causes us to properly restart the composited animation.

Bug: 799061, 835824
Change-Id: Ib307a5409c52c5dab1ee0f98c989d7dbaef42937
Reviewed-on: https://chromium-review.googlesource.com/1026700
Commit-Queue: Stephen McGruer <smcgruer@chromium.org>
Reviewed-by: Majid Valipour <majidvp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#554484}

--

wpt-commits: e7d3e5206b87ece7e9c80b46a21740d508f924da
wpt-pr: 10618
2018-05-02 07:48:52 +01:00

55 lines
1.8 KiB
HTML

<!DOCTYPE html>
<meta charset=utf-8>
<title>KeyframeEffect.setKeyframes</title>
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-keyframeeffect-setkeyframes">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../testcommon.js"></script>
<script src="../../resources/keyframe-utils.js"></script>
<script src="../../resources/keyframe-tests.js"></script>
<body>
<div id="log"></div>
<div id="target"></div>
<script>
'use strict';
const target = document.getElementById('target');
test(t => {
for (const frame of gEmptyKeyframeListTests) {
const effect = new KeyframeEffect(target, {});
effect.setKeyframes(frame);
assert_frame_lists_equal(effect.getKeyframes(), []);
}
}, 'Keyframes can be replaced with an empty keyframe');
for (const subtest of gKeyframesTests) {
test(t => {
const effect = new KeyframeEffect(target, {});
effect.setKeyframes(subtest.input);
assert_frame_lists_equal(effect.getKeyframes(), subtest.output);
}, `Keyframes can be replaced with ${subtest.desc}`);
}
for (const subtest of gInvalidKeyframesTests) {
test(t => {
const effect = new KeyframeEffect(target, {});
assert_throws(new TypeError, () => {
effect.setKeyframes(subtest.input);
});
}, `KeyframeEffect constructor throws with ${subtest.desc}`);
}
test(t => {
const frames1 = [ { left: '100px' }, { left: '200px' } ];
const frames2 = [ { left: '200px' }, { left: '300px' } ];
const animation = target.animate(frames1, 1000);
animation.currentTime = 500;
assert_equals(getComputedStyle(target).left, "150px");
animation.effect.setKeyframes(frames2);
assert_equals(getComputedStyle(target).left, "250px");
}, 'Changes made via setKeyframes should be immediately visible in style');
</script>
</body>