瀏覽代碼

LibWeb: Add a test to ensure style invalidations don't reset animations

Matthew Olsson 1 年之前
父節點
當前提交
43b0b3fa80

+ 1 - 0
Tests/LibWeb/Text/expected/WebAnimations/misc/animation-single-iteration-no-repeat.txt

@@ -0,0 +1 @@
+   finish count: 1

+ 34 - 0
Tests/LibWeb/Text/input/WebAnimations/misc/animation-single-iteration-no-repeat.html

@@ -0,0 +1,34 @@
+<!-- https://github.com/SerenityOS/serenity/issues/23716 -->
+<!DOCTYPE html>
+<style>
+    #foo {
+        animation: anim .025s;
+    }
+    @keyframes anim {
+        from {
+            opacity: 0;
+        }
+        to {
+            opacity: 1;
+        }
+    }
+</style>
+<div id="foo"></div>
+<script src="../../include.js"></script>
+<script>
+    asyncTest(done => {
+        const foo = document.getElementById("foo");
+        let finishCount = 0;
+        foo.getAnimations()[0].onfinish = () => {
+            finishCount += 1;
+        }
+
+        // Cause a few style invalidations, which shouldn't mess with the animation at all
+        setInterval(() => foo.style = "", 50);
+
+        setTimeout(() => {
+            println(`finish count: ${finishCount}`);
+            done();
+        }, 200);
+    })
+</script>