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/current-time-scrubber_head.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 '')
-rw-r--r-- | devtools/client/inspector/animation/test/current-time-scrubber_head.js | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/devtools/client/inspector/animation/test/current-time-scrubber_head.js b/devtools/client/inspector/animation/test/current-time-scrubber_head.js new file mode 100644 index 0000000000..1e94a7562c --- /dev/null +++ b/devtools/client/inspector/animation/test/current-time-scrubber_head.js @@ -0,0 +1,101 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +/* import-globals-from head.js */ + +// Test for following CurrentTimeScrubber and CurrentTimeScrubberController components: +// * element existence +// * scrubber position validity +// * make animations currentTime to change by click on the controller +// * mouse drag on the scrubber + +// eslint-disable-next-line no-unused-vars +async function testCurrentTimeScrubber(isRTL) { + await addTab(URL_ROOT + "doc_simple_animation.html"); + await removeAnimatedElementsExcept([".long"]); + const { animationInspector, panel } = await openAnimationInspector(); + + info("Checking scrubber controller existence"); + const controllerEl = panel.querySelector(".current-time-scrubber-area"); + ok(controllerEl, "scrubber controller should exist"); + + info("Checking scrubber existence"); + const scrubberEl = controllerEl.querySelector(".current-time-scrubber"); + ok(scrubberEl, "scrubber should exist"); + + info("Checking scrubber changes current time of animation and the position"); + const duration = animationInspector.state.timeScale.getDuration(); + clickOnCurrentTimeScrubberController( + animationInspector, + panel, + isRTL ? 1 : 0 + ); + await waitUntilAnimationsPlayState(animationInspector, "paused"); + await waitUntilCurrentTimeChangedAt(animationInspector, 0); + assertPosition( + scrubberEl, + controllerEl, + isRTL ? duration : 0, + animationInspector + ); + + clickOnCurrentTimeScrubberController( + animationInspector, + panel, + isRTL ? 0 : 1 + ); + await waitUntilCurrentTimeChangedAt(animationInspector, duration); + assertPosition( + scrubberEl, + controllerEl, + isRTL ? 0 : duration, + animationInspector + ); + + clickOnCurrentTimeScrubberController(animationInspector, panel, 0.5); + await waitUntilCurrentTimeChangedAt(animationInspector, duration * 0.5); + assertPosition(scrubberEl, controllerEl, duration * 0.5, animationInspector); + + info("Checking current time scrubber position during running"); + // Running again + clickOnPauseResumeButton(animationInspector, panel); + await waitUntilAnimationsPlayState(animationInspector, "running"); + let previousX = scrubberEl.getBoundingClientRect().x; + await wait(1000); + let currentX = scrubberEl.getBoundingClientRect().x; + isnot(previousX, currentX, "Scrubber should be moved"); + + info("Checking draggable on scrubber over animation list"); + clickOnPauseResumeButton(animationInspector, panel); + await waitUntilAnimationsPlayState(animationInspector, "paused"); + previousX = scrubberEl.getBoundingClientRect().x; + await dragOnCurrentTimeScrubber(animationInspector, panel, 5, 30); + currentX = scrubberEl.getBoundingClientRect().x; + isnot(previousX, currentX, "Scrubber should be draggable"); + + info( + "Checking a behavior which mouse out from animation inspector area " + + "during dragging from controller" + ); + await dragOnCurrentTimeScrubberController(animationInspector, panel, 0.5, 2); + ok( + !panel + .querySelector(".animation-list-container") + .classList.contains("active-scrubber"), + "Click and DnD should be inactive" + ); +} + +function assertPosition(scrubberEl, controllerEl, time, animationInspector) { + const controllerBounds = controllerEl.getBoundingClientRect(); + const scrubberBounds = scrubberEl.getBoundingClientRect(); + const scrubberX = + scrubberBounds.x + scrubberBounds.width / 2 - controllerBounds.x; + const timeScale = animationInspector.state.timeScale; + const expected = Math.round( + (time / timeScale.getDuration()) * controllerBounds.width + ); + is(scrubberX, expected, `Position should be ${expected} at ${time}ms`); +} |