aboutsummaryrefslogtreecommitdiffstats
path: root/tests/wpt/web-platform-tests/web-animations/testcommon.js
diff options
context:
space:
mode:
authorbors-servo <servo-ops@mozilla.com>2020-06-09 23:51:15 -0400
committerGitHub <noreply@github.com>2020-06-09 23:51:15 -0400
commit1a561242cfca27b51d31bf63509cbc95044b69d4 (patch)
treed90b9d6b03ca1b4c218b3aa1163fad84ee311cad /tests/wpt/web-platform-tests/web-animations/testcommon.js
parent0b0ea17dca72d867b56ddf518240e25f30d93f3e (diff)
parent4c6f01b60a3093071a9b39cb92db303d280d28dc (diff)
downloadservo-1a561242cfca27b51d31bf63509cbc95044b69d4.tar.gz
servo-1a561242cfca27b51d31bf63509cbc95044b69d4.zip
Auto merge of #26831 - servo-wpt-sync:wpt_update_09-06-2020, r=jdm
Sync WPT with upstream (09-06-2020) Automated downstream sync of changes from upstream as of 09-06-2020. [no-wpt-sync] r? @servo-wpt-sync
Diffstat (limited to 'tests/wpt/web-platform-tests/web-animations/testcommon.js')
-rw-r--r--tests/wpt/web-platform-tests/web-animations/testcommon.js31
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