WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
298227
TextTrackCue/VTTCue fails to dispatch enter/exit events (when no track is associated) so 4 WPT tests fail
https://bugs.webkit.org/show_bug.cgi?id=298227
Summary
TextTrackCue/VTTCue fails to dispatch enter/exit events (when no track is ass...
Rob Smith
Reported
2025-09-02 06:25:45 PDT
Created
attachment 476586
[details]
WPT TextTrackCue results showing 4 onenter/onexit failures Steps to reproduce: 1. Run Web Platform Tests for TextTrackCue directly or view results at
https://wpt.fyi/results/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue?label=master&label=experimental&aligned&q=texttrackcue
2. Note that onenter.html and onexit.html tests fail on WebKit, but pass on Firefox. Problem description: Calling dispatchEvent() on a cue derived from TextTrackCue, such as VTTCue or DataCue, should invoke its associated event handler(s) synchronously. This behaviour should be inherited from EventTarget - see
https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/dispatchEvent
- but the event handler is not invoked by WebKit which causes these four WPT tests to fail. * onenter results (2 tests):
https://wpt.fyi/results/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/onenter.html?label=master&label=experimental&aligned&q=texttrackcue
* onexit results (2 tests):
https://wpt.fyi/results/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/onexit.html?label=master&label=experimental&aligned&q=texttrackcue
Additional comments: 1. These four WPT tests pass in Firefox. 2. Issue
https://github.com/w3c/webvtt/issues/519
addresses other properties inherited by VTTCue from TextTrackCue and these two issues may be related. 3. A proposal has been raised in WICG DataCue to expose TextTrackCue's constructor that would allow removal of the dependency on VTTCue from TextTrackCue WPT tests which could help to resolve these and future issues:
https://github.com/WICG/datacue/blob/main/text-track-cue-constructor.md
Attachments
WPT TextTrackCue results showing 4 onenter/onexit failures
(194.65 KB, image/jpeg)
2025-09-02 06:25 PDT
,
Rob Smith
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Karl Dubost
Comment 1
2025-09-03 00:30:25 PDT
IDL in Safari The current code has a couple of FIXME
https://searchfox.org/wubkat/rev/487a3721e3ff1de52e9baa5a4ba9190889bb1204/Source/WebCore/html/track/TextTrackCue.idl
[ Conditional=VIDEO, CustomIsReachable, CustomToJSObject, JSCustomMarkFunction, SkipVTableValidation, LegacyFactoryFunctionEnabledBySetting=GenericCueAPIEnabled, Exposed=Window ] interface TextTrackCue : EventTarget { readonly attribute TextTrack? track; attribute [AtomString] DOMString id; attribute double startTime; // FIXME: Add 'unrestricted' to 'endTime' to align with the specification. See:
https://bugs.webkit.org/show_bug.cgi?id=260765
attribute double endTime; attribute boolean pauseOnExit; attribute EventHandler onenter; attribute EventHandler onexit; // FIXME: Add 'unrestricted' to 'endTime' to align with the specification. See:
https://bugs.webkit.org/show_bug.cgi?id=260765
[CallWith=CurrentDocument] constructor(double startTime, double endTime, DocumentFragment cueNode); [EnabledBySetting=GenericCueAPIEnabled] DocumentFragment getCueAsHTML(); }; IDL in Firefox.
https://searchfox.org/firefox-main/rev/8a50d94240fb8f312d8b061a425ff0755bcbaac4/dom/webidl/TextTrackCue.webidl
[Exposed=Window] interface TextTrackCue : EventTarget { readonly attribute TextTrack? track; attribute DOMString id; attribute double startTime; attribute double endTime; attribute boolean pauseOnExit; attribute EventHandler onenter; attribute EventHandler onexit; }; Spec IDL is defined as [Exposed=Window] interface TextTrackCue : EventTarget { readonly attribute TextTrack? track; attribute DOMString id; attribute double startTime; attribute unrestricted double endTime; attribute boolean pauseOnExit; attribute EventHandler onenter; attribute EventHandler onexit; }; The first test being failed in
https://wpt.live/html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/onenter.html
Fail assert_true(false, "dispatching event") /html/semantics/embedded-content/media-elements/interfaces/TextTrackCue/onenter.html:20:16 test(function(){ assert_equals(c1.onenter, null, 'initial value'); c1.onenter = undefined; assert_equals(c1.onenter, null, 'assigning undefined'); c1.onenter = cb; assert_equals(c1.onenter, cb, 'assigning onenter'); // FAILING HERE c1.dispatchEvent(ev); assert_true(ran, 'dispatching event'); // NEXT TEXT c1.onenter = null; assert_equals(c1.onenter, null, 'assigning null'); ran = false; c1.dispatchEvent(ev); assert_false(ran, 'dispatching event after nulling onenter'); });
https://searchfox.org/wubkat/rev/487a3721e3ff1de52e9baa5a4ba9190889bb1204/Source/WebCore/html/track/TextTrackCue.cpp#338-345
```cpp void TextTrackCue::dispatchEvent(Event& event) { // When a TextTrack's mode is disabled: no cues are active, no events fired. if (!track() || track()->mode() == TextTrack::Mode::Disabled) return; EventTarget::dispatchEvent(event); } ```
Karl Dubost
Comment 2
2025-09-03 00:43:15 PDT
in the dispatchEvent, there is a dependency on track being defined and not disabled. Is the WPT test correct? The setup function doesn't have an instantiation of a track. setup(function(){ window.c1 = new VTTCue(0, 1, 'text1'); window.ev = new Event('enter'); window.ran = false; window.cb = function() { ran = true; }; }); Would the test PASS if it was initializing a TextTrack first. c1.track returns null The specs says: cue.track Returns the TextTrack object to which this text track cue belongs, if any, or null otherwise. and The following are the event handlers (and their corresponding event handler event types) that must be supported, as event handler IDL attributes, by all objects implementing the TextTrackCue interface: onenter onexit So does it make sense to work without a text track in Firefox?
Rob Smith
Comment 3
2025-09-03 04:06:41 PDT
(In reply to Karl Dubost from
comment #2
)
> in the dispatchEvent, there is a dependency on track being defined and not > disabled. > Is the WPT test correct?
The short answer is: yes. The longer answer is: TextTrackCue inherits dispatchEvent() from EventTarget according to
https://html.spec.whatwg.org/multipage/media.html#texttrackcue
: interface TextTrackCue : EventTarget { readonly attribute TextTrack? track; attribute DOMString id; attribute double startTime; attribute unrestricted double endTime; attribute boolean pauseOnExit; attribute EventHandler onenter; attribute EventHandler onexit; }; HTML does not specify any override of dispatchEvent functionality for TextTrackCue, so this function should have no dependency on any attribute of TextTrackCue and the WPT test is correct. The code you've identified in WebKit's TextTrackCue::dispatchEvent implementation is not compliant with HTML:
https://searchfox.org/wubkat/rev/487a3721e3ff1de52e9baa5a4ba9190889bb1204/Source/WebCore/html/track/TextTrackCue.cpp#340-342
> So does it make sense to work without a text track in Firefox?
Yes. HTML imposes no special conditions on how TextTrackCue events are dispatched - which could be either via TextTrack or by a direct call to dispatchEvent. TextTrackCue acts as the container object for timed metadata cues which may not require any real time scheduling at all, such as a video metadata search use case:
https://www.w3.org/TR/webvmt/#area-monitoring
Hope this helps.
Rob Smith
Comment 4
2025-09-05 10:00:54 PDT
https://searchfox.org/wubkat/rev/487a3721e3ff1de52e9baa5a4ba9190889bb1204/Source/WebCore/html/track/TextTrackCue.cpp#338
Renaming WebKit's TextTrackCue::dispatchEvent function would retain its existing functionality, avoid overriding EventTarget::dispatchEvent to comply with the HTML specification and allow the WPT tests to pass with no loss of capability. Hope this helps.
Radar WebKit Bug Importer
Comment 5
2025-09-09 06:26:16 PDT
<
rdar://problem/160195643
>
Karl Dubost
Comment 6
2025-09-09 22:16:55 PDT
Pull request:
https://github.com/WebKit/WebKit/pull/50526
EWS
Comment 7
2025-10-20 16:28:54 PDT
Committed
301836@main
(8956674a34a3): <
https://commits.webkit.org/301836@main
> Reviewed commits have been landed. Closing PR #50526 and removing active labels.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug