Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /css/css-animations/animation-iteration-event-001.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>CSS Animations Test: animation events - animationiteration</title>
<link rel="author" title="Oriol Brufau" href="mailto:obrufau@igalia.com">
<link rel="help" href="https://drafts.csswg.org/css-animations-1/#eventdef-globaleventhandlers-animationiteration">
<style>
@keyframes anim {}
:root { animation: 1s -4s 7 anim paused }
</style>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
promise_test(async () => {
let elapsedTimes = [];
let element = document.documentElement;
element.style.animationPlayState = "running";
await new Promise((resolve) => {
let listener = e => {
elapsedTimes.push(e.elapsedTime);
};
element.addEventListener("animationiteration", listener);
element.addEventListener("animationend", () => {
element.removeEventListener("animationiteration", listener);
resolve();
}, { once: true });
});
assert_array_equals(elapsedTimes, [5, 6]);
}, "Got the expected elapsedTime in the correct order");
</script>