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 fill mode on transform</title>
8 <style type="text/css" media="screen">
15 -webkit-transform: translate3d(100px, 0, 0);
16 -webkit-animation-delay: 0.1s;
17 -webkit-animation-duration: 0.1s;
18 -webkit-animation-timing-function: linear;
19 -webkit-animation-name: anim;
21 @-webkit-keyframes anim {
22 from { -webkit-transform: translate3d(200px, 0, 0); }
23 to { -webkit-transform: translate3d(300px, 0, 0); }
26 background-color: blue;
27 -webkit-animation-fill-mode: none;
30 background-color: red;
31 -webkit-animation-fill-mode: backwards;
34 background-color: green;
35 -webkit-animation-fill-mode: forwards;
38 background-color: yellow;
39 -webkit-animation-fill-mode: both;
42 background-color: #999;
43 -webkit-animation-fill-mode: both;
44 -webkit-animation-iteration-count: 2;
45 -webkit-animation-direction: alternate;
48 <script type="text/javascript" charset="utf-8">
50 var animsFinished = 0;
52 const expectedValues = [
53 {id: "a", start: 100, end: 100},
54 {id: "b", start: 200, end: 100},
55 {id: "c", start: 100, end: 300},
56 {id: "d", start: 200, end: 300},
57 {id: "e", start: 200, end: 200}
61 if (window.layoutTestController) {
62 layoutTestController.dumpAsText();
63 layoutTestController.waitUntilDone();
66 function animationEnded(event) {
67 if (++animsFinished == numAnims) {
68 setTimeout(endTest, 0); // this set timeout should be ok in the test environment
69 // since we're just giving style a chance to resolve
75 for (var i=0; i < expectedValues.length; i++) {
76 var el = document.getElementById(expectedValues[i].id);
77 var expectedValue = expectedValues[i].end;
78 var computedValue = window.getComputedStyle(el).webkitTransform;
79 var realValue = parseFloat(computedValue.split("(")[1].split(",")[4]);
80 if (Math.abs(expectedValue - realValue) < allowance) {
85 result += " - end of animation - id: " + expectedValues[i].id + " expected: " + expectedValue + " actual: " + realValue + "<br>";
87 document.getElementById('result').innerHTML = result;
89 if (window.layoutTestController)
90 layoutTestController.notifyDone();
93 window.onload = function () {
94 for (var i=0; i < expectedValues.length; i++) {
95 var el = document.getElementById(expectedValues[i].id);
96 var expectedValue = expectedValues[i].start;
97 var computedValue = window.getComputedStyle(el).webkitTransform;
98 var realValue = parseFloat(computedValue.split("(")[1].split(",")[4]);
99 if (Math.abs(expectedValue - realValue) < allowance) {
104 result += " - start of animation - id: " + expectedValues[i].id + " expected: " + expectedValue + " actual: " + realValue + "<br>";
106 document.addEventListener("webkitAnimationEnd", animationEnded, false);
112 This test performs an animation of the transform property with four different
113 fill modes. It animates over 0.1 second with a 0.1 second delay.
114 It takes snapshots at document load and the end of the animations.
115 <div id="a" class="box">
118 <div id="b" class="box">
121 <div id="c" class="box">
124 <div id="d" class="box">
127 <div id="e" class="box">