mirror of
https://github.com/servo/servo.git
synced 2025-10-04 02:29:12 +01:00
48 lines
1.7 KiB
HTML
48 lines
1.7 KiB
HTML
<!DOCTYPE html>
|
|
<meta charset=utf-8>
|
|
<title>The current time of a worklet animation</title>
|
|
<link rel="help" href="https://drafts.css-houdini.org/css-animationworklet/">
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script src="/web-animations/testcommon.js"></script>
|
|
<script src="common.js"></script>
|
|
<body>
|
|
<div id="log"></div>
|
|
<script>
|
|
'use strict';
|
|
|
|
const DURATION = 10000; // ms
|
|
const KEYFRAMES = { height : ['100px', '50px'] };
|
|
|
|
promise_test(async t => {
|
|
await registerPassthroughAnimator();
|
|
const animation =
|
|
new WorkletAnimation('passthrough', new KeyframeEffect(createDiv(t),
|
|
KEYFRAMES, DURATION), document.timeline);
|
|
|
|
animation.play();
|
|
assert_equals(animation.currentTime, 0,
|
|
'Current time returns the hold time set when entering the play-pending' +
|
|
'state');
|
|
}, 'The current time returns the hold time when set');
|
|
|
|
promise_test(async t => {
|
|
await registerPassthroughAnimator();
|
|
const animation =
|
|
new WorkletAnimation('passthrough', new KeyframeEffect(createDiv(t),
|
|
KEYFRAMES, DURATION), document.timeline);
|
|
|
|
// TODO(majidvp): We should use Animation.startTime here because the
|
|
// animation may not immediately start.
|
|
const startTime = document.timeline.currentTime;
|
|
animation.play();
|
|
await waitForNextFrame();
|
|
const timelineTime = document.timeline.currentTime;
|
|
assert_times_equal(animation.currentTime, (timelineTime - startTime));
|
|
}, 'The current time is calculated from the timeline time and start time');
|
|
|
|
// TODO(majidvp): Add tests for playbackRate and animations that are not
|
|
// associated with a timeline once these are supported in WorkletAnimation.
|
|
// http://crbug.com/833846
|
|
</script>
|
|
</body>
|