1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
7 <title>Test simple animation with fill modes and non integer iteration count</title>
8 <style type="text/css" media="screen">
15 -webkit-animation-delay: 0.1s;
16 -webkit-animation-duration: 0.2s;
17 -webkit-animation-timing-function: linear;
18 -webkit-animation-name: anim;
20 @-webkit-keyframes anim {
25 background-color: blue;
26 -webkit-animation-fill-mode: none;
27 -webkit-animation-iteration-count: 1.5;
30 background-color: red;
31 -webkit-animation-fill-mode: backwards;
32 -webkit-animation-iteration-count: 0.5;
35 background-color: green;
36 -webkit-animation-fill-mode: forwards;
37 -webkit-animation-iteration-count: 1.5;
40 background-color: yellow;
41 -webkit-animation-fill-mode: both;
42 -webkit-animation-iteration-count: 1.5;
45 background-color: #999;
46 -webkit-animation-fill-mode: both;
47 -webkit-animation-iteration-count: 2.5;
48 -webkit-animation-direction: alternate;
51 <script type="text/javascript" charset="utf-8">
53 var animsFinished = 0;
55 const expectedValues = [
56 {id: "a", start: 100, end: 100},
57 {id: "b", start: 200, end: 100},
58 {id: "c", start: 100, end: 300},
59 {id: "d", start: 200, end: 300},
60 {id: "e", start: 200, end: 300}
64 if (window.layoutTestController) {
65 layoutTestController.dumpAsText();
66 layoutTestController.waitUntilDone();
69 function animationEnded(event) {
70 if (++animsFinished == numAnims) {
71 setTimeout(endTest, 0); // this set timeout should be ok in the test environment
72 // since we're just giving style a chance to resolve
78 for (var i=0; i < expectedValues.length; i++) {
79 var el = document.getElementById(expectedValues[i].id);
80 var expectedValue = expectedValues[i].end;
81 var realValue = window.getComputedStyle(el).getPropertyCSSValue("left").getFloatValue(CSSPrimitiveValue.CSS_NUMBER);
82 if (Math.abs(expectedValue - realValue) < allowance) {
87 result += " - end of animation - id: " + expectedValues[i].id + " expected: " + expectedValue + " actual: " + realValue + "<br>";
89 document.getElementById('result').innerHTML = result;
91 if (window.layoutTestController)
92 layoutTestController.notifyDone();
95 window.onload = function () {
96 for (var i=0; i < expectedValues.length; i++) {
97 var el = document.getElementById(expectedValues[i].id);
98 var expectedValue = expectedValues[i].start;
99 var realValue = window.getComputedStyle(el).getPropertyCSSValue("left").getFloatValue(CSSPrimitiveValue.CSS_NUMBER);
100 if (Math.abs(expectedValue - realValue) < allowance) {
105 result += " - start of animation - id: " + expectedValues[i].id + " expected: " + expectedValue + " actual: " + realValue + "<br>";
107 document.addEventListener("webkitAnimationEnd", animationEnded, false);
113 This test performs an animation of the left property with four different
114 fill modes. It animates over 0.1 second with a 0.1 second delay.
115 It takes snapshots at document load and the end of the animation.
116 <div id="a" class="box">
119 <div id="b" class="box">
122 <div id="c" class="box">
125 <div id="d" class="box">
128 <div id="e" class="box">