Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / transitions / cancel-transition.html
1 <!DOCTYPE html>
2
3 <html>
4 <head>
5     <style>
6         #container {
7             width: 700px;
8             background-color: #fcc;
9         }
10
11         #container div {
12             position: relative;
13             background-color: #933;
14             width: 200px;
15             height: 50px;
16             left: 50px;
17             margin-top: 10px;
18         }
19         #container.run #left {
20             left: 450px;
21             -webkit-transition-property: left;
22             -webkit-transition-duration: 1s;
23             -webkit-transition-timing-function: linear;
24         }
25         #container.run #translate {
26             transform: translate(400px, 0px);
27             -webkit-transition-property: transform;
28             -webkit-transition-duration: 1s;
29             -webkit-transition-timing-function: linear;
30         }
31     </style>
32     <script>
33         if (window.testRunner) {
34             testRunner.dumpAsText();
35             testRunner.waitUntilDone();
36         }
37
38         function isEqual(actual, desired, tolerance)
39         {
40             var diff = Math.abs(actual - desired);
41             return diff < tolerance;
42         }
43
44         function cancelTransition()
45         {
46             document.getElementById("container").className = "";
47             document.body.offsetHeight;
48         }
49
50         function restartTransition()
51         {
52             document.getElementById("container").className = "run";
53             document.body.offsetHeight;
54             // The transition should restart at the beginning here. After 250 it should be halfway done.
55             setTimeout(check, 500);
56         }
57
58         function check()
59         {
60             var left = parseFloat(window.getComputedStyle(document.getElementById('left')).left);
61             result = "left: ";
62             if (!isEqual(left, 250, 50))
63                 result += "<span style='color:red'>FAIL (was: " + left + ", expected: 250)</span>";
64             else
65                 result += "<span style='color:green'>PASS</span>";
66
67             result += ", webkitTransform: ";
68
69             var transform = window.getComputedStyle(document.getElementById('translate')).webkitTransform;
70             transform = transform.split("(");
71             transform = transform[1].split(",");
72             if (!isEqual(transform[4], 200, 50))
73                 result += "<span style='color:red'>FAIL (was: " + transform[4] + ", expected: 200)</span>";
74             else
75                 result += "<span style='color:green'>PASS</span>";
76
77             document.getElementById('result').innerHTML = result;
78             if (window.testRunner)
79                 testRunner.notifyDone();
80         }
81
82         function start()
83         {
84             document.getElementById("container").className = "run";
85             document.body.offsetHeight;
86             setTimeout("cancelTransition()", 200);
87             setTimeout("restartTransition()", 400);
88         }
89     </script>
90 </head>
91 <body onload="start()">
92 <p>
93     Test removes the transition properties while the transition is running, then adds them back in.
94     If working properly the transitions should start from the beginning. But there was a bug that
95     would cause the transition to continue to run (although with no visible effect). So when you
96     restarted, it would pick up where it left off.
97 </p>
98 <div id="container">
99     <div id="left">left</div>
100     <div id="translate">translate</div>
101 </div>
102 <div id="result"></div>
103 </body>
104 </html>