Bug 1380258 - Test case for restarting CSS animation on pseudo element once after the pseudo element was re-generated. r?birtles draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Mon, 16 Jan 2017 07:49:09 +0900
changeset 614098 b561a0453c9044ef14b6be9384236a4a1cd91f48
parent 614097 24630ac79b676b8a1ca6767229bc850c30b5c755
child 614099 023d0a1feadb2c01b67e0c21889ff22751a8412b
push id69914
push userhikezoe@mozilla.com
push dateMon, 24 Jul 2017 04:10:48 +0000
reviewersbirtles
bugs1380258
milestone56.0a1
Bug 1380258 - Test case for restarting CSS animation on pseudo element once after the pseudo element was re-generated. r?birtles This test fails without the first patch in this series. MozReview-Commit-ID: A22aFPnklqj
dom/animation/test/mozilla/file_hide_and_show.html
--- a/dom/animation/test/mozilla/file_hide_and_show.html
+++ b/dom/animation/test/mozilla/file_hide_and_show.html
@@ -3,16 +3,21 @@
 <script src="../testcommon.js"></script>
 <style>
 @keyframes move {
   100% {
     transform: translateX(100px);
   }
 }
 
+div.pseudo::before {
+  animation: move 0.01s;
+  content: 'content';
+}
+
 </style>
 <body>
 <script>
 'use strict';
 
 test(function(t) {
   var div = addDiv(t, { style: 'animation: move 100s infinite' });
   assert_equals(div.getAnimations().length, 1,
@@ -152,11 +157,40 @@ test(function(t) {
                 'animations again');
 
   assert_not_equals(div.getAnimations()[0], animation,
                     'Restarted animation is a newly-generated animation');
 
 }, 'CSS Animation which has already finished starts playing when its parent ' +
    'element is shown from "display:none" state');
 
+promise_test(function(t) {
+  var div = addDiv(t, { 'class': 'pseudo' });
+  var eventWatcher = new EventWatcher(t, div, 'animationend');
+
+  assert_equals(document.getAnimations().length, 1,
+                'CSS animation on pseudo element');
+
+  return eventWatcher.wait_for('animationend').then(function() {
+    assert_equals(document.getAnimations().length, 0,
+                  'No CSS animation on pseudo element after the animation ' +
+                  'finished');
+
+    // Remove the class which generated this pseudo element.
+    div.classList.remove('pseudo');
+
+    // We need to wait for two frames to process re-framing.
+    // The callback of 'animationend' is processed just before rAF callbacks,
+    // and rAF callbacks are processed before re-framing process, so waiting for
+    // one rAF callback is not sufficient.
+    return waitForAnimationFrames(2);
+  }).then(function() {
+    // Add the class again to re-generate pseudo element.
+    div.classList.add('pseudo');
+    assert_equals(document.getAnimations().length, 1,
+                  'A new CSS animation on pseudo element');
+  });
+}, 'CSS animation on pseudo element restarts after the pseudo element that ' +
+   'had a finished CSS animation is re-generated');
+
 done();
 </script>
 </body>