2008-11-04 Anders Carlsson <andersca@apple.com>
[webkit/qt.git] / LayoutTests / animations / keyframes.html
blob5caeda685218e20c25e54c7e1238a895a8f6227c
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
4 <html lang="en">
5 <head>
6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
7 <title>Keyframes test</title>
8 <style type="text/css" media="screen">
9 #box {
10 position: absolute;
11 left: 0;
12 top: 100px;
13 height: 100px;
14 width: 100px;
15 background-color: blue;
16 -webkit-animation-duration: 1s;
17 -webkit-animation-timing-function: linear;
18 -webkit-animation-name: "anim";
20 @-webkit-keyframes "anim" {
21 from { left: 50px; }
22 20% { left: 100px; }
23 40% { left: 100px; }
24 60% { left: 200px; }
25 80% { left: 200px; }
26 to { left: 300px; }
28 </style>
29 <script type="text/javascript" charset="utf-8">
30 if (window.layoutTestController) {
31 layoutTestController.dumpAsText();
32 layoutTestController.waitUntilDone();
35 result = "PASS";
36 const defaultTolerance = 0.2;
38 function isEqual(actual, desired, tolerance)
40 if (tolerance == undefined || tolerance == 0)
41 tolerance = defaultTolerance;
42 var diff = Math.abs(actual - desired);
43 return diff < tolerance;
46 function snapshot(which)
48 if (result != "PASS")
49 return;
51 var left = parseInt(window.getComputedStyle(document.getElementById('box')).left);
52 var expected = which ? 200 : 100;
53 if (!isEqual(left, expected))
54 result = "FAIL(was:"+left+", expected:"+expected+")";
57 function start()
59 setTimeout("snapshot(0)", 300);
60 setTimeout("snapshot(1)", 700);
62 window.setTimeout(function() {
63 document.getElementById('result').innerHTML = result;
64 if (window.layoutTestController)
65 layoutTestController.notifyDone();
66 }, 800);
69 document.addEventListener('webkitAnimationStart', start, false);
71 </script>
72 </head>
73 <body>
74 This test performs an animation of the left property. It should stop for 100ms at 100px and 200px
75 We test for those values 50ms after it has stopped at each position.
76 <div id="box">
77 </div>
78 <div id="result">
79 </div>
80 </body>
81 </html>