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
</title>
8 <style type=
"text/css" media=
"screen">
15 -webkit-animation-delay:
0.1s;
16 -webkit-animation-duration:
0.1s;
17 -webkit-animation-timing-function: linear;
21 -webkit-animation-name: anim1;
25 -webkit-animation-name: anim2;
28 @-webkit-keyframes anim1 {
32 @-webkit-keyframes anim2 {
39 background-color: blue;
40 -webkit-animation-fill-mode: none;
43 background-color: red;
44 -webkit-animation-fill-mode: backwards;
47 background-color: green;
48 -webkit-animation-fill-mode: forwards;
51 background-color: yellow;
52 -webkit-animation-fill-mode: both;
55 background-color: #
999;
56 -webkit-animation-fill-mode: both;
57 -webkit-animation-iteration-count:
2;
58 -webkit-animation-direction: alternate;
61 <script type=
"text/javascript" charset=
"utf-8">
63 var animsFinished =
0;
65 const expectedValues = [
66 {id:
"a", start:
100, end:
100},
67 {id:
"b", start:
200, end:
100},
68 {id:
"c", start:
100, end:
300},
69 {id:
"d", start:
200, end:
300},
70 {id:
"e", start:
200, end:
200},
71 {id:
"f", start:
100, end:
100},
72 {id:
"g", start:
200, end:
100},
73 {id:
"h", start:
100, end:
300},
74 {id:
"i", start:
200, end:
300},
75 {id:
"j", start:
200, end:
200}
79 if (window.testRunner) {
80 testRunner.dumpAsText();
81 testRunner.waitUntilDone();
84 function animationEnded(event) {
85 if (++animsFinished == numAnims) {
86 setTimeout(endTest,
0); // this set timeout should be ok in the test environment
87 // since we're just giving style a chance to resolve
93 for (var i=
0; i < expectedValues.length; i++) {
94 var el = document.getElementById(expectedValues[i].id);
95 var expectedValue = expectedValues[i].end;
96 var realValue = parseFloat(window.getComputedStyle(el).left);
97 if (Math.abs(expectedValue - realValue) < allowance) {
102 result +=
" - end of animation - id: " + expectedValues[i].id +
" expected: " + expectedValue +
" actual: " + realValue +
"<br>";
104 document.getElementById('result').innerHTML = result;
106 if (window.testRunner)
107 testRunner.notifyDone();
110 window.onload = function () {
111 for (var i=
0; i < expectedValues.length; i++) {
112 var el = document.getElementById(expectedValues[i].id);
113 var expectedValue = expectedValues[i].start;
114 var realValue = parseFloat(window.getComputedStyle(el).left);
115 if (Math.abs(expectedValue - realValue) < allowance) {
120 result +=
" - start of animation - id: " + expectedValues[i].id +
" expected: " + expectedValue +
" actual: " + realValue +
"<br>";
122 document.addEventListener(
"webkitAnimationEnd", animationEnded, false);
128 This test performs an animation of the left property with four different
129 fill modes on two sets of objects. The first set has animations with
130 only from and to keyframes. The second set has animations with from, to and
131 a third keyframe at
50%. It animates over
0.1 second with a
0.1 second delay.
132 It takes snapshots at document load and the end of the animation.
134 <div id=
"a" class=
"box two-keyframes">
137 <div id=
"b" class=
"box two-keyframes">
138 Backwards -
2 keyframes
140 <div id=
"c" class=
"box two-keyframes">
141 Forwards -
2 keyframes
143 <div id=
"d" class=
"box two-keyframes">
146 <div id=
"e" class=
"box two-keyframes">
147 Both iterating -
2 keyframes
150 <div id=
"f" class=
"box three-keyframes">
153 <div id=
"g" class=
"box three-keyframes">
154 Backwards -
3 keyframes
156 <div id=
"h" class=
"box three-keyframes">
157 Forwards -
3 keyframes
159 <div id=
"i" class=
"box three-keyframes">
162 <div id=
"j" class=
"box three-keyframes">
163 Both iterating -
3 keyframes