Bug 1466031 - Tidy up test_animation-finished.html; r?hiro draft
authorBrian Birtles <birtles@gmail.com>
Mon, 04 Jun 2018 10:10:38 +0900
changeset 803420 4732afc2663b653015d2a4dd71889339393ecc19
parent 803419 ca98c09504677bde925b1ccda13c6b2ccd82e346
child 803421 006a4f853a3c25b41ef7b31b75cd74b9e4bcef7a
push id112095
push userbmo:bbirtles@mozilla.com
push dateMon, 04 Jun 2018 01:13:47 +0000
reviewershiro
bugs1466031
milestone62.0a1
Bug 1466031 - Tidy up test_animation-finished.html; r?hiro This mostly just involves using promise_rejects to simplify some test code. The change to the test description of the last test might seem like it is giving it the opposite meaning but the original test name was "Test finished promise changes when animationPlayState set to running"[1], and it is about testing that there are NO changes but that got lost when the "Test" part of the description was dropped. [1] https://searchfox.org/mozilla-central/rev/cb846d13d3f9ec5d38ace93a74f749a18e9c67f5/dom/animation/test/css-animations/test_animation-player-finished.html#287 MozReview-Commit-ID: iAfIH3P81A
dom/animation/test/css-animations/test_animation-finished.html
--- a/dom/animation/test/css-animations/test_animation-finished.html
+++ b/dom/animation/test/css-animations/test_animation-finished.html
@@ -15,35 +15,32 @@
 <script>
 'use strict';
 
 const ANIM_PROP_VAL = 'abc 100s';
 const ANIM_DURATION = 100 * MS_PER_SEC;
 
 promise_test(async t => {
   const div = addDiv(t);
+
   // Set up pending animation
   div.style.animation = ANIM_PROP_VAL;
   const animation = div.getAnimations()[0];
   const originalFinishedPromise = animation.finished;
 
   // Cancel the animation and flush styles
   div.style.animation = '';
   getComputedStyle(div).animation;
 
-  try {
-    await originalFinishedPromise;
-    assert_unreached('Original finished promise should not be fulfilled');
-  } catch (err) {
-    assert_equals(err.name, 'AbortError',
-                  'finished promise is rejected with AbortError');
-    assert_not_equals(animation.finished, originalFinishedPromise,
-                      'Finished promise should change after the original is ' +
-                      'rejected');
-  }
+  await promise_rejects(t, 'AbortError', originalFinishedPromise,
+                        'finished promise is rejected with AbortError');
+
+  assert_not_equals(animation.finished, originalFinishedPromise,
+                    'Finished promise should change after the original is ' +
+                    'rejected');
 }, 'finished promise is rejected when an animation is canceled by resetting ' +
    'the animation property');
 
 promise_test(async t => {
   const div = addDiv(t);
   // As before, but this time instead of removing all animations, simply update
   // the list of animations. At least for Firefox, updating is a different
   // code path.
@@ -52,43 +49,37 @@ promise_test(async t => {
   div.style.animation = ANIM_PROP_VAL;
   const animation = div.getAnimations()[0];
   const originalFinishedPromise = animation.finished;
 
   // Update the animation and flush styles
   div.style.animation = 'def 100s';
   getComputedStyle(div).animation;
 
-  try {
-    await originalFinishedPromise;
-    assert_unreached('Original finished promise should not be fulfilled');
-  } catch (err) {
-    assert_equals(err.name, 'AbortError',
-                  'finished promise is rejected with AbortError');
-    assert_not_equals(animation.finished, originalFinishedPromise,
-                      'Finished promise should change after the original is ' +
-                      'rejected');
-  }
+  await promise_rejects(t, 'AbortError', originalFinishedPromise,
+                        'finished promise is rejected with AbortError');
+
+  assert_not_equals(animation.finished, originalFinishedPromise,
+                    'Finished promise should change after the original is ' +
+                    'rejected');
 }, 'finished promise is rejected when an animation is canceled by changing ' +
    'the animation property');
 
 promise_test(async t => {
   const div = addDiv(t);
   div.style.animation = ANIM_PROP_VAL;
   const animation = div.getAnimations()[0];
   const originalFinishedPromise = animation.finished;
   animation.currentTime = ANIM_DURATION;
 
   await animation.finished;
 
   div.style.animationPlayState = 'running';
   await waitForAnimationFrames(2);
 
   assert_equals(animation.finished, originalFinishedPromise,
-                'Should not replay when animation-play-state changes to ' +
-                '"running" on finished animation');
+                'The finished promise should NOT be reset');
   assert_equals(animation.currentTime, ANIM_DURATION,
-                'currentTime should not change when animation-play-state ' +
-                'changes to "running" on finished animation');
-}, 'Test finished promise changes when animationPlayState set to running');
+                'Sanity check: the current time should not change');
+}, 'finished promise is not reset when animationPlayState is set to running');
 
 </script>
 </body>