diff options
Diffstat (limited to 'tests/wpt/web-platform-tests/web-animations/testcommon.js')
-rw-r--r-- | tests/wpt/web-platform-tests/web-animations/testcommon.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/wpt/web-platform-tests/web-animations/testcommon.js b/tests/wpt/web-platform-tests/web-animations/testcommon.js index 1eb24f658c2..baa7550d660 100644 --- a/tests/wpt/web-platform-tests/web-animations/testcommon.js +++ b/tests/wpt/web-platform-tests/web-animations/testcommon.js @@ -275,3 +275,34 @@ function assert_rotate3d_equals(actual, expected, description) { `expected ${expected} but got ${actual}: ${description}`); } } + +function assert_phase_at_time(animation, phase, currentTime) { + animation.currentTime = currentTime; + + if (phase === 'active') { + // If the fill mode is 'none', then progress will only be non-null if we + // are in the active phase. + animation.effect.updateTiming({ fill: 'none' }); + assert_not_equals(animation.effect.getComputedTiming().progress, null, + 'Animation effect is in active phase when current time' + + ` is ${currentTime}ms`); + } else { + // The easiest way to distinguish between the 'before' phase and the 'after' + // phase is to toggle the fill mode. For example, if the progress is null + // will the fill node is 'none' but non-null when the fill mode is + // 'backwards' then we are in the before phase. + animation.effect.updateTiming({ fill: 'none' }); + assert_equals(animation.effect.getComputedTiming().progress, null, + `Animation effect is in ${phase} phase when current time` + + ` is ${currentTime}ms` + + ' (progress is null with \'none\' fill mode)'); + + animation.effect.updateTiming({ + fill: phase === 'before' ? 'backwards' : 'forwards', + }); + assert_not_equals(animation.effect.getComputedTiming().progress, null, + `Animation effect is in ${phase} phase when current time` + + ` is ${currentTime}ms` + + ' (progress is non-null with appropriate fill mode)'); + } +}
\ No newline at end of file |