Bug 132321

Summary: AX: SpeechSynthesisUtterance cannot addEventListener
Product: WebKit Reporter: chris fleizach <cfleizach>
Component: AccessibilityAssignee: chris fleizach <cfleizach>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, commit-queue, esprehn+autocc, kondapallykalyan, mario, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
patch mario: review+

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); });


<rdar://problem/14887812>
Comment 1 chris fleizach 2014-04-29 00:16:37 PDT
Created attachment 230358 [details]
patch
Comment 2 Mario Sanchez Prada 2014-04-29 02:29:43 PDT
Comment on attachment 230358 [details]
patch

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
http://trac.webkit.org/changeset/167933

Thanks Mario!