blob: f115ccf46f95a5f43d28cabcbb6fa36baeda3166 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
<script src="resources/lifecycle-utilities.js"></script>
<style>
@keyframes fade-in {
from {
color: red;
opacity: 0;
}
50% {
color: green;
opacity: 0.5;
}
to {
color: blue;
opacity: 1;
}
}
div#target.active {
animation-name: fade-in;
animation-duration: 400ms;
animation-timing-function: cubic-bezier(0.1, 0.2, 0.3, 0.4);
animation-delay: 100ms;
animation-direction: alternate;
animation-fill-mode: both;
}
div#target.active.finite {
animation-iteration-count: 2;
}
div#target.active.infinite {
animation-iteration-count: infinite;
}
</style>
<script>
function test()
{
let suite = InspectorTest.createAsyncSuite("Animation.Lifecycle");
suite.addTestCase({
name: "Animation.Lifecycle.CSSAnimation.Finite",
description: "Check that Web Inspector is notified whenever CSS animations are created/destroyed.",
async test() {
InspectorTest.expectEqual(WI.animationManager.animationCollection.size, 0, "There should not be any animations.");
let [animation] = await Promise.all([
InspectorTest.AnimationLifecycleUtilities.awaitAnimationCreated(WI.Animation.Type.CSSAnimation),
InspectorTest.evaluateInPage(`document.getElementById("target").classList.add("active", "finite")`),
]);
await Promise.all([
InspectorTest.AnimationLifecycleUtilities.awaitAnimationDestroyed(animation.animationId),
InspectorTest.AnimationLifecycleUtilities.destroyAnimations(),
InspectorTest.evaluateInPage(`document.getElementById("target").classList.remove("active", "finite")`),
]);
},
});
suite.addTestCase({
name: "Animation.Lifecycle.CSSAnimation.Infinite",
description: "Check that Web Inspector is notified whenever CSS animations are created/destroyed.",
async test() {
InspectorTest.expectEqual(WI.animationManager.animationCollection.size, 0, "There should not be any animations.");
let [animation] = await Promise.all([
InspectorTest.AnimationLifecycleUtilities.awaitAnimationCreated(WI.Animation.Type.CSSAnimation),
InspectorTest.evaluateInPage(`document.getElementById("target").classList.add("active", "infinite")`),
]);
await Promise.all([
InspectorTest.AnimationLifecycleUtilities.awaitAnimationDestroyed(animation.animationId),
InspectorTest.AnimationLifecycleUtilities.destroyAnimations(),
InspectorTest.evaluateInPage(`document.getElementById("target").classList.remove("active", "infinite")`),
]);
},
});
suite.runTestCasesAndFinish();
}
</script>
</head>
<body onload="runTest()">
<p>Tests for the Animation.animationCreated and Animation.animationDestroyed events.</p>
<div id="target"></div>
</body>
</html>