Commit c8711793 authored by Yi Gu's avatar Yi Gu Committed by Commit Bot

[Animation Worklet] Clean up animator registration logic for wpt test...

[Animation Worklet] Clean up animator registration logic for wpt test worklet-animation-with-fill-mode.https.html

Similar to [1], we should register the animator only once in the setup.

[1] https://cs.chromium.org/chromium/src/third_party/blink/web_tests/external/wpt/animation-worklet/scroll-timeline-writing-modes.https.html

Bug: 923881
Change-Id: I0f6761b7753aacdf3ebe6d8ed63fe4e0ea183e25
Reviewed-on: https://chromium-review.googlesource.com/c/1448519Reviewed-by: default avatarStephen McGruer <smcgruer@chromium.org>
Commit-Queue: Yi Gu <yigu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#628460}
parent f2e58c31
...@@ -14,83 +14,146 @@ ...@@ -14,83 +14,146 @@
} }
</style> </style>
<div id="target" class='target'></div>
<script> <script>
function CreateTest(target, effect, verify, test_name) { setup(setupAndRegisterTests, {explicit_done: true});
promise_test(async function() {
await registerConstantLocalTimeAnimator(2000);
const animation = new WorkletAnimation('constant_time', effect);
animation.play();
await waitForAsyncAnimationFrames(1); function setupAndRegisterTests() {
// waitTwoAnimationFrames guarantees a compositor frame that could update registerConstantLocalTimeAnimator(2000).then(() => {
// the opacity value in the worklet. Meanwhile, getComputedStyle needs an promise_test(
// extra frame to fetch the updated value. effect_with_fill_mode_forwards,
await waitForNextFrame(); "Effect with fill mode forwards in after phase produces output that is equivalent to effect's end value.");
verify();
animation.cancel();
}, test_name);
}
</script>
<div id="target1" class='target'></div> promise_test(
<div id="target2" class='target'></div> effect_without_fill_mode_forwards,
<div id="target3" class='target'></div> 'Effect without fill mode forwards in after phase (local time beyond end) should deactivate the animation.');
<div id="target4" class='target'></div>
<div id="target5" class='target'></div>
<div id="target6" class='target'></div>
<script> promise_test(
effect_without_fill_forwards_at_end,
'Effect without fill mode in after phase (local time at end) should deactivate the animation.');
promise_test(
effect_with_fill_backwards,
"Effect with fill mode backwards in before phase produces output that is equivalent to effect's start value.");
promise_test(
effect_without_fill_backwards,
'Effect without fill mode backwards in before phase (local time before start) should deactivate the animation.');
promise_test(
effect_without_fill_backwards_at_start,
'Effect with local time at start point is in active phase.');
done();
});
}
async function effect_with_fill_mode_forwards(t) {
const effect_with_fill_forwards = new KeyframeEffect( const effect_with_fill_forwards = new KeyframeEffect(
target1, target,
{ opacity: [0.5, 0] }, { opacity: [0.5, 0] },
{ duration: 1000, fill: 'forwards' }); { duration: 1000, fill: 'forwards' });
CreateTest(target1, const animation = new WorkletAnimation(
effect_with_fill_forwards, 'constant_time',
function() { assert_equals(getComputedStyle(target1).opacity, '0'); }, effect_with_fill_forwards);
"Effect with fill mode forwards in after phase produces output that is equivalent to effect's end value."); animation.play();
await waitForAsyncAnimationFrames(1);
await waitForNextFrame();
assert_equals(getComputedStyle(target).opacity, '0');
animation.cancel();
}
async function effect_without_fill_mode_forwards(t) {
const effect_without_fill_forwards = new KeyframeEffect( const effect_without_fill_forwards = new KeyframeEffect(
target2, target,
{ opacity: [0.5, 0] }, { opacity: [0.5, 0] },
{ duration: 1000 }); { duration: 1000 });
CreateTest(target2, const animation = new WorkletAnimation(
effect_without_fill_forwards, 'constant_time',
function() { assert_equals(getComputedStyle(target2).opacity, '1'); }, effect_without_fill_forwards);
'Effect without fill mode forwards in after phase (local time beyond end) should deactivate the animation.'); animation.play();
await waitForAsyncAnimationFrames(1);
await waitForNextFrame();
assert_equals(getComputedStyle(target).opacity, '1');
animation.cancel();
}
async function effect_without_fill_forwards_at_end(t) {
const effect_without_fill_forwards_at_end = new KeyframeEffect( const effect_without_fill_forwards_at_end = new KeyframeEffect(
target3, target,
{ opacity: [0.5, 0] }, { opacity: [0.5, 0] },
{ duration: 2000 }); { duration: 2000 });
CreateTest(target3, const animation = new WorkletAnimation(
effect_without_fill_forwards_at_end, 'constant_time',
function() { assert_equals(getComputedStyle(target3).opacity, '1'); }, effect_without_fill_forwards_at_end);
'Effect without fill mode in after phase (local time at end) should deactivate the animation.'); animation.play();
await waitForAsyncAnimationFrames(1);
await waitForNextFrame();
assert_equals(getComputedStyle(target).opacity, '1');
animation.cancel();
}
async function effect_with_fill_backwards(t) {
const effect_with_fill_backwards = new KeyframeEffect( const effect_with_fill_backwards = new KeyframeEffect(
target4, target,
{ opacity: [0.5, 0] }, { opacity: [0.5, 0] },
{ duration: 1000, delay: 2001, fill: 'backwards' }); { duration: 1000, delay: 2001, fill: 'backwards' });
CreateTest(target4, const animation = new WorkletAnimation(
effect_with_fill_backwards, 'constant_time',
function() { assert_equals(getComputedStyle(target4).opacity, '0.5'); }, effect_with_fill_backwards);
"Effect with fill mode backwards in before phase produces output that is equivalent to effect's start value."); animation.play();
await waitForAsyncAnimationFrames(1);
await waitForNextFrame();
assert_equals(getComputedStyle(target).opacity, '0.5');
animation.cancel();
}
async function effect_without_fill_backwards(t) {
const effect_without_fill_backwards = new KeyframeEffect( const effect_without_fill_backwards = new KeyframeEffect(
target5, target,
{ opacity: [0.5, 0] }, { opacity: [0.5, 0] },
{ duration: 1000, delay: 2001 }); { duration: 1000, delay: 2001 });
CreateTest(target5, const animation = new WorkletAnimation(
effect_without_fill_backwards, 'constant_time',
function() { assert_equals(getComputedStyle(target5).opacity, '1'); }, effect_without_fill_backwards);
'Effect without fill mode backwards in before phase (local time before start) should deactivate the animation.'); animation.play();
await waitForAsyncAnimationFrames(1);
await waitForNextFrame();
assert_equals(getComputedStyle(target).opacity, '1');
animation.cancel();
}
async function effect_without_fill_backwards_at_start(t) {
const effect_without_fill_backwards_at_start = new KeyframeEffect( const effect_without_fill_backwards_at_start = new KeyframeEffect(
target6, target,
{ opacity: [0.5, 0] }, { opacity: [0.5, 0] },
{ duration: 1000, delay: 2000 }); { duration: 1000, delay: 2000 });
CreateTest(target6, const animation = new WorkletAnimation(
effect_without_fill_backwards_at_start, 'constant_time',
function() { assert_equals(getComputedStyle(target6).opacity, '0.5'); }, effect_without_fill_backwards_at_start);
'Effect with local time at start point is in active phase.'); animation.play();
await waitForAsyncAnimationFrames(1);
await waitForNextFrame();
assert_equals(getComputedStyle(target).opacity, '0.5');
animation.cancel();
}
</script> </script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment