Bug 1430654 - Introduce assert_time_equals_literal and use it. r?birtles draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Mon, 22 Jan 2018 14:55:16 +0900
changeset 723031 9e2b00286bf43225c4578256754a7d5513466b94
parent 723009 5faab9e619901b1513fd4ca137747231be550def
child 723032 52511027c1393dcd0c145e3996b5c9274dbda4a8
push id96298
push userhikezoe@mozilla.com
push dateMon, 22 Jan 2018 06:02:45 +0000
reviewersbirtles
bugs1430654
milestone59.0a1
Bug 1430654 - Introduce assert_time_equals_literal and use it. r?birtles This assertion is supposed to be used where the first argument has a tolerance but the second argument doesn't have such tolerance. Whereas assert_times_equal() is supposed to be used for the case both arguments have the same tolerance, actually it hasn't, it will be fixed in a subsequent patch in this patch series. MozReview-Commit-ID: FEDHilbX2rm
dom/animation/test/css-animations/file_animation-currenttime.html
dom/animation/test/css-animations/file_event-dispatch.html
dom/animation/test/testcommon.js
testing/web-platform/tests/web-animations/README.md
testing/web-platform/tests/web-animations/interfaces/AnimationEffectTiming/direction.html
testing/web-platform/tests/web-animations/interfaces/AnimationEffectTiming/duration.html
testing/web-platform/tests/web-animations/interfaces/AnimationEffectTiming/endDelay.html
testing/web-platform/tests/web-animations/interfaces/AnimationEffectTiming/iterationStart.html
testing/web-platform/tests/web-animations/interfaces/AnimationEffectTiming/iterations.html
testing/web-platform/tests/web-animations/testcommon.js
testing/web-platform/tests/web-animations/timing-model/animation-effects/active-time.html
testing/web-platform/tests/web-animations/timing-model/animations/current-time.html
testing/web-platform/tests/web-animations/timing-model/animations/playing-an-animation.html
testing/web-platform/tests/web-animations/timing-model/animations/set-the-animation-start-time.html
testing/web-platform/tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation.html
--- a/dom/animation/test/css-animations/file_animation-currenttime.html
+++ b/dom/animation/test/css-animations/file_animation-currenttime.html
@@ -52,17 +52,17 @@ test(function(t)
   assert_equals(animation.currentTime, 0,
     'Animation.currentTime should be zero when an animation ' +
     'is initially created');
 
   // Make sure the animation is running before we set the current time.
   animation.startTime = animation.timeline.currentTime;
 
   animation.currentTime = 50 * MS_PER_SEC;
-  assert_times_equal(animation.currentTime, 50 * MS_PER_SEC,
+  assert_time_equals_literal(animation.currentTime, 50 * MS_PER_SEC,
     'Check setting of currentTime actually works');
 }, 'Sanity test to check round-tripping assigning to new animation\'s ' +
    'currentTime');
 
 promise_test(function(t) {
   var div = addDiv(t, {'class': 'animated-div'});
   var eventWatcher = new EventWatcher(t, div, CSS_ANIM_EVENTS);
   div.style.animation = "anim 100s 100s";
--- a/dom/animation/test/css-animations/file_event-dispatch.html
+++ b/dom/animation/test/css-animations/file_event-dispatch.html
@@ -120,30 +120,30 @@ promise_test(t => {
   const { animation, watcher, div } = setupAnimation(t, 'anim 100s');
 
   return watcher.wait_for('animationstart').then(evt => {
     animation.currentTime = 100.0;
     // Make idle
     animation.timeline = null;
     return watcher.wait_for('animationcancel');
   }).then(evt => {
-    assert_times_equal(evt.elapsedTime, 0.1);
+    assert_time_equals_literal(evt.elapsedTime, 0.1);
   });
 }, 'Active -> Idle, setting Animation.timeline = null');
 
 promise_test(t => {
   // we should NOT pause animation since calling cancel synchronously.
   const { animation, watcher, div } = setupAnimation(t, 'anim 100s');
 
   return watcher.wait_for('animationstart').then(evt => {
     animation.currentTime = 50.0;
     animation.cancel();
     return watcher.wait_for('animationcancel');
   }).then(evt => {
-    assert_times_equal(evt.elapsedTime, 0.05);
+    assert_time_equals_literal(evt.elapsedTime, 0.05);
   });
 }, 'Active -> Idle, calling Animation.cancel()');
 
 promise_test(t => {
   const { animation, watcher } =
     setupAnimation(t, 'anim 100s 100s paused');
 
   // Seek to Active phase.
--- a/dom/animation/test/testcommon.js
+++ b/dom/animation/test/testcommon.js
@@ -25,16 +25,23 @@ var TIME_PRECISION = 0.0005; // ms
  * Allow implementations to substitute an alternative method for comparing
  * times based on their precision requirements.
  */
 function assert_times_equal(actual, expected, description) {
   assert_approx_equals(actual, expected, TIME_PRECISION, description);
 }
 
 /*
+ * Compare a time value based on its precision requirements with a fixed value.
+ */
+function assert_time_equals_literal(actual, expected, description) {
+  assert_approx_equals(actual, expected, TIME_PRECISION, description);
+}
+
+/*
  * Compare matrix string like 'matrix(1, 0, 0, 1, 100, 0)'.
  * This function allows error, 0.01, because on Android when we are scaling down
  * the document, it results in some errors.
  */
 function assert_matrix_equals(actual, expected, description) {
   var matrixRegExp = /^matrix\((.+),(.+),(.+),(.+),(.+),(.+)\)/;
   assert_regexp_match(actual, matrixRegExp,
     'Actual value should be a matrix')
--- a/testing/web-platform/tests/web-animations/README.md
+++ b/testing/web-platform/tests/web-animations/README.md
@@ -93,15 +93,24 @@ Guidelines for writing tests
 
 *   Avoid using `GLOBAL_CONSTS` that make the test harder to read.
     It's fine to repeat the the same parameter values like `100 * MS_PER_SEC`
     over and over again since it makes it easy to read and debug a test in
     isolation.
     Remember, even if we do need to make all tests take, say 200s each, text
     editors are very good at search and replace.
 
-*   Use the `assert_times_equal` assertion for comparing calculated times.
-    It tests times are equal using the precision recommended in the spec whilst
-    allowing implementations to override the function to meet their own
-    precision requirements.
+*   Use the `assert_times_equal` assertion for comparing times returned from
+    the API. This asserts that the time values are equal using a tolerance
+    based on the precision recommended in the spec. This tolerance is applied
+    to *both* of the values being compared. That is, it effectively allows
+    double the epsilon that is used when comparing with an absolute value.
+
+    For comparing a time value returned from the API to an absolute value, use
+    `assert_time_equals_literal`. This tests that the actual value is equal to
+    the expected value within the precision recommended in the spec.
+
+    Both `assert_times_equal` and `assert_time_equals_literal` are defined in a
+    way that implementations can override them to meet their own precision
+    requirements.
 
 *   There are quite a few bad tests in the repository. We're learning as
     we go. Don't just copy them blindly&mdash;please fix them!
--- a/testing/web-platform/tests/web-animations/interfaces/AnimationEffectTiming/direction.html
+++ b/testing/web-platform/tests/web-animations/interfaces/AnimationEffectTiming/direction.html
@@ -26,23 +26,23 @@ test(t => {
                   `set direction to ${direction}`);
   }
 }, 'Can be set to each of the possible keywords');
 
 test(t => {
   const div = createDiv(t);
   const anim = div.animate(null, { duration: 10000, direction: 'normal' });
   anim.currentTime = 7000;
-  assert_times_equal(anim.effect.getComputedTiming().progress, 0.7,
-                     'progress before updating direction');
+  assert_time_equals_literal(anim.effect.getComputedTiming().progress, 0.7,
+                             'progress before updating direction');
 
   anim.effect.timing.direction = 'reverse';
 
-  assert_times_equal(anim.effect.getComputedTiming().progress, 0.3,
-                     'progress after updating direction');
+  assert_time_equals_literal(anim.effect.getComputedTiming().progress, 0.3,
+                             'progress after updating direction');
 }, 'Can be changed from \'normal\' to \'reverse\' while in progress');
 
 test(t => {
   const div = createDiv(t);
   const anim = div.animate({ opacity: [ 0, 1 ] },
                            { duration: 10000,
                              direction: 'normal' });
   assert_equals(anim.effect.getComputedTiming().progress, 0,
@@ -73,36 +73,36 @@ test(t => {
 
 test(t => {
   const div = createDiv(t);
   const anim = div.animate({ opacity: [ 0, 1 ] },
                            { iterations: 2,
                              duration: 10000,
                              direction: 'normal' });
   anim.currentTime = 17000;
-  assert_times_equal(anim.effect.getComputedTiming().progress, 0.7,
-                     'progress before updating direction');
+  assert_time_equals_literal(anim.effect.getComputedTiming().progress, 0.7,
+                             'progress before updating direction');
 
   anim.effect.timing.direction = 'alternate';
 
-  assert_times_equal(anim.effect.getComputedTiming().progress, 0.3,
-                     'progress after updating direction');
+  assert_time_equals_literal(anim.effect.getComputedTiming().progress, 0.3,
+                             'progress after updating direction');
 }, 'Can be changed from \'normal\' to \'alternate\' while in progress');
 
 test(t => {
   const div = createDiv(t);
   const anim = div.animate({ opacity: [ 0, 1 ] },
                            { iterations: 2,
                              duration: 10000,
                              direction: 'alternate' });
   anim.currentTime = 17000;
-  assert_times_equal(anim.effect.getComputedTiming().progress, 0.3,
-                     'progress before updating direction');
+  assert_time_equals_literal(anim.effect.getComputedTiming().progress, 0.3,
+                             'progress before updating direction');
 
   anim.effect.timing.direction = 'alternate-reverse';
 
-  assert_times_equal(anim.effect.getComputedTiming().progress, 0.7,
-                     'progress after updating direction');
+  assert_time_equals_literal(anim.effect.getComputedTiming().progress, 0.7,
+                             'progress after updating direction');
 }, 'Can be changed from \'alternate\' to \'alternate-reverse\' while in'
    + ' progress');
 
 </script>
 </body>
--- a/testing/web-platform/tests/web-animations/interfaces/AnimationEffectTiming/duration.html
+++ b/testing/web-platform/tests/web-animations/interfaces/AnimationEffectTiming/duration.html
@@ -14,20 +14,20 @@ test(t => {
   const anim = createDiv(t).animate(null);
   assert_equals(anim.effect.timing.duration, 'auto');
 }, 'Has the default value \'auto\'');
 
 test(t => {
   const div = createDiv(t);
   const anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
   anim.effect.timing.duration = 123.45;
-  assert_times_equal(anim.effect.timing.duration, 123.45,
-                     'set duration 123.45');
-  assert_times_equal(anim.effect.getComputedTiming().duration, 123.45,
-                     'getComputedTiming() after set duration 123.45');
+  assert_time_equals_literal(anim.effect.timing.duration, 123.45,
+                             'set duration 123.45');
+  assert_time_equals_literal(anim.effect.getComputedTiming().duration, 123.45,
+                             'getComputedTiming() after set duration 123.45');
 }, 'Can be set to a double value');
 
 test(t => {
   const div = createDiv(t);
   const anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
   anim.effect.timing.duration = 'auto';
   assert_equals(anim.effect.timing.duration, 'auto', 'set duration \'auto\'');
   assert_equals(anim.effect.getComputedTiming().duration, 0,
@@ -171,18 +171,18 @@ promise_test(t => {
 
 test(t => {
   const div = createDiv(t);
   const anim = div.animate(null, { duration: 100000, fill: 'both' });
   anim.finish();
   assert_equals(anim.effect.getComputedTiming().progress, 1,
                 'progress when animation is finished');
   anim.effect.timing.duration *= 2;
-  assert_times_equal(anim.effect.getComputedTiming().progress, 0.5,
-                     'progress after doubling the duration');
+  assert_time_equals_literal(anim.effect.getComputedTiming().progress, 0.5,
+                             'progress after doubling the duration');
   anim.effect.timing.duration = 0;
   assert_equals(anim.effect.getComputedTiming().progress, 1,
                 'progress after setting duration to zero');
   anim.effect.timing.duration = 'auto';
   assert_equals(anim.effect.getComputedTiming().progress, 1,
                 'progress after setting duration to \'auto\'');
 }, 'Can be updated while the animation is in progress');
 
--- a/testing/web-platform/tests/web-animations/interfaces/AnimationEffectTiming/endDelay.html
+++ b/testing/web-platform/tests/web-animations/interfaces/AnimationEffectTiming/endDelay.html
@@ -14,20 +14,20 @@ test(t => {
   const anim = createDiv(t).animate(null);
   assert_equals(anim.effect.timing.endDelay, 0);
 }, 'Has the default value 0');
 
 test(t => {
   const div = createDiv(t);
   const anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
   anim.effect.timing.endDelay = 123.45;
-  assert_times_equal(anim.effect.timing.endDelay, 123.45,
-                     'set endDelay 123.45');
-  assert_times_equal(anim.effect.getComputedTiming().endDelay, 123.45,
-                     'getComputedTiming() after set endDelay 123.45');
+  assert_time_equals_literal(anim.effect.timing.endDelay, 123.45,
+                             'set endDelay 123.45');
+  assert_time_equals_literal(anim.effect.getComputedTiming().endDelay, 123.45,
+                             'getComputedTiming() after set endDelay 123.45');
 }, 'Can be set to a positive number');
 
 test(t => {
   const div = createDiv(t);
   const anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
   anim.effect.timing.endDelay = -1000;
   assert_equals(anim.effect.timing.endDelay, -1000, 'set endDelay -1000');
   assert_equals(anim.effect.getComputedTiming().endDelay, -1000,
--- a/testing/web-platform/tests/web-animations/interfaces/AnimationEffectTiming/iterationStart.html
+++ b/testing/web-platform/tests/web-animations/interfaces/AnimationEffectTiming/iterationStart.html
@@ -19,44 +19,44 @@ test(t => {
   const div = createDiv(t);
   const anim = div.animate({ opacity: [ 0, 1 ] },
                            { iterationStart: 0.2,
                              iterations: 1,
                              fill: 'both',
                              duration: 100,
                              delay: 1 });
   anim.effect.timing.iterationStart = 2.5;
-  assert_times_equal(anim.effect.getComputedTiming().progress, 0.5);
+  assert_time_equals_literal(anim.effect.getComputedTiming().progress, 0.5);
   assert_equals(anim.effect.getComputedTiming().currentIteration, 2);
 }, 'Changing the value updates computed timing when backwards-filling');
 
 test(t => {
   const div = createDiv(t);
   const anim = div.animate({ opacity: [ 0, 1 ] },
                            { iterationStart: 0.2,
                              iterations: 1,
                              fill: 'both',
                              duration: 100,
                              delay: 0 });
   anim.effect.timing.iterationStart = 2.5;
-  assert_times_equal(anim.effect.getComputedTiming().progress, 0.5);
+  assert_time_equals_literal(anim.effect.getComputedTiming().progress, 0.5);
   assert_equals(anim.effect.getComputedTiming().currentIteration, 2);
 }, 'Changing the value updates computed timing during the active phase');
 
 test(t => {
   const div = createDiv(t);
   const anim = div.animate({ opacity: [ 0, 1 ] },
                            { iterationStart: 0.2,
                              iterations: 1,
                              fill: 'both',
                              duration: 100,
                              delay: 0 });
   anim.finish();
   anim.effect.timing.iterationStart = 2.5;
-  assert_times_equal(anim.effect.getComputedTiming().progress, 0.5);
+  assert_time_equals_literal(anim.effect.getComputedTiming().progress, 0.5);
   assert_equals(anim.effect.getComputedTiming().currentIteration, 3);
 }, 'Changing the value updates computed timing when forwards-filling');
 
 test(t => {
   const div = createDiv(t);
   const anim = div.animate(null);
   for (let invalid of [-1, NaN, Infinity]) {
     assert_throws({ name: 'TypeError' }, () => {
--- a/testing/web-platform/tests/web-animations/interfaces/AnimationEffectTiming/iterations.html
+++ b/testing/web-platform/tests/web-animations/interfaces/AnimationEffectTiming/iterations.html
@@ -65,20 +65,22 @@ test(t => {
 
   assert_equals(anim.effect.getComputedTiming().progress, 1,
                 'progress when animation is finished');
   assert_equals(anim.effect.getComputedTiming().currentIteration, 0,
                 'current iteration when animation is finished');
 
   anim.effect.timing.iterations = 2;
 
-  assert_times_equal(anim.effect.getComputedTiming().progress, 0,
-                     'progress after adding an iteration');
-  assert_times_equal(anim.effect.getComputedTiming().currentIteration, 1,
-                     'current iteration after adding an iteration');
+  assert_time_equals_literal(anim.effect.getComputedTiming().progress,
+                             0,
+                             'progress after adding an iteration');
+  assert_time_equals_literal(anim.effect.getComputedTiming().currentIteration,
+                             1,
+                             'current iteration after adding an iteration');
 
   anim.effect.timing.iterations = 0;
 
   assert_equals(anim.effect.getComputedTiming().progress, 0,
                 'progress after setting iterations to zero');
   assert_equals(anim.effect.getComputedTiming().currentIteration, 0,
                 'current iteration after setting iterations to zero');
 
--- a/testing/web-platform/tests/web-animations/testcommon.js
+++ b/testing/web-platform/tests/web-animations/testcommon.js
@@ -20,16 +20,24 @@ const TIME_PRECISION = 0.0005; // ms
 // Allow implementations to substitute an alternative method for comparing
 // times based on their precision requirements.
 if (!window.assert_times_equal) {
   window.assert_times_equal = (actual, expected, description) => {
     assert_approx_equals(actual, expected, TIME_PRECISION, description);
   };
 }
 
+// Allow implementations to substitute an alternative method for comparing
+// a time value based on its precision requirements with a fixed value.
+if (!window.assert_time_equals_literal) {
+  window.assert_time_equals_literal = (actual, expected, description) => {
+    assert_approx_equals(actual, expected, TIME_PRECISION, description);
+  }
+}
+
 // creates div element, appends it to the document body and
 // removes the created element during test cleanup
 function createDiv(test, doc) {
   return createElement(test, 'div', doc);
 }
 
 // creates element of given tagName, appends it to the document body and
 // removes the created element during test cleanup
--- a/testing/web-platform/tests/web-animations/timing-model/animation-effects/active-time.html
+++ b/testing/web-platform/tests/web-animations/timing-model/animation-effects/active-time.html
@@ -20,29 +20,29 @@ test(t => {
     assert_equals(anim.effect.getComputedTiming().progress, test.progress,
                   `Progress in before phase when using '${test.fill}' fill`);
   }
 }, 'Active time in before phase');
 
 test(t => {
   const anim = createDiv(t).animate(null, 1000);
   anim.currentTime = 500;
-  assert_times_equal(anim.effect.getComputedTiming().progress, 0.5);
+  assert_time_equals_literal(anim.effect.getComputedTiming().progress, 0.5);
 }, 'Active time in active phase and no start delay is the local time');
 
 test(t => {
   const anim = createDiv(t).animate(null, { duration: 1000, delay: 500 });
   anim.currentTime = 1000;
-  assert_times_equal(anim.effect.getComputedTiming().progress, 0.5);
+  assert_time_equals_literal(anim.effect.getComputedTiming().progress, 0.5);
 }, 'Active time in active phase and positive start delay is the local time'
    + ' minus the start delay');
 
 test(t => {
   const anim = createDiv(t).animate(null, { duration: 1000, delay: -500 });
-  assert_times_equal(anim.effect.getComputedTiming().progress, 0.5);
+  assert_time_equals_literal(anim.effect.getComputedTiming().progress, 0.5);
 }, 'Active time in active phase and negative start delay is the local time'
    + ' minus the start delay');
 
 test(t => {
   const anim = createDiv(t).animate(null);
   assert_equals(anim.effect.getComputedTiming().progress, null);
 }, 'Active time in after phase with no fill is unresolved');
 
@@ -53,17 +53,17 @@ test(t => {
 
 test(t => {
   const anim = createDiv(t).animate(null, { duration: 1000,
                                             iterations: 2.3,
                                             delay: 500, // Should have no effect
                                             fill: 'forwards' });
   anim.finish();
   assert_equals(anim.effect.getComputedTiming().currentIteration, 2);
-  assert_times_equal(anim.effect.getComputedTiming().progress, 0.3);
+  assert_time_equals_literal(anim.effect.getComputedTiming().progress, 0.3);
 }, 'Active time in after phase with forwards fill is the active duration');
 
 test(t => {
   const anim = createDiv(t).animate(null, { duration: 0,
                                             iterations: Infinity,
                                             fill: 'forwards' });
   anim.finish();
   assert_equals(anim.effect.getComputedTiming().currentIteration, Infinity);
@@ -74,29 +74,29 @@ test(t => {
 test(t => {
   const anim = createDiv(t).animate(null, { duration: 1000,
                                             iterations: 2.3,
                                             delay: 500,
                                             endDelay: 4000,
                                             fill: 'forwards' });
   anim.finish();
   assert_equals(anim.effect.getComputedTiming().currentIteration, 2);
-  assert_times_equal(anim.effect.getComputedTiming().progress, 0.3);
+  assert_time_equals_literal(anim.effect.getComputedTiming().progress, 0.3);
 }, 'Active time in after phase with forwards fill and positive end delay'
    + ' is the active duration');
 
 test(t => {
   const anim = createDiv(t).animate(null, { duration: 1000,
                                             iterations: 2.3,
                                             delay: 500,
                                             endDelay: -800,
                                             fill: 'forwards' });
   anim.finish();
   assert_equals(anim.effect.getComputedTiming().currentIteration, 1);
-  assert_times_equal(anim.effect.getComputedTiming().progress, 0.5);
+  assert_time_equals_literal(anim.effect.getComputedTiming().progress, 0.5);
 }, 'Active time in after phase with forwards fill and negative end delay'
    + ' is the active duration + end delay');
 
 test(t => {
   const anim = createDiv(t).animate(null, { duration: 1000,
                                             iterations: 2.3,
                                             delay: 500,
                                             endDelay: -2500,
@@ -122,17 +122,17 @@ test(t => {
 
 test(t => {
   const anim = createDiv(t).animate(null, { duration: 1000,
                                             iterations: 2.3,
                                             delay: 500,
                                             fill: 'both' });
   anim.finish();
   assert_equals(anim.effect.getComputedTiming().currentIteration, 2);
-  assert_times_equal(anim.effect.getComputedTiming().progress, 0.3);
+  assert_time_equals_literal(anim.effect.getComputedTiming().progress, 0.3);
 }, 'Active time in after phase with \'both\' fill is the active duration');
 
 test(t => {
   // Create an effect with a non-zero duration so we ensure we're not just
   // testing the after-phase behavior.
   const effect = new KeyframeEffect(null, null, 1);
   assert_equals(effect.getComputedTiming().progress, null);
 }, 'Active time when the local time is unresolved, is unresolved');
--- a/testing/web-platform/tests/web-animations/timing-model/animations/current-time.html
+++ b/testing/web-platform/tests/web-animations/timing-model/animations/current-time.html
@@ -63,14 +63,14 @@ test(t => {
    'playback rate');
 
 promise_test(t => {
   const animation = createDiv(t).animate(null, 100 * MS_PER_SEC);
   animation.playbackRate = 0;
 
   return animation.ready.then(() => waitForAnimationFrames(1))
   .then(() => {
-    assert_times_equal(animation.currentTime, 0);
+    assert_time_equals_literal(animation.currentTime, 0);
   });
 }, 'The current time does not progress if playback rate is 0');
 
 </script>
 </body>
--- a/testing/web-platform/tests/web-animations/timing-model/animations/playing-an-animation.html
+++ b/testing/web-platform/tests/web-animations/timing-model/animations/playing-an-animation.html
@@ -9,36 +9,36 @@
 <body>
 <div id="log"></div>
 <script>
 'use strict';
 
 test(t => {
   const animation = createDiv(t).animate(null, 100 * MS_PER_SEC);
   animation.currentTime = 1 * MS_PER_SEC;
-  assert_times_equal(animation.currentTime, 1 * MS_PER_SEC);
+  assert_time_equals_literal(animation.currentTime, 1 * MS_PER_SEC);
   animation.play();
-  assert_times_equal(animation.currentTime, 1 * MS_PER_SEC);
+  assert_time_equals_literal(animation.currentTime, 1 * MS_PER_SEC);
 }, 'Playing a running animation leaves the current time unchanged');
 
 test(t => {
   const animation = createDiv(t).animate(null, 100 * MS_PER_SEC);
   animation.finish();
-  assert_times_equal(animation.currentTime, 100 * MS_PER_SEC);
+  assert_time_equals_literal(animation.currentTime, 100 * MS_PER_SEC);
   animation.play();
-  assert_times_equal(animation.currentTime, 0);
+  assert_time_equals_literal(animation.currentTime, 0);
 }, 'Playing a finished animation seeks back to the start');
 
 test(t => {
   const animation = createDiv(t).animate(null, 100 * MS_PER_SEC);
   animation.playbackRate = -1;
   animation.currentTime = 0;
-  assert_times_equal(animation.currentTime, 0);
+  assert_time_equals_literal(animation.currentTime, 0);
   animation.play();
-  assert_times_equal(animation.currentTime, 100 * MS_PER_SEC);
+  assert_time_equals_literal(animation.currentTime, 100 * MS_PER_SEC);
 }, 'Playing a finished and reversed animation seeks to end');
 
 test(t => {
   const animation = createDiv(t).animate(null, 100 * MS_PER_SEC);
   animation.cancel();
   const promise = animation.ready;
   animation.play();
   assert_not_equals(animation.ready, promise);
--- a/testing/web-platform/tests/web-animations/timing-model/animations/set-the-animation-start-time.html
+++ b/testing/web-platform/tests/web-animations/timing-model/animations/set-the-animation-start-time.html
@@ -75,42 +75,43 @@ test(t => {
   // Since the start time is unresolved at this point, setting the current time
   // will set the hold time
   animation.currentTime = 1000;
   assert_equals(animation.currentTime, 1000,
                 'The current time is calculated from the hold time');
 
   // If we set the start time, however, we should clear the hold time.
   animation.startTime = document.timeline.currentTime - 2000;
-  assert_times_equal(animation.currentTime, 2000,
-                     'The current time is calculated from the start time,'
-                     + ' not the hold time');
+  assert_time_equals_literal(animation.currentTime, 2000,
+                             'The current time is calculated from the start'
+                             + ' time, not the hold time');
 
   // Sanity check
   assert_equals(animation.playState, 'running',
                 'Animation reports it is running after setting a resolved'
                 + ' start time');
 }, 'Setting the start time clears the hold time');
 
 test(t => {
   const animation =
     new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
                   document.timeline);
 
   // Set up a running animation (i.e. both start time and current time
   // are resolved).
   animation.startTime = document.timeline.currentTime - 1000;
   assert_equals(animation.playState, 'running');
-  assert_times_equal(animation.currentTime, 1000,
-                     'Current time is resolved for a running animation')
+  assert_time_equals_literal(animation.currentTime, 1000,
+                             'Current time is resolved for a running animation');
 
   // Clear start time
   animation.startTime = null;
-  assert_times_equal(animation.currentTime, 1000,
-                     'Hold time is set after start time is made unresolved');
+  assert_time_equals_literal(animation.currentTime, 1000,
+                             'Hold time is set after start time is made'
+                             + ' unresolved');
   assert_equals(animation.playState, 'paused',
                 'Animation reports it is paused after setting an unresolved'
                 + ' start time');
 }, 'Setting an unresolved start time sets the hold time');
 
 promise_test(t => {
   const animation =
     new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
--- a/testing/web-platform/tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation.html
+++ b/testing/web-platform/tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation.html
@@ -21,30 +21,30 @@ test(t => {
     new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
                   null);
   animation.currentTime = 50 * MS_PER_SEC;
   assert_equals(animation.playState, 'paused');
 
   animation.timeline = document.timeline;
 
   assert_equals(animation.playState, 'paused');
-  assert_times_equal(animation.currentTime, 50 * MS_PER_SEC);
+  assert_time_equals_literal(animation.currentTime, 50 * MS_PER_SEC);
 }, 'After setting timeline on paused animation it is still paused');
 
 test(t => {
   const animation =
     new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
                   null);
   animation.currentTime = 200 * MS_PER_SEC;
   assert_equals(animation.playState, 'paused');
 
   animation.timeline = document.timeline;
 
   assert_equals(animation.playState, 'paused');
-  assert_times_equal(animation.currentTime, 200 * MS_PER_SEC);
+  assert_time_equals_literal(animation.currentTime, 200 * MS_PER_SEC);
 }, 'After setting timeline on animation paused outside active interval'
    + ' it is still paused');
 
 test(t => {
   const animation =
     new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
                   null);
   assert_equals(animation.playState, 'idle');
@@ -136,17 +136,17 @@ test(t => {
   animation.currentTime = 50 * MS_PER_SEC;
   assert_false(animation.pending);
   assert_equals(animation.playState, 'paused');
 
   animation.timeline = null;
 
   assert_false(animation.pending);
   assert_equals(animation.playState, 'paused');
-  assert_times_equal(animation.currentTime, 50 * MS_PER_SEC);
+  assert_time_equals_literal(animation.currentTime, 50 * MS_PER_SEC);
 }, 'After clearing timeline on paused animation it is still paused');
 
 test(t => {
   const animation =
     new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
                   document.timeline);
   const initialStartTime = document.timeline.currentTime - 200 * MS_PER_SEC;
   animation.startTime = initialStartTime;