Bug 118405 - Update Exception handling in WebAudio
Summary: Update Exception handling in WebAudio
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Audio (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: WebExposed
Depends on:
Blocks:
 
Reported: 2013-07-04 22:29 PDT by Praveen Jadhav
Modified: 2013-07-09 03:00 PDT (History)
8 users (show)

See Also:


Attachments
Patch (20.44 KB, patch)
2013-07-04 22:39 PDT, Praveen Jadhav
sam: review-
Details | Formatted Diff | Diff
Patch (20.01 KB, patch)
2013-07-07 21:41 PDT, Praveen Jadhav
crogers: review+
Details | Formatted Diff | Diff
Patch (20.32 KB, patch)
2013-07-08 23:48 PDT, Praveen Jadhav
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Praveen Jadhav 2013-07-04 22:29:24 PDT
AudioBufferSourceNode, OscillatorNode and AnalyserNode doesn't propagate any exceptions specified in WebAudio specification.
Comment 1 Praveen Jadhav 2013-07-04 22:39:56 PDT
Created attachment 206122 [details]
Patch

Patch updated to handle exception in WebAudio.
Comment 2 Chris Dumez 2013-07-04 23:38:28 PDT
Comment on attachment 206122 [details]
Patch

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

> Source/WebCore/ChangeLog:8
> +        AudioBufferSourceNode, OscillatorNode and AnalyserNode don't propagate any exceptions specified in WebAudio spec.

Throwing new exceptions is risky business when it comes to backward compatibility.

> Source/WebCore/Modules/webaudio/AudioContext.cpp:555
> +        ec = INDEX_SIZE_ERR;

Where is this exception name specified?

> Source/WebCore/Modules/webaudio/AudioContext.cpp:601
> +    if (!real || !imag || (real->length() != imag->length() || (real->length() > 4096))) {

Would be nice to have a global static const variable for that magic number. Alsom , the spec says that the value should be greater than 0 but it does not seem to be covered, right?

> Source/WebCore/Modules/webaudio/AudioContext.cpp:602
> +        ec = INDEX_SIZE_ERR;

Does the spec actually specify it needs to be a IndexSizeError and not a SyntaxError? I cannot find it.

> LayoutTests/webaudio/analyser-exception.html:34
> +    shouldThrow("analyser.minDecibels = -20");

shouldThrow() can take a second argument with the exception name to validate that as well. If you expect a specific exception, you probably want to add that (although the spec does not seem to indicate exception names?)
Comment 3 Sam Weinig 2013-07-05 21:24:45 PDT
Comment on attachment 206122 [details]
Patch

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

>> Source/WebCore/ChangeLog:8
>> +        AudioBufferSourceNode, OscillatorNode and AnalyserNode don't propagate any exceptions specified in WebAudio spec.
> 
> Throwing new exceptions is risky business when it comes to backward compatibility.

While I usually am a champion for this point, given how little WebAudio content there is, I am not too worried here.

>> LayoutTests/webaudio/analyser-exception.html:34
>> +    shouldThrow("analyser.minDecibels = -20");
> 
> shouldThrow() can take a second argument with the exception name to validate that as well. If you expect a specific exception, you probably want to add that (although the spec does not seem to indicate exception names?)

I agree with Christophe, you should specify what exception you expect.  If the spec isn't specifying it clearly, we should get it updated.
Comment 4 Praveen Jadhav 2013-07-07 21:41:10 PDT
Created attachment 206215 [details]
Patch

Patch updated as per the review comments. Description for start and stop methods in AudioBufferSourceNode says 'an exception will be thrown' but doesn't specify the exact DOM exception. INVALID_STATE_ERR seems to be appropriate error in this case.

@crogers: WDYT?
Comment 5 Chris Rogers 2013-07-08 12:09:48 PDT
Comment on attachment 206215 [details]
Patch

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

Looks good if comment is added

> LayoutTests/webaudio/audiobuffersource-exception.html:34
> +

It would be nice to add brief comments describing why each case should throw an exception.
Comment 6 Praveen Jadhav 2013-07-08 23:48:31 PDT
Created attachment 206296 [details]
Patch

Comments updated in Layouttest files.
Comment 7 WebKit Commit Bot 2013-07-09 03:00:24 PDT
Comment on attachment 206296 [details]
Patch

Clearing flags on attachment: 206296

Committed r152489: <http://trac.webkit.org/changeset/152489>
Comment 8 WebKit Commit Bot 2013-07-09 03:00:27 PDT
All reviewed patches have been landed.  Closing bug.