diff options
Diffstat (limited to 'tests/wpt/web-platform-tests/web-animations')
3 files changed, 33 insertions, 32 deletions
diff --git a/tests/wpt/web-platform-tests/web-animations/resources/keyframe-utils.js b/tests/wpt/web-platform-tests/web-animations/resources/keyframe-utils.js index 971e82ed81d..fdea1d8d93c 100644 --- a/tests/wpt/web-platform-tests/web-animations/resources/keyframe-utils.js +++ b/tests/wpt/web-platform-tests/web-animations/resources/keyframe-utils.js @@ -28,7 +28,8 @@ function assert_frames_equal(a, b, name) { assert_equals(Object.keys(a).sort().toString(), Object.keys(b).sort().toString(), `properties on ${name} should match`); - for (const p in a) { + // Iterates sorted keys to ensure stable failures. + for (const p of Object.keys(a).sort()) { assert_equals(a[p], b[p], `value for '${p}' on ${name}`); } } 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 diff --git a/tests/wpt/web-platform-tests/web-animations/timing-model/animation-effects/phases-and-states.html b/tests/wpt/web-platform-tests/web-animations/timing-model/animation-effects/phases-and-states.html index b62726c7e64..a33dbf517e8 100644 --- a/tests/wpt/web-platform-tests/web-animations/timing-model/animation-effects/phases-and-states.html +++ b/tests/wpt/web-platform-tests/web-animations/timing-model/animation-effects/phases-and-states.html @@ -16,37 +16,6 @@ // // -------------------------------------------------------------------- -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)'); - } -} - test(t => { const animation = createDiv(t).animate(null, 1); |