Bug 1454954 - Part 2: Test the animation state in case of the currentTime is over endTime. r?pbro
MozReview-Commit-ID: 39jPrDAuWHM
--- a/devtools/client/inspector/animation/test/browser.ini
+++ b/devtools/client/inspector/animation/test/browser.ini
@@ -38,16 +38,17 @@ support-files =
[browser_animation_keyframes-graph_computed-value-path.js]
[browser_animation_keyframes-graph_computed-value-path_easing-hint.js]
[browser_animation_keyframes-graph_keyframe-marker.js]
[browser_animation_keyframes-progress-bar.js]
[browser_animation_logic_auto-stop.js]
[browser_animation_logic_avoid-updating-during-hiding.js]
[browser_animation_logic_mutations.js]
[browser_animation_pause-resume-button.js]
+[browser_animation_pause-resume-button_end-time.js]
[browser_animation_pause-resume-button_respectively.js]
[browser_animation_pause-resume-button_spacebar.js]
[browser_animation_playback-rate-selector.js]
[browser_animation_pseudo-element.js]
[browser_animation_rewind-button.js]
[browser_animation_summary-graph_animation-name.js]
[browser_animation_summary-graph_compositor.js]
[browser_animation_summary-graph_computed-timing-path.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/inspector/animation/test/browser_animation_pause-resume-button_end-time.js
@@ -0,0 +1,47 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Test whether the animation can rewind if the current time is over end time when
+// the resume button clicked.
+
+add_task(async function() {
+ await addTab(URL_ROOT + "doc_simple_animation.html");
+ await removeAnimatedElementsExcept([".animated", ".end-delay", ".long"]);
+ const { animationInspector, panel } = await openAnimationInspector();
+
+ info("Check animations state after resuming with infinite animation");
+ info("Make the current time of animation to be over its end time");
+ await clickOnCurrentTimeScrubberController(animationInspector, panel, 1);
+ info("Resume animations");
+ await clickOnPauseResumeButton(animationInspector, panel);
+ await wait(1000);
+ assertPlayState(animationInspector.state.animations,
+ ["running", "finished", "finished"]);
+ await clickOnCurrentTimeScrubberController(animationInspector, panel, 0);
+
+ info("Check animations state after resuming without infinite animation");
+ info("Remove infinite animation");
+ await setClassAttribute(animationInspector, ".animated", "ball still");
+ info("Make the current time of animation to be over its end time");
+ await clickOnCurrentTimeScrubberController(animationInspector, panel, 1);
+ info("Resume animations");
+ await clickOnPauseResumeButton(animationInspector, panel);
+ assertPlayState(animationInspector.state.animations, ["running", "running"]);
+ assertCurrentTimeLessThanDuration(animationInspector.state.animations);
+});
+
+function assertPlayState(animations, expectedState) {
+ animations.forEach((animation, index) => {
+ is(animation.state.playState, expectedState[index],
+ `The playState of animation [${ index }] should be ${ expectedState[index] }`);
+ });
+}
+
+function assertCurrentTimeLessThanDuration(animations) {
+ animations.forEach((animation, index) => {
+ ok(animation.state.currentTime < animation.state.duration,
+ "The current time of animation[${ index }] should be less than its duration");
+ });
+}