OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 | |
3 <html> | 2 <html> |
4 <head> | 3 <head> |
| 4 <meta charset="utf-8"> |
| 5 <script src="../resources/testharness.js"></script> |
| 6 <script src="../resources/testharnessreport.js"></script> |
5 <style> | 7 <style> |
6 #container { | 8 #container { |
7 width: 700px; | 9 width: 700px; |
8 background-color: #fcc; | 10 background-color: #fcc; |
9 } | 11 } |
10 | 12 |
11 #container div { | 13 #container div { |
12 position: relative; | 14 position: relative; |
13 background-color: #933; | 15 background-color: #933; |
14 width: 200px; | 16 width: 200px; |
15 height: 50px; | 17 height: 50px; |
16 left: 50px; | 18 left: 50px; |
17 margin-top: 10px; | 19 margin-top: 10px; |
18 } | 20 } |
19 #container.run #left { | 21 #container.run #left { |
20 left: 450px; | 22 left: 450px; |
21 transition-property: left; | 23 transition-property: left; |
22 transition-duration: 1s; | 24 transition-duration: 4s; |
23 transition-timing-function: linear; | 25 transition-timing-function: linear; |
24 } | 26 } |
25 #container.run #translate { | 27 #container.run #translate { |
26 transform: translate(400px, 0px); | 28 transform: translate(400px, 0px); |
27 transition-property: transform; | 29 transition-property: transform; |
28 transition-duration: 1s; | 30 transition-duration: 4s; |
| 31 transition-delay: -1s; |
29 transition-timing-function: linear; | 32 transition-timing-function: linear; |
30 } | 33 } |
31 </style> | 34 </style> |
| 35 </head> |
| 36 <body> |
| 37 <!-- |
| 38 Test removes the transition properties while the transition is running,
then adds them back in. |
| 39 If working properly the transitions should start from the beginning. But
there was a bug that |
| 40 would cause the transition to continue to run (although with no visible
effect). So when you |
| 41 restarted, it would pick up where it left off. |
| 42 https://bugs.webkit.org/show_bug.cgi?id=26163 |
| 43 --> |
| 44 <div id="container"> |
| 45 <div id="left">left</div> |
| 46 <div id="translate">translate</div> |
| 47 </div> |
32 <script> | 48 <script> |
33 if (window.testRunner) { | 49 'use strict'; |
34 testRunner.dumpAsText(); | 50 |
35 testRunner.waitUntilDone(); | 51 function waitSeveralFrames() { |
| 52 return container.animate({opacity: ['1', '1']}, 100).finished; |
36 } | 53 } |
37 | 54 |
38 function isEqual(actual, desired, tolerance) | 55 async_test(t => { |
39 { | 56 getComputedStyle(container).height; // force style recalc |
40 var diff = Math.abs(actual - desired); | 57 container.className = 'run'; |
41 return diff < tolerance; | 58 getComputedStyle(container).height; // force style recalc - transiti
on will start |
42 } | 59 waitSeveralFrames().then(t.step_func(() => { |
43 | 60 assert_greater_than(parseFloat(getComputedStyle(left).left), 50)
; |
44 function cancelTransition() | 61 container.className = ''; |
45 { | 62 getComputedStyle(container).height; // force style recalc - tran
sition will cancel |
46 document.getElementById("container").className = ""; | 63 })).then(waitSeveralFrames).then(t.step_func_done(() => { |
47 document.body.offsetHeight; | 64 container.className = 'run'; // restart transition |
48 } | 65 assert_equals(getComputedStyle(left).left, '50px'); |
49 | 66 assert_equals(getComputedStyle(translate).transform, 'matrix(1,
0, 0, 1, 100, 0)'); |
50 function restartTransition() | 67 })); |
51 { | 68 }, 'Transition restarts from the beginning'); |
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.getElementByI
d('left')).left); | |
61 result = "left: "; | |
62 if (!isEqual(left, 250, 50)) | |
63 result += "<span style='color:red'>FAIL (was: " + left + ", expe
cted: 250)</span>"; | |
64 else | |
65 result += "<span style='color:green'>PASS</span>"; | |
66 | |
67 result += ", transform: "; | |
68 | |
69 var transform = window.getComputedStyle(document.getElementById('tra
nslate')).transform; | |
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> | 69 </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 the
re was a bug that | |
95 would cause the transition to continue to run (although with no visible effe
ct). 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> | 70 </body> |
104 </html> | 71 </html> |
OLD | NEW |