tor-browser

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

browser_animation_pause-resume-button_spacebar.js (2063B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 // Test for following PauseResumeButton component with spacebar:
      7 // * make animations to pause/resume by spacebar
      8 // * combination with other UI components
      9 
     10 add_task(async function () {
     11  await addTab(URL_ROOT + "doc_custom_playback_rate.html");
     12  const { animationInspector, panel } = await openAnimationInspector();
     13 
     14  info("Checking spacebar makes animations to pause");
     15  await testPauseAndResumeBySpacebar(animationInspector, panel);
     16 
     17  info(
     18    "Checking spacebar makes animations to pause when the button has the focus"
     19  );
     20  const pauseResumeButton = panel.querySelector(".pause-resume-button");
     21  await testPauseAndResumeBySpacebar(animationInspector, pauseResumeButton);
     22 
     23  info("Checking spacebar works with other UI components");
     24  // To pause
     25  clickOnPauseResumeButton(animationInspector, panel);
     26  await waitUntilAnimationsPlayState(animationInspector, "paused");
     27  // To resume
     28  sendSpaceKeyEvent(animationInspector, panel);
     29  await waitUntilAnimationsPlayState(animationInspector, "running");
     30  // To pause
     31  clickOnCurrentTimeScrubberController(animationInspector, panel, 0.5);
     32  await waitUntilAnimationsPlayState(animationInspector, "paused");
     33  // To resume
     34  clickOnPauseResumeButton(animationInspector, panel);
     35  await waitUntilAnimationsPlayState(animationInspector, "running");
     36  // To pause
     37  sendSpaceKeyEvent(animationInspector, panel);
     38  await waitUntilAnimationsPlayState(animationInspector, "paused");
     39  ok(true, "All components that can make animations pause/resume works fine");
     40 });
     41 
     42 async function testPauseAndResumeBySpacebar(animationInspector, element) {
     43  await sendSpaceKeyEvent(animationInspector, element);
     44  await waitUntilAnimationsPlayState(animationInspector, "paused");
     45  ok(true, "Space key can pause animations");
     46  await sendSpaceKeyEvent(animationInspector, element);
     47  await waitUntilAnimationsPlayState(animationInspector, "running");
     48  ok(true, "Space key can resume animations");
     49 }