mirror of
https://github.com/servo/servo.git
synced 2025-08-30 01:28:21 +01:00
Update web-platform-tests to revision 388ba3a049a3473b1945b9f8f81e9d6e342a249e
This commit is contained in:
parent
43e21dc845
commit
bdaf11b099
139 changed files with 3089 additions and 807 deletions
|
@ -30,3 +30,9 @@ function waitForAsyncAnimationFrames(count) {
|
|||
// AnimationWorklet.
|
||||
return waitForAnimationFrames(count + 1);
|
||||
}
|
||||
|
||||
async function waitForAnimationFrameWithCondition(condition) {
|
||||
do {
|
||||
await new Promise(window.requestAnimationFrame);
|
||||
} while (!condition())
|
||||
};
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<style>
|
||||
#box {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
transform: translateY(100px);
|
||||
background-color: green;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div id="box"></div>
|
|
@ -0,0 +1,37 @@
|
|||
<!DOCTYPE html>
|
||||
<html class="reftest-wait">
|
||||
<title>Verify that calling pause immediately after playing works as expected</title>
|
||||
<link rel="help" href="https://drafts.css-houdini.org/css-animationworklet/">
|
||||
<link rel="match" href="references/translated-box-ref.html">
|
||||
|
||||
<script src="/common/reftest-wait.js"></script>
|
||||
<script src="/web-animations/testcommon.js"></script>
|
||||
<script src="common.js"></script>
|
||||
<style>
|
||||
#box {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
background-color: green;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div id="box"></div>
|
||||
|
||||
<script>
|
||||
registerPassthroughAnimator().then(async _ => {
|
||||
const box = document.getElementById('box');
|
||||
const effect = new KeyframeEffect(box,
|
||||
{ transform: ['translateY(100px)', 'translateY(200px)'] },
|
||||
{ duration: 100, iterations: 1 }
|
||||
);
|
||||
|
||||
const animation = new WorkletAnimation('passthrough', effect);
|
||||
animation.play();
|
||||
// Immediately pausing animation should freeze the current time at 0.
|
||||
animation.pause();
|
||||
// Wait at least one frame to ensure a paused animation actually freezes.
|
||||
await waitForAsyncAnimationFrames(1);
|
||||
takeScreenshot();
|
||||
});
|
||||
</script>
|
||||
</html>
|
|
@ -0,0 +1,40 @@
|
|||
<!DOCTYPE html>
|
||||
<html class="reftest-wait">
|
||||
<title>Verify that calling pause immediately after playing works as expected</title>
|
||||
<link rel="help" href="https://drafts.css-houdini.org/css-animationworklet/">
|
||||
<link rel="match" href="references/translated-box-ref.html">
|
||||
|
||||
<script src="/common/reftest-wait.js"></script>
|
||||
<script src="common.js"></script>
|
||||
<style>
|
||||
#box {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
background-color: green;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div id="box"></div>
|
||||
|
||||
<script>
|
||||
registerPassthroughAnimator().then(async _ => {
|
||||
const duration = 18; // a bit longer than a frame
|
||||
const box = document.getElementById('box');
|
||||
const effect = new KeyframeEffect(box,
|
||||
{ transform: ['translateY(0px)', 'translateY(100px)'] },
|
||||
{ duration: duration, iterations: 1, fill: 'forwards'}
|
||||
);
|
||||
|
||||
const animation = new WorkletAnimation('passthrough', effect);
|
||||
// Immediately pausing animation should freeze the current time at 0.
|
||||
animation.pause();
|
||||
// Playing should cause animation to resume.
|
||||
animation.play();
|
||||
// Wait until we ensure animation has reached completion.
|
||||
await waitForAnimationFrameWithCondition( _ => {
|
||||
return animation.currentTime >= duration;
|
||||
});
|
||||
takeScreenshot();
|
||||
});
|
||||
</script>
|
||||
</html>
|
|
@ -0,0 +1,58 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Verify that currentTime and playState are correct when animation is paused</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>
|
||||
|
||||
<div id="box"></div>
|
||||
|
||||
<script>
|
||||
|
||||
setup(setupAndRegisterTests, {explicit_done: true});
|
||||
|
||||
function createAnimation() {
|
||||
const box = document.getElementById('box');
|
||||
const effect = new KeyframeEffect(box,
|
||||
{ transform: ['translateY(100px)', 'translateY(200px)'] },
|
||||
{ duration: 100, iterations: 1 }
|
||||
);
|
||||
|
||||
return new WorkletAnimation('passthrough', effect);
|
||||
}
|
||||
|
||||
async function setupAndRegisterTests() {
|
||||
await registerPassthroughAnimator();
|
||||
|
||||
promise_test(async t => {
|
||||
const animation = createAnimation();
|
||||
animation.play();
|
||||
// Immediately pausing animation should freeze the current time at 0.
|
||||
animation.pause();
|
||||
assert_equals(animation.currentTime, 0);
|
||||
assert_equals(animation.playState, "paused");
|
||||
// Wait some time to ensure a paused animation actually freezes.
|
||||
await waitForNextFrame();
|
||||
assert_equals(animation.currentTime, 0);
|
||||
assert_equals(animation.playState, "paused");
|
||||
}, 'pausing an animation freezes its current time');
|
||||
|
||||
promise_test(async t => {
|
||||
const animation = createAnimation();
|
||||
const startTime = document.timeline.currentTime;
|
||||
animation.pause();
|
||||
animation.play();
|
||||
await waitForNextFrame();
|
||||
const timelineTime = document.timeline.currentTime;
|
||||
assert_equals(animation.playState, "running");
|
||||
assert_greater_than(animation.currentTime, 0);
|
||||
assert_times_equal(animation.currentTime, (timelineTime - startTime));
|
||||
}, 'playing a paused animation should resume it');
|
||||
|
||||
done();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue