Bug 132321 - AX: SpeechSynthesisUtterance cannot addEventListener
Summary: AX: SpeechSynthesisUtterance cannot addEventListener
Alias: None
Product: WebKit
Classification: Unclassified
Component: Accessibility (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: chris fleizach
Keywords: InRadar
Depends on:
Reported: 2014-04-29 00:14 PDT by chris fleizach
Modified: 2014-04-29 09:05 PDT (History)
6 users (show)

See Also:

patch (2.77 KB, patch)
2014-04-29 00:16 PDT, chris fleizach
mario: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description chris fleizach 2014-04-29 00:14:48 PDT
According to the Web Speech API spec, the SpeechSynthesisUtterance is a subclass of EventTarget. Therefore it has event handler attributes like `onend` and `onresume`.

However it did not implement the `addEventListener` method, so you cannot hook event handlers to an utterance instance via the more common way.

Steps to Reproduce:
1. var u = new SpeechSynthesisUtterance("Test speech");
2. u.addEventListener('end', function(e) { console.log(e); });

Comment 1 chris fleizach 2014-04-29 00:16:37 PDT
Created attachment 230358 [details]
Comment 2 Mario Sanchez Prada 2014-04-29 02:29:43 PDT
Comment on attachment 230358 [details]

View in context: https://bugs.webkit.org/attachment.cgi?id=230358&action=review

It looks good to me, but please take into consideration my comments below (should they make sense to you too). Thanks!

> Source/WebCore/Modules/speech/SpeechSynthesisUtterance.idl:40
> +    void addEventListener(DOMString type, EventListener listener, optional boolean useCapture);
> +    void removeEventListener(DOMString type, EventListener listener, optional boolean useCapture);

I know you probably don't need it for this specific case, but wouldn't it be a good idea to add EventTarget's dispatchEvent() here too, so the implementation of that interface is complete insite SpeechSynthesisUtterance?

Also, for consistency with other IDLs (e.g. html/MediaController.idl, html/track/TextTrack.idl...), I guess I would add these methods to the end with a comment "// EventTarget interface" on top for clarity.
Comment 3 chris fleizach 2014-04-29 09:05:44 PDT

Thanks Mario!