tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_animation_timing_negative-playback-rate_current-time-scrubber.js (1692B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Test whether the scrubber was working in case of negative playback rate.
      7 
      8 add_task(async function () {
      9  await addTab(URL_ROOT + "doc_negative_playback_rate.html");
     10  await removeAnimatedElementsExcept([".normal"]);
     11  const { animationInspector, panel } = await openAnimationInspector();
     12 
     13  info("Set initial state");
     14  clickOnCurrentTimeScrubberController(animationInspector, panel, 0);
     15  await waitUntilAnimationsPlayState(animationInspector, "paused");
     16  const initialCurrentTime =
     17    animationInspector.state.animations[0].state.currentTime;
     18  const initialProgressBarX = getProgressBarX(panel);
     19 
     20  info("Check whether the animation currentTime was decreased");
     21  clickOnCurrentTimeScrubberController(animationInspector, panel, 0.5);
     22  await waitUntilCurrentTimeChangedAt(
     23    animationInspector,
     24    animationInspector.state.timeScale.getDuration() * 0.5
     25  );
     26  Assert.greater(
     27    initialCurrentTime,
     28    animationInspector.state.animations[0].state.currentTime,
     29    "currentTime should be decreased"
     30  );
     31 
     32  info("Check whether the progress bar was moved to left");
     33  Assert.greater(
     34    initialProgressBarX,
     35    getProgressBarX(panel),
     36    "Progress bar should be moved to left"
     37  );
     38 });
     39 
     40 function getProgressBarX(panel) {
     41  const areaEl = panel.querySelector(".keyframes-progress-bar-area");
     42  const barEl = areaEl.querySelector(".keyframes-progress-bar");
     43  const controllerBounds = areaEl.getBoundingClientRect();
     44  const barBounds = barEl.getBoundingClientRect();
     45  const barX = barBounds.x + barBounds.width / 2 - controllerBounds.x;
     46  return barX;
     47 }