Commit d18db804 authored by Kevin Ellis's avatar Kevin Ellis Committed by Commit Bot

Fix test flake in animation-state-changes-positive-playback-rate.html

The flake is caused by limited precision of timeline times. When
comparing times with >=, the boundary time needs to factor in error
tolerance.

The virtual/threaded-no-composited-antialiasing variant of this test
had a recent flake score of 954.

Bug: 623434
Change-Id: I44b41da1326849da4b3dec30cea76be6673e0b17
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2368500Reviewed-by: default avatarXida Chen <xidachen@chromium.org>
Commit-Queue: Kevin Ellis <kevers@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801013}
parent 17829a1a
......@@ -417,8 +417,10 @@ async_test(function(t) {
var timelineCurrentTime = document.timeline.currentTime;
animation.ready.then(t.step_func_done(() => {
assert_equals(animation.playState, 'running');
assert_greater_than_equal(animation.startTime, timelineCurrentTime);
assert_greater_than_equal(animation.currentTime, animationCurrentTime);
assert_time_greater_than_equal(animation.startTime,
timelineCurrentTime);
assert_time_greater_than_equal(animation.currentTime,
animationCurrentTime);
}));
}, "PlayState is 'running' while playing a cancelled animation");
......@@ -429,7 +431,8 @@ async_test(function(t) {
animation.ready.then(t.step_func_done(() => {
assert_equals(animation.playState, 'paused');
assert_equals(animation.startTime, null);
assert_greater_than_equal(animation.currentTime, animationCurrentTime);
assert_time_greater_than_equal(animation.currentTime,
animationCurrentTime);
}));
}, "PlayState is 'running' while pausing a running animation");
</script>
......@@ -25,6 +25,15 @@ if (!window.assert_times_equal) {
};
}
// Allow implementations to substitute an alternative method for comparing
// times based on their precision requirements.
if (!window.assert_time_greater_than_equal) {
window.assert_time_greater_than_equal = (actual, expected, description) => {
assert_greater_than_equal(actual, expected - 2 * 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) {
......@@ -305,4 +314,4 @@ function assert_phase_at_time(animation, phase, currentTime) {
+ ` is ${currentTime}ms`
+ ' (progress is non-null with appropriate fill mode)');
}
}
\ No newline at end of file
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment