5 <title>Test simple animation with fill modes and non integer iteration count
</title>
6 <style type=
"text/css" media=
"screen">
12 -webkit-animation-delay:
0.1s;
13 -webkit-animation-duration:
0.1s;
14 -webkit-animation-timing-function: linear;
15 -webkit-animation-name: anim;
17 @-webkit-keyframes anim {
22 background-color: blue;
23 -webkit-animation-fill-mode: none;
24 -webkit-animation-iteration-count:
1.4;
27 background-color: red;
28 -webkit-animation-fill-mode: backwards;
29 -webkit-animation-iteration-count:
0.4;
32 background-color: green;
33 -webkit-animation-fill-mode: forwards;
34 -webkit-animation-iteration-count:
1.4;
37 background-color: yellow;
38 -webkit-animation-fill-mode: both;
39 -webkit-animation-iteration-count:
1.4;
42 background-color: cyan;
43 -webkit-animation-fill-mode: both;
44 -webkit-animation-iteration-count:
2.4;
45 -webkit-animation-direction: alternate;
47 #both_iterating_reverse {
48 background-color: #
999;
49 -webkit-animation-fill-mode: both;
50 -webkit-animation-iteration-count:
2.4;
51 -webkit-animation-direction: alternate-reverse;
54 <script type=
"text/javascript" charset=
"utf-8">
56 var animsFinished =
0;
57 const expectedValues = [
58 {id:
"none", start:
100, end:
100},
59 {id:
"backwards", start:
200, end:
100},
60 {id:
"forwards", start:
100, end:
240},
61 {id:
"both", start:
200, end:
240},
62 {id:
"both_iterating", start:
200, end:
240},
63 {id:
"both_iterating_reverse", start:
300, end:
260}
67 if (window.testRunner) {
68 testRunner.dumpAsText();
69 testRunner.waitUntilDone();
72 function animationEnded(event) {
73 if (++animsFinished == numAnims) {
74 // This call to setTimeout() should be OK in the test environment
75 // since we're just giving style a chance to resolve.
76 setTimeout(endTest,
0);
80 function log(expected, actual, isStart, id) {
81 var identifier = (isStart ? 'Start' : 'End') + ' of animation for element \'' + id + '\'';
82 if (Math.abs(expected - actual) <
5) {
83 result += 'PASS: ' + identifier + ': Saw something close to ' + expected + '
<br>';
85 result += 'FAIL: ' + identifier + ': Expected ' + expected + ' but saw ' + actual + '
<br>';
90 for (var i=
0; i < expectedValues.length; i++) {
91 var el = document.getElementById(expectedValues[i].id);
92 var expectedValue = expectedValues[i].end;
93 var realValue = parseFloat(window.getComputedStyle(el).left);
94 log(expectedValue, realValue, false, expectedValues[i].id);
96 document.getElementById('result').innerHTML = result;
98 if (window.testRunner)
99 testRunner.notifyDone();
102 window.onload = function () {
103 for (var i=
0; i < expectedValues.length; i++) {
104 var el = document.getElementById(expectedValues[i].id);
105 var expectedValue = expectedValues[i].start;
106 var realValue = parseFloat(window.getComputedStyle(el).left);
107 log(expectedValue, realValue, true, expectedValues[i].id);
109 document.addEventListener(
"webkitAnimationEnd", animationEnded, false);
115 This test performs an animation of the left property with four different
116 fill modes. It animates over
0.1 seconds with a
0.1 second delay. It takes
117 snapshots at document load and the end of the animation.
119 <div id=
"none" class=
"box">
122 <div id=
"backwards" class=
"box">
125 <div id=
"forwards" class=
"box">
128 <div id=
"both" class=
"box">
131 <div id=
"both_iterating" class=
"box">
134 <div id=
"both_iterating_reverse" class=
"box">
135 Both iterating reverse