Bug 1430654 - Use assert_times_equal for comparing timing values. r?birtles
MozReview-Commit-ID: CUn1f8M0jo5
--- a/dom/animation/test/css-animations/file_animation-finish.html
+++ b/dom/animation/test/css-animations/file_animation-finish.html
@@ -40,21 +40,20 @@ async_test(function(t) {
div.style.animation = ANIM_PROP_VAL + ' paused';
var animation = div.getAnimations()[0];
animation.ready.then(t.step_func(function() {
animation.finish();
assert_equals(animation.playState, 'finished',
'The play state of a paused animation should become ' +
'"finished" after finish() is called');
- assert_approx_equals(animation.startTime,
- animation.timeline.currentTime - ANIM_DURATION,
- 0.0001,
- 'The start time of a paused animation should be set ' +
- 'after calling finish()');
+ assert_times_equal(animation.startTime,
+ animation.timeline.currentTime - ANIM_DURATION,
+ 'The start time of a paused animation should be set ' +
+ 'after calling finish()');
t.done();
}));
}, 'Test finish() while paused');
test(function(t) {
var div = addDiv(t);
div.style.animation = ANIM_PROP_VAL + ' paused';
var animation = div.getAnimations()[0];
@@ -64,21 +63,20 @@ test(function(t) {
animation.playbackRate = 2;
// While animation is still pause-pending call finish()
animation.finish();
assert_equals(animation.playState, 'finished',
'The play state of a pause-pending animation should become ' +
'"finished" after finish() is called');
- assert_approx_equals(animation.startTime,
- animation.timeline.currentTime - ANIM_DURATION / 2,
- 0.0001,
- 'The start time of a pause-pending animation should ' +
- 'be set after calling finish()');
+ assert_times_equal(animation.startTime,
+ animation.timeline.currentTime - ANIM_DURATION / 2,
+ 'The start time of a pause-pending animation should ' +
+ 'be set after calling finish()');
}, 'Test finish() while pause-pending with positive playbackRate');
test(function(t) {
var div = addDiv(t);
div.style.animation = ANIM_PROP_VAL + ' paused';
var animation = div.getAnimations()[0];
animation.playbackRate = -2;
--- a/dom/animation/test/css-transitions/file_animation-starttime.html
+++ b/dom/animation/test/css-transitions/file_animation-starttime.html
@@ -149,17 +149,17 @@ test(function(t)
{
var div = addDiv(t, {'class': 'animated-div'});
flushComputedStyle(div);
div.style.marginLeft = '200px'; // initiate transition
var animation = div.getAnimations()[0];
var currentTime = animation.timeline.currentTime;
animation.startTime = currentTime;
- assert_approx_equals(animation.startTime, currentTime, 0.0001, // rounding error
+ assert_times_equal(animation.startTime, currentTime,
'Check setting of startTime actually works');
}, 'Sanity test to check round-tripping assigning to new animation\'s ' +
'startTime');
async_test(function(t) {
var div = addDiv(t, {'class': 'animated-div'});
var eventWatcher = new EventWatcher(t, div, 'transitionend');
--- a/testing/web-platform/tests/web-animations/interfaces/Animation/playbackRate.html
+++ b/testing/web-platform/tests/web-animations/interfaces/Animation/playbackRate.html
@@ -9,26 +9,24 @@
<div id="log"></div>
<script>
'use strict';
function assert_playbackrate(animation,
previousAnimationCurrentTime,
previousTimelineCurrentTime,
description) {
- const accuracy = 0.001; /* accuracy of DOMHighResTimeStamp */
const animationCurrentTimeDifference =
animation.currentTime - previousAnimationCurrentTime;
const timelineCurrentTimeDifference =
animation.timeline.currentTime - previousTimelineCurrentTime;
- assert_approx_equals(animationCurrentTimeDifference,
- timelineCurrentTimeDifference * animation.playbackRate,
- accuracy,
- description);
+ assert_times_equal(animationCurrentTimeDifference,
+ timelineCurrentTimeDifference * animation.playbackRate,
+ description);
}
promise_test(t => {
const div = createDiv(t);
const animation = div.animate(null, 100 * MS_PER_SEC);
return animation.ready.then(() => {
animation.currentTime = 7 * MS_PER_SEC; // ms
animation.playbackRate = 0.5;