| <!DOCTYPE html> | |
| <!-- | |
| | Test case which ensures that when an element has its display set to none, | |
| | all running transitions on it are immediately ended. | |
| | While the specification doesn't seem to say anything about this, it is | |
| | how Chrome and Firefox both work, and it is also intuitively in line with | |
| | the following behavior specified for CSS Animations: | |
| | From https://www.w3.org/TR/2013/WD-css3-animations-20130219/#animations, | |
| | "Setting the display property to ‘none’ will terminate any running animation | |
| | applied to the element and its descendants. If an element has a display of | |
| | ‘none’, updating display to a value other than ‘none’ will start all | |
| | animations applied to the element by the ‘animation-name’ property, as well | |
| | as all animations applied to descendants with display other than ‘none’." | |
| --> | |
| <html> | |
| <head> | |
| <style> | |
| #block { | |
| width: 100px; | |
| height: 100px; | |
| background-color: red; | |
| font-size: 30px; | |
| transition: background-color 1s, transform 2s linear; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div id="block"></div> | |
| <script> | |
| if (window.testRunner) { | |
| window.testRunner.waitUntilDone(); | |
| } | |
| var blockDiv = document.getElementById('block'); | |
| window.addEventListener('load', function() { | |
| if (window.testRunner) { | |
| // Do a layout upon the load event so that we setup our source styles | |
| // that we will be transitioning from. | |
| window.testRunner.DoNonMeasuredLayout(); | |
| } | |
| blockDiv.style.backgroundColor = 'blue'; | |
| blockDiv.style.transform = "translate(100px, 0)"; | |
| if (window.testRunner) { | |
| // Run the transition a bit so that it is started but not completed. | |
| window.testRunner.DoNonMeasuredLayout(); | |
| window.testRunner.AdvanceClockByMs(500); | |
| window.testRunner.DoNonMeasuredLayout(); | |
| blockDiv.style.display = "none"; | |
| window.testRunner.DoNonMeasuredLayout(); | |
| blockDiv.style.display = "block"; | |
| // Measure that the transition should now appear to be fully completed. | |
| window.testRunner.notifyDone(); | |
| } | |
| }); | |
| </script> | |
| </body> | |
| </html> |