diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /devtools/client/inspector/animation/test/browser_animation_pause-resume-button_end-time.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/inspector/animation/test/browser_animation_pause-resume-button_end-time.js')
-rw-r--r-- | devtools/client/inspector/animation/test/browser_animation_pause-resume-button_end-time.js | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/devtools/client/inspector/animation/test/browser_animation_pause-resume-button_end-time.js b/devtools/client/inspector/animation/test/browser_animation_pause-resume-button_end-time.js new file mode 100644 index 0000000000..896ae5d2ef --- /dev/null +++ b/devtools/client/inspector/animation/test/browser_animation_pause-resume-button_end-time.js @@ -0,0 +1,79 @@ +/* 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", + ".negative-delay", + ]); + 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"); + clickOnCurrentTimeScrubberController(animationInspector, panel, 1); + await waitUntilAnimationsPlayState(animationInspector, "paused"); + info("Resume animations"); + clickOnPauseResumeButton(animationInspector, panel); + await wait(1000); + assertPlayState(animationInspector.state.animations, [ + "running", + "finished", + "finished", + "finished", + ]); + clickOnCurrentTimeScrubberController(animationInspector, panel, 0); + await waitUntilAnimationsPlayState(animationInspector, "paused"); + + info("Check animations state after resuming without infinite animation"); + info("Remove infinite animation"); + await setClassAttribute(animationInspector, ".animated", "ball still"); + await waitUntil(() => panel.querySelectorAll(".animation-item").length === 3); + + info("Make the current time of animation to be over its end time"); + clickOnCurrentTimeScrubberController(animationInspector, panel, 1.1); + await waitUntilAnimationsPlayState(animationInspector, "paused"); + await changePlaybackRateSelector(animationInspector, panel, 0.1); + info("Resume animations"); + clickOnPauseResumeButton(animationInspector, panel); + await waitUntilAnimationsPlayState(animationInspector, "running"); + assertCurrentTimeLessThanDuration(animationInspector.state.animations); + assertScrubberPosition(panel); +}); + +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) => { + Assert.less( + animation.state.currentTime, + animation.state.duration, + `The current time of animation[${index}] should be less than its duration` + ); + }); +} + +function assertScrubberPosition(panel) { + const scrubberEl = panel.querySelector(".current-time-scrubber"); + const marginInlineStart = parseFloat(scrubberEl.style.marginInlineStart); + Assert.greaterOrEqual( + marginInlineStart, + 0, + "The translateX of scrubber position should be zero or more" + ); +} |