<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>290772</bug_id>
          
          <creation_ts>2025-03-31 10:37:32 -0700</creation_ts>
          <short_desc>[web-animations] animation events do not get fired if relevant event listeners are added dynamically after they are enqueued</short_desc>
          <delta_ts>2025-04-03 22:38:17 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Animations</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://github.com/web-platform-tests/wpt/pull/51828</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>290836</dependson>
          <blocked>290993</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Antoine Quint">graouts</reporter>
          <assigned_to name="Antoine Quint">graouts</assigned_to>
          <cc>graouts</cc>
    
    <cc>karlcow</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2107460</commentid>
    <comment_count>0</comment_count>
      <attachid>474773</attachid>
    <who name="Antoine Quint">graouts</who>
    <bug_when>2025-03-31 10:37:32 -0700</bug_when>
    <thetext>Created attachment 474773
Test

The attached test case adds `finish` and `cancel` events after a `finished` promise has resolved and the `cancel()` method was called on the finished animation. Due to the asynchronous nature of animation events, which are first enqueued and later dispatched in one batch, and our optimization where only events with registered event listeners are enqueued (see 262123@main), we fail to dispatch the expected events. This also affects Chrome, though I&apos;m not sure this is for the same reason.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2107463</commentid>
    <comment_count>1</comment_count>
    <who name="Antoine Quint">graouts</who>
    <bug_when>2025-03-31 10:42:45 -0700</bug_when>
    <thetext>Filed a similar bug on Chrome: https://issues.chromium.org/issues/407497938. This works as expected in Firefox.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2108482</commentid>
    <comment_count>2</comment_count>
    <who name="Antoine Quint">graouts</who>
    <bug_when>2025-04-03 05:45:26 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/43536</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2108483</commentid>
    <comment_count>3</comment_count>
    <who name="Antoine Quint">graouts</who>
    <bug_when>2025-04-03 05:45:52 -0700</bug_when>
    <thetext>Submitted web-platform-tests pull request: https://github.com/web-platform-tests/wpt/pull/51828</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2108783</commentid>
    <comment_count>4</comment_count>
    <who name="Antoine Quint">graouts</who>
    <bug_when>2025-04-03 22:34:37 -0700</bug_when>
    <thetext>*** Bug 290836 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2108784</commentid>
    <comment_count>5</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2025-04-03 22:37:29 -0700</bug_when>
    <thetext>Committed 293217@main (fdfe5c907393): &lt;https://commits.webkit.org/293217@main&gt;

Reviewed commits have been landed. Closing PR #43536 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2108785</commentid>
    <comment_count>6</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2025-04-03 22:38:17 -0700</bug_when>
    <thetext>&lt;rdar://problem/148572720&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>474773</attachid>
            <date>2025-03-31 10:37:32 -0700</date>
            <delta_ts>2025-03-31 10:37:32 -0700</delta_ts>
            <desc>Test</desc>
            <filename>dynamic-finish-and-cancel-event.html</filename>
            <type>text/html</type>
            <size>1952</size>
            <attacher name="Antoine Quint">graouts</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ImVuIj4KPGhlYWQ+CiAgICA8bWV0YSBjaGFyc2V0
PSJ1dGYtOCI+CiAgICA8bWV0YSBodHRwLWVxdWl2PSJ4LXVhLWNvbXBhdGlibGUiIGNvbnRlbnQ9
ImllPWVkZ2UiPgogICAgPG1ldGEgbmFtZT0idmlld3BvcnQiIGNvbnRlbnQ9IndpZHRoPWRldmlj
ZS13aWR0aCwgaW5pdGlhbC1zY2FsZT0xLCBzaHJpbmstdG8tZml0PW5vIj4KICAgIDx0aXRsZT48
L3RpdGxlPgogICAgPHN0eWxlPgoKI3RhcmdldCB7CiAgICB3aWR0aDogMTAwcHg7CiAgICBoZWln
aHQ6IDEwMHB4OwogICAgYmFja2dyb3VuZC1jb2xvcjogYmxhY2s7Cn0KCiAgICA8L3N0eWxlPgo8
L2hlYWQ+Cjxib2R5PgoKPGRpdiBpZD0idGFyZ2V0Ij48L2Rpdj4KCjxzY3JpcHQ+CgooYXN5bmMg
ZnVuY3Rpb24oKSB7CiAgICBhd2FpdCBuZXcgUHJvbWlzZShyZXF1ZXN0QW5pbWF0aW9uRnJhbWUp
OwoKICAgIGNvbnN0IGFuaW1hdGlvbiA9IHRhcmdldC5hbmltYXRlKHsgbWFyZ2luTGVmdDogIjEw
MHB4IiB9LCAxMDApOwoKICAgIC8vIFRoZSAiZmluaXNoZWQiIHByb21pc2Ugd2lsbCBiZSByZXNv
bHZlZCB3aGVuIHRoZSB0aW1lbGluZSBhZHZhbmNlcyB0byBhIHRpbWUKICAgIC8vIHBhc3QgMTAw
bXMgb2YgdGhlIGFuaW1hdGlvbiBzdGFydCB0aW1lLiBUaGlzIGhhcHBlbnMgYXMgc3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