mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:57:44 +00:00
LibWeb: Add tests for the rest of the Animation properties
This commit is contained in:
parent
e91f4dcd79
commit
dc47210360
10 changed files with 164 additions and 0 deletions
|
@ -0,0 +1,35 @@
|
|||
<!DOCTYPE html>
|
||||
<div id="foo"></div>
|
||||
<script src="../../include.js"></script>
|
||||
<script>
|
||||
asyncTest(async done => {
|
||||
const wait = async (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
||||
|
||||
const foo = document.getElementById("foo");
|
||||
const animation = foo.animate({ opacity: [0, 1] }, { duration: 1000 });
|
||||
animation.playbackRate = 2;
|
||||
|
||||
// Allow 50ms of error for each test
|
||||
await wait(100);
|
||||
if (animation.currentTime >= 150 && animation.currentTime <= 250)
|
||||
println("Animation has expected currentTime value after 100ms");
|
||||
|
||||
animation.playbackRate = 0.5;
|
||||
await wait(100);
|
||||
if (animation.currentTime >= 200 && animation.currentTime <= 300)
|
||||
println("Animation has expected currentTime value after 200ms");
|
||||
|
||||
animation.playbackRate = -1;
|
||||
await wait(100);
|
||||
if (animation.currentTime >= 100 && animation.currentTime <= 200)
|
||||
println("Animation has expected currentTime value after 300ms");
|
||||
|
||||
animation.playbackRate = 0;
|
||||
const originalTime = animation.currentTime;
|
||||
await wait(100);
|
||||
if (animation.currentTime === originalTime)
|
||||
println("Animation has expected currentTime value after 400ms");
|
||||
|
||||
done();
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue