blob: 2fbc1b5c2627cf1de30a38410ea22b038a9df5f5 [file] [log] [blame]
dino@apple.come519fcb2010-06-26 02:01:29 +00001<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
3
4<html lang="en">
5<head>
6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
7 <title>Test animation with missing from and to keyframes</title>
8 <style type="text/css" media="screen">
9 .box {
10 position: relative;
11 left: 10px;
12 top: 10px;
13 height: 20px;
14 width: 20px;
15 -webkit-transform: translateX(10px);
16 background-color: blue;
17 -webkit-animation-duration: 2s;
18 -webkit-animation-timing-function: linear;
19 }
20
21 #box1 {
22 -webkit-animation-name: anim1;
23 }
24 @-webkit-keyframes anim1 {
25 from { -webkit-transform: translateX(10px); }
26 40% { -webkit-transform: translateX(30px); }
27 60% { -webkit-transform: translateX(10px); }
28 to { -webkit-transform: translateX(20px); }
29 }
30
31 #box2 {
32 -webkit-animation-name: anim2;
33 background-color: red;
34 }
35 @-webkit-keyframes anim2 {
36 40% { -webkit-transform: translateX(30px); }
37 60% { -webkit-transform: translateX(10px); }
38 to { -webkit-transform: translateX(20px); }
39 }
40
41 #box3 {
42 -webkit-transform: translateX(20px);
43 -webkit-animation-name: anim3;
44 background-color: green;
45 }
46 @-webkit-keyframes anim3 {
47 from { -webkit-transform: translateX(10px); }
48 40% { -webkit-transform: translateX(30px); }
49 60% { -webkit-transform: translateX(10px); }
50 }
51
52 #box4 {
53 -webkit-animation-name: anim4;
54 background-color: yellow;
55 }
56 @-webkit-keyframes anim4 {
57 40% { -webkit-transform: translateX(30px); }
58 60% { -webkit-transform: translateX(20px); }
59 }
60
61 #box5 {
62 -webkit-animation-name: anim5;
63 background-color: orange;
64 }
65 @-webkit-keyframes anim5 {
66 }
67
68 #result {
69 margin-top: 20px;
70 }
71 </style>
simon.fraser@apple.com93531132011-04-26 03:16:31 +000072 <script src="resources/animation-test-helpers.js" type="text/javascript" charset="utf-8"></script>
dino@apple.come519fcb2010-06-26 02:01:29 +000073 <script type="text/javascript" charset="utf-8">
74
75 const expectedValues = [
76 // [animation-name, time, element-id, property, expected-value, tolerance]
77 ["anim1", 0.4, "box1", "webkitTransform.4", 20, 2],
78 ["anim1", 1.0, "box1", "webkitTransform.4", 20, 2],
79 ["anim1", 1.6, "box1", "webkitTransform.4", 15, 2],
80 ["anim2", 0.4, "box2", "webkitTransform.4", 20, 2],
81 ["anim2", 1.0, "box2", "webkitTransform.4", 20, 2],
82 ["anim2", 1.6, "box2", "webkitTransform.4", 15, 2],
83 ["anim3", 0.4, "box3", "webkitTransform.4", 20, 2],
84 ["anim3", 1.0, "box3", "webkitTransform.4", 20, 2],
85 ["anim3", 1.6, "box3", "webkitTransform.4", 15, 2],
86 ["anim4", 0.4, "box4", "webkitTransform.4", 20, 2],
87 ["anim4", 1.0, "box4", "webkitTransform.4", 25, 2],
88 ["anim4", 1.6, "box4", "webkitTransform.4", 15, 2]
89 ];
90
91 runAnimationTest(expectedValues, function() {
rniwa@webkit.orgad35b682012-06-11 17:22:07 +000092 if (window.testRunner) {
benjamin@webkit.org84dbb0d2013-02-07 21:34:32 +000093 var box5Element = document.getElementById('box5');
94 if (internals.pauseAnimationAtTimeOnElement("anim5", 0.1, box5Element))
dino@apple.come519fcb2010-06-26 02:01:29 +000095 result += "FAIL - box5 animation was running<br>";
96 else
97 result += "PASS - box5 animation was not running<br>";
98 }
99 });
100
101 </script>
102</head>
103<body>
104This test performs animations of the transform property on five boxes over 2 seconds.
105Box 1 has all keyframes. Box 2 has a missing "from" keyframe.
106Box 3 has a missing "to" keyframe.
107Box 4 has both "from" and "to" keyframes missing, but other keyframes which
108should trigger the generation of "from" and "to". Box 5 has no keyframes, and
109should not animate.
110The test takes 3 snapshots each and expects each result to be within a specified range.
111<div class="box" id="box1">
112</div>
113<div class="box" id="box2">
114</div>
115<div class="box" id="box3">
116</div>
117<div class="box" id="box4">
118</div>
119<div class="box" id="box5">
120</div>
121<div id="result">
122</div>
123</body>
124</html>