Bug 1287983 part 7 - Add negative delay tests for CSS-Transitions event. r?birtles draft
authorMantaroh Yoshinaga <mantaroh@gmail.com>
Fri, 21 Oct 2016 11:37:53 +0900
changeset 427894 178dce48a90eee1889e14f62e72ced44b2b58fee
parent 427853 0ef3878921b8153c1f9b2b6281683be857e34453
child 427917 5d09e515d2b8778ad9194be42120c9624f6c6fbf
child 427923 faf872db2831a58a5b2499d7b2cdae91730006f5
child 427928 035cf2ad2f115b14a9a093a00143bc23fd8d1eca
push id33154
push usermantaroh@gmail.com
push dateFri, 21 Oct 2016 02:38:19 +0000
reviewersbirtles
bugs1287983
milestone52.0a1
Bug 1287983 part 7 - Add negative delay tests for CSS-Transitions event. r?birtles MozReview-Commit-ID: KOVljOtRqFt
dom/animation/test/css-transitions/file_csstransition-events.html
--- a/dom/animation/test/css-transitions/file_csstransition-events.html
+++ b/dom/animation/test/css-transitions/file_csstransition-events.html
@@ -27,19 +27,20 @@ function TransitionEventHandler(target) 
 }
 
 TransitionEventHandler.prototype.clear = function() {
   this.transitionrun   = undefined;
   this.transitionstart = undefined;
   this.transitionend   = undefined;
 };
 
-function setupTransition(t) {
+function setupTransition(t, transitionStyle) {
   var div, watcher, handler, transition;
-  div = addDiv(t, { style: 'transition: margin-left 100s 100s' });
+  transitionStyle = transitionStyle || 'transition: margin-left 100s 100s';
+  div = addDiv(t, { style: transitionStyle });
   watcher = new EventWatcher(t, div, [ 'transitionrun',
                                        'transitionstart',
                                        'transitionend' ]);
   handler = new TransitionEventHandler(div);
   flushComputedStyle(div);
 
   div.style.marginLeft = '100px';
   flushComputedStyle(div);
@@ -171,12 +172,52 @@ promise_test(function(t) {
     // Seek to Active phase.
     transition.currentTime = 100 * MS_PER_SEC;
     return watcher.wait_for('transitionstart');
   }).then(function(evt) {
     assert_equals(evt.elapsedTime, 100.0);
   });
 }, 'After -> Active');
 
+promise_test(function(t) {
+  var [transition, watcher, handler] =
+    setupTransition(t, 'transition: margin-left 100s -50s');
+
+  return watcher.wait_for([ 'transitionrun',
+                            'transitionstart' ]).then(function() {
+    assert_equals(handler.transitionrun, 50.0);
+    assert_equals(handler.transitionstart, 50.0);
+    transition.finish();
+    return watcher.wait_for('transitionend');
+  }).then(function(evt) {
+    assert_equals(evt.elapsedTime, 100.0);
+  });
+}, 'Calculating the interval start and end time with negative start delay.');
+
+promise_test(function(t) {
+  var [transition, watcher, handler] = setupTransition(t);
+
+  return watcher.wait_for('transitionrun').then(function(evt) {
+    // We can't set the end delay via generated effect timing.
+    // Because CSS-Transition use the AnimationEffectTimingReadOnly.
+    transition.effect = new KeyframeEffect(handler.target,
+                                           { marginleft: [ '0px', '100px' ]},
+                                           { duration: 100 * MS_PER_SEC,
+                                             endDelay: -50 * MS_PER_SEC });
+    // Seek to Before and play.
+    transition.cancel();
+    transition.play();
+    return watcher.wait_for('transitionstart');
+  }).then(function() {
+    assert_equals(handler.transitionstart, 0.0);
+
+    // Seek to After phase.
+    transition.finish();
+    return watcher.wait_for('transitionend');
+  }).then(function(evt) {
+    assert_equals(evt.elapsedTime, 50.0);
+  });
+}, 'Calculating the interval start and end time with negative end delay.');
+
 done();
 </script>
 </body>
 </html>