Bug 1343589 - Add tests that the playback rate is updated silently draft
authorBrian Birtles <birtles@gmail.com>
Tue, 28 Mar 2017 14:51:53 +0900
changeset 552240 1521e1ace0b6943b96e1b6b0806b1343dc956655
parent 552239 f5dd13805dea7e833654b23e31bdf328542f0003
child 552241 0cf47b458efcd566027ea8a96fbde68d75e18b45
push id51295
push userbbirtles@mozilla.com
push dateTue, 28 Mar 2017 06:38:47 +0000
bugs1343589
milestone55.0a1
Bug 1343589 - Add tests that the playback rate is updated silently The spec[1] says: Silently set the animation playback rate of animation to -animation playback rate. This must be done silently or else we may end up resolving the current ready promise when we do the compensatory seek despite the fact that we are most likely not exiting the pending play state. This patch add tests that we don't exit the pending play state when calling reverse() or resolve the ready promise. [1] https://w3c.github.io/web-animations/#reverse-an-animation MozReview-Commit-ID: 1X42O5yKpk9
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/web-animations/timing-model/animations/reversing-an-animation.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -207833,17 +207833,17 @@
    "53a4a6c6c6d07e00fecc50e5de831862e7bf4b2e",
    "testharness"
   ],
   "web-animations/timing-model/animations/current-time.html": [
    "b1ea8e490cbfb69fd71b91a90e7e2d9ce99f42d3",
    "testharness"
   ],
   "web-animations/timing-model/animations/reversing-an-animation.html": [
-   "80327fe9a7c68d280b7b4cfba42d081358ee1ea7",
+   "2b5631893d0d0846e5e57097ce4ae54dfa8a03e3",
    "testharness"
   ],
   "web-animations/timing-model/animations/set-the-animation-start-time.html": [
    "84afa495b1a4c467e27b1394f6449a18c58ed98d",
    "testharness"
   ],
   "web-animations/timing-model/animations/set-the-target-effect-of-an-animation.html": [
    "840be610db4bce6d6fd1c22710e494a75ee95eba",
--- a/testing/web-platform/tests/web-animations/timing-model/animations/reversing-an-animation.html
+++ b/testing/web-platform/tests/web-animations/timing-model/animations/reversing-an-animation.html
@@ -53,16 +53,44 @@ test(function(t) {
 
   assert_equals(animation.currentTime, 50 * MS_PER_SEC,
     'The current time should not change it is in the middle of ' +
     'the animation duration');
 }, 'Reversing an animation maintains the same current time');
 
 test(function(t) {
   var div = createDiv(t);
+  var animation = div.animate({}, { duration: 200 * MS_PER_SEC,
+                                    delay: -100 * MS_PER_SEC });
+  assert_equals(animation.playState, 'pending',
+    'The playState is pending before we call reverse');
+
+  animation.reverse();
+
+  assert_equals(animation.playState, 'pending',
+    'The playState is still pending after calling reverse');
+}, 'Reversing an animation does not cause it to leave the pending state');
+
+promise_test(function(t) {
+  var div = createDiv(t);
+  var animation = div.animate({}, { duration: 200 * MS_PER_SEC,
+                                    delay: -100 * MS_PER_SEC });
+  var readyResolved = false;
+  animation.ready.then(() => { readyResolved = true; });
+
+  animation.reverse();
+
+  return Promise.resolve(() => {
+    assert_false(readyResolved,
+                 'ready promise should not have been resolved yet');
+  });
+}, 'Reversing an animation does not cause it to resolve the ready promise');
+
+test(function(t) {
+  var div = createDiv(t);
   var animation = div.animate({}, 100 * MS_PER_SEC);
   animation.currentTime = 200 * MS_PER_SEC;
   animation.reverse();
 
   assert_equals(animation.currentTime, 100 * MS_PER_SEC,
     'reverse() should start playing from the animation effect end ' +
     'if the playbackRate > 0 and the currentTime > effect end');
 }, 'Reversing an animation when playbackRate > 0 and currentTime > ' +