91876d65dd24818464d8668f15f2d064b118b1a5
[WebKit-https.git] / LayoutTests / transitions / cancel-transition.html
1 <!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>Cancelled Transition Should Not Continue To Run</title>
8     <style type="text/css" media="screen">
9         #container {
10             height: 300px;
11             width: 700px;
12             background: #fcc;
13             font-family: ArialRoundedMTBold, sans-serif;
14             font-size: 200%;
15         }
16   
17         #container div {
18             position: absolute;
19             background-color: #933;
20             width: 200px;
21             height: 100px;
22             left: 50px;
23         }
24         #a {
25             top: 100px;
26         }
27         #container.run #a {
28             left: 450px;
29             -webkit-transition-property: left;
30             -webkit-transition-duration: 0.5s;
31             -webkit-transition-timing-function: linear;
32         }
33         #b {
34             top: 250px;
35         }
36         #container.run #b {
37             -webkit-transform: translate(400px, 0px);
38             -webkit-transition-property: -webkit-transform;
39             -webkit-transition-duration: 0.5s;
40             -webkit-transition-timing-function: linear;
41         }
42     </style>
43     <script type="text/javascript" charset="utf-8">
44         if (window.layoutTestController) {
45             layoutTestController.dumpAsText();
46             layoutTestController.waitUntilDone();
47         }
48
49         result = "<span style='color:red'>CHECK NOT COMPLETED</span>";
50
51         function isEqual(actual, desired, tolerance)
52         {
53             if (tolerance == undefined || tolerance == 0)
54                 tolerance = defaultTolerance;
55             var diff = Math.abs(actual - desired);
56             return diff < tolerance;
57         }
58
59         function cancelTransition()
60         {
61             document.getElementById("container").className = "";
62         }
63
64         function restartTransition()
65         {
66             document.getElementById("container").className = "run";
67             setTimeout("check()", 250);
68         }
69
70         function check()
71         {
72             var left = parseFloat(window.getComputedStyle(document.getElementById('a')).left);
73             result = "left:";
74             if (!isEqual(left, 250, 30))
75                 result += "<span style='color:red'>FAIL(was:" + left + ", s/b:150)</span>";
76             else
77                 result += "<span style='color:green'>PASS</span>";
78             
79             result += ", webkitTransform:";
80             
81             var transform = window.getComputedStyle(document.getElementById('b')).webkitTransform;
82             transform = transform.split("(");
83             transform = transform[1].split(",");
84             if (!isEqual(transform[4], 200, 30))
85                 result += "<span style='color:red'>FAIL(was:" + transform[4] + ", s/b:50)</span>";
86             else
87                 result += "<span style='color:green'>PASS</span>";
88         }
89
90         function start()
91         {
92             document.getElementById("container").className = "run";
93             setTimeout("cancelTransition()", 100);
94             setTimeout("restartTransition()", 200);
95
96             window.setTimeout(function() {
97                 document.getElementById('result').innerHTML = result;
98                 if (window.layoutTestController)
99                 layoutTestController.notifyDone();
100             },
101             500);
102         }
103     </script>
104 <body onload="start()">
105 <p>
106     Test removes the transition properties while the transition is running, then adds them back in.
107     If working properly the transitions should start from the beginning. But there was a bug that
108     would cause the transition to continue to run (although with no visible effect). So when you
109     restarted, it would pick up where it left off.
110 </p>
111 <div id="container">
112     <div id="a" class="tester">left</div>
113     <div id="b" class="tester">translate</div>
114 </div>
115 <div id="result">
116 </div>
117 </body>
118 </html>