tor-browser

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

event-trigger-repeat.tentative.html (2654B)


      1 <!DOCTYPE html>
      2 <html>
      3  <head>
      4    <link rel="help" href="https://drafts.csswg.org/web-animations-2#animation-trigger">
      5    <script src="/resources/testdriver.js"></script>
      6    <script src="/resources/testdriver-vendor.js"></script>
      7    <script src="/resources/testharness.js"></script>
      8    <script src="/resources/testharnessreport.js"></script>
      9    <script src="/web-animations/testcommon.js"></script>
     10  </head>
     11  <body>
     12    <div id="event-target">Click me!</div>
     13 
     14    <div id="animation-target">Watch me!</div>
     15    <script>
     16      promise_test(async (test) => {
     17        const eventTarget = document.getElementById("event-target");
     18        const animationTarget = document.getElementById("animation-target");
     19        const ANIMATION_DURATION_MS = 10000;
     20        const animation = new Animation(
     21          new KeyframeEffect(
     22            animationTarget,
     23            [
     24              { transform: "translateY(0)" },
     25              { transform: "translateY(3rem)" },
     26            ],
     27            { duration: ANIMATION_DURATION_MS, fill: "both" }
     28          ));
     29        const trigger = new EventTrigger({
     30          eventType: "click",
     31          eventTarget: eventTarget
     32        });
     33        trigger.addAnimation(animation, "replay");
     34        await waitForAnimationFrames(1);
     35        assert_equals(animation.playState, "idle", "animation is idle");
     36        await test_driver.click(eventTarget);
     37        await waitForAnimationFrames(3);
     38        assert_equals(animation.playState, "running", "animation is running");
     39        assert_less_than(0, animation.overallProgress, "Animation has progressed");
     40        let progress = animation.overallProgress;
     41        await test_driver.click(eventTarget);
     42        await waitForAnimationFrames(1);
     43        assert_equals(animation.playState, "running", "animation is still running");
     44        assert_less_than(animation.overallProgress, progress, "Progress has been reset");
     45        animation.finish();
     46        await waitForAnimationFrames(1);
     47        assert_equals(animation.playState, "finished", "Animation has finished");
     48        await test_driver.click(eventTarget);
     49        await waitForAnimationFrames(1);
     50        assert_equals(animation.playState, "running", "animation is running again");
     51        animation.pause();
     52        await waitForAnimationFrames(1);
     53        assert_equals(animation.playState, "paused", "Animation is paused");
     54        await test_driver.click(eventTarget);
     55        await waitForAnimationFrames(1);
     56        assert_equals(animation.playState, "running", "animation is running after pause");
     57      }, "Basic event-based animation-trigger with 'repeat' behavior");
     58    </script>
     59  </body>
     60 </html>