tor-browser

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

event-trigger-before-handlers.tentative.html (1869B)


      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        let listenerRan = false;
     30        eventTarget.addEventListener("click", evt => {
     31          listenerRan = true;
     32          assert_equals(
     33            animation.playState, "running",
     34            "Animation is already running when event listener runs");
     35        });
     36        const trigger = new EventTrigger({
     37          eventType: "click",
     38          eventTarget: eventTarget
     39        });
     40        trigger.addAnimation(animation, "play");
     41        await waitForAnimationFrames(2);
     42        assert_equals(animation.playState, "idle", "animation is idle");
     43        await test_driver.click(eventTarget);
     44        await waitForAnimationFrames(1);
     45        assert_true(listenerRan, "Click event listener ran.");
     46      }, "Animation triggers are handled before registered event listeners");
     47    </script>
     48  </body>
     49 </html>