Changeset 268812 in webkit


Ignore:
Timestamp:
Oct 21, 2020 11:38:48 AM (21 months ago)
Author:
Chris Dumez
Message:

Make sure WebAudio API throws exceptions with useful error messages
https://bugs.webkit.org/show_bug.cgi?id=218033

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Rebaseline existing tests now that exception messages have been improved.

  • web-platform-tests/webaudio/the-audio-api/the-constantsourcenode-interface/constant-source-basic-expected.txt:
  • web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/convolver-channels-expected.txt:
  • web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/ctor-convolver-expected.txt:
  • web-platform-tests/webaudio/the-audio-api/the-delaynode-interface/delaynode-maxdelaylimit-expected.txt:

Source/WebCore:

Make sure WebAudio API throws exceptions with useful error messages to be
more developer friendly.

No new tests, rebaselined existing tests.

  • Modules/webaudio/AudioContext.cpp:

(WebCore::AudioContext::create):

  • Modules/webaudio/AudioScheduledSourceNode.cpp:

(WebCore::AudioScheduledSourceNode::startLater):

  • Modules/webaudio/AudioWorkletGlobalScope.cpp:

(WebCore::AudioWorkletGlobalScope::registerProcessor):

  • Modules/webaudio/BaseAudioContext.cpp:

(WebCore::BaseAudioContext::createScriptProcessor):
(WebCore::BaseAudioContext::finishedRendering):

  • Modules/webaudio/ConvolverNode.cpp:

(WebCore::ConvolverNode::setBuffer):

  • Modules/webaudio/DefaultAudioDestinationNode.cpp:

(WebCore::DefaultAudioDestinationNode::startRendering):

  • Modules/webaudio/DelayNode.cpp:

(WebCore::DelayNode::create):

  • Modules/webaudio/OfflineAudioContext.cpp:

(WebCore::OfflineAudioContext::create):

  • Modules/webaudio/OfflineAudioDestinationNode.cpp:

(WebCore::OfflineAudioDestinationNode::startRendering):

LayoutTests:

Rebaseline existing tests now that exception messages have been improved.

  • webaudio/Oscillator/oscillator-basic-expected.txt:
  • webaudio/ScriptProcessor/scriptprocessornode-expected.txt:
  • webaudio/convolver-channels-expected.txt:
  • webaudio/convolver-setBuffer-different-samplerate-expected.txt:
  • webaudio/delaynode-maxdelaylimit-expected.txt:
  • webaudio/dom-exceptions-expected.txt:
Location:
trunk
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r268810 r268812  
     12020-10-21  Chris Dumez  <cdumez@apple.com>
     2
     3        Make sure WebAudio API throws exceptions with useful error messages
     4        https://bugs.webkit.org/show_bug.cgi?id=218033
     5
     6        Reviewed by Darin Adler.
     7
     8        Rebaseline existing tests now that exception messages have been improved.
     9
     10        * webaudio/Oscillator/oscillator-basic-expected.txt:
     11        * webaudio/ScriptProcessor/scriptprocessornode-expected.txt:
     12        * webaudio/convolver-channels-expected.txt:
     13        * webaudio/convolver-setBuffer-different-samplerate-expected.txt:
     14        * webaudio/delaynode-maxdelaylimit-expected.txt:
     15        * webaudio/dom-exceptions-expected.txt:
     16
    1172020-10-21  Antoine Quint  <graouts@webkit.org>
    218
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r268792 r268812  
     12020-10-21  Chris Dumez  <cdumez@apple.com>
     2
     3        Make sure WebAudio API throws exceptions with useful error messages
     4        https://bugs.webkit.org/show_bug.cgi?id=218033
     5
     6        Reviewed by Darin Adler.
     7
     8        Rebaseline existing tests now that exception messages have been improved.
     9
     10        * web-platform-tests/webaudio/the-audio-api/the-constantsourcenode-interface/constant-source-basic-expected.txt:
     11        * web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/convolver-channels-expected.txt:
     12        * web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/ctor-convolver-expected.txt:
     13        * web-platform-tests/webaudio/the-audio-api/the-delaynode-interface/delaynode-maxdelaylimit-expected.txt:
     14
    1152020-10-20  Sergio Villar Senin  <svillar@igalia.com>
    216
  • trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-constantsourcenode-interface/constant-source-basic-expected.txt

    r267649 r268812  
    3737PASS   Calling stop() before start() threw InvalidStateError: "cannot call stop without calling start first.".
    3838PASS   start(-1) threw RangeError: "when value should be positive".
    39 PASS   Calling start() twice threw InvalidStateError: "The object is in an invalid state.".
     39PASS   Calling start() twice threw InvalidStateError: "Cannot call start() more than once".
    4040PASS   stop(-1) threw RangeError: "when value should be positive".
    4141PASS   stop(NaN) threw TypeError: "The provided value is non-finite".
  • trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/convolver-channels-expected.txt

    r267649 r268812  
    66PASS   ConvolverNode with buffer of 1 channels did not throw an exception.
    77PASS   ConvolverNode with buffer of 2 channels did not throw an exception.
    8 PASS   ConvolverNode with buffer of 3 channels threw NotSupportedError: "The operation is not supported.".
     8PASS   ConvolverNode with buffer of 3 channels threw NotSupportedError: "Buffer should have 1, 2 or 4 channels".
    99PASS   ConvolverNode with buffer of 4 channels did not throw an exception.
    10 PASS   ConvolverNode with buffer of 5 channels threw NotSupportedError: "The operation is not supported.".
    11 PASS   ConvolverNode with buffer of 6 channels threw NotSupportedError: "The operation is not supported.".
    12 PASS   ConvolverNode with buffer of 7 channels threw NotSupportedError: "The operation is not supported.".
    13 PASS   ConvolverNode with buffer of 8 channels threw NotSupportedError: "The operation is not supported.".
    14 PASS   ConvolverNode with buffer of 9 channels threw NotSupportedError: "The operation is not supported.".
    15 PASS   ConvolverNode with buffer of 10 channels threw NotSupportedError: "The operation is not supported.".
    16 PASS   ConvolverNode with buffer of 11 channels threw NotSupportedError: "The operation is not supported.".
    17 PASS   ConvolverNode with buffer of 12 channels threw NotSupportedError: "The operation is not supported.".
    18 PASS   ConvolverNode with buffer of 13 channels threw NotSupportedError: "The operation is not supported.".
    19 PASS   ConvolverNode with buffer of 14 channels threw NotSupportedError: "The operation is not supported.".
    20 PASS   ConvolverNode with buffer of 15 channels threw NotSupportedError: "The operation is not supported.".
    21 PASS   ConvolverNode with buffer of 16 channels threw NotSupportedError: "The operation is not supported.".
    22 PASS   ConvolverNode with buffer of 17 channels threw NotSupportedError: "The operation is not supported.".
    23 PASS   ConvolverNode with buffer of 18 channels threw NotSupportedError: "The operation is not supported.".
    24 PASS   ConvolverNode with buffer of 19 channels threw NotSupportedError: "The operation is not supported.".
    25 PASS   ConvolverNode with buffer of 20 channels threw NotSupportedError: "The operation is not supported.".
    26 PASS   ConvolverNode with buffer of 21 channels threw NotSupportedError: "The operation is not supported.".
    27 PASS   ConvolverNode with buffer of 22 channels threw NotSupportedError: "The operation is not supported.".
    28 PASS   ConvolverNode with buffer of 23 channels threw NotSupportedError: "The operation is not supported.".
    29 PASS   ConvolverNode with buffer of 24 channels threw NotSupportedError: "The operation is not supported.".
    30 PASS   ConvolverNode with buffer of 25 channels threw NotSupportedError: "The operation is not supported.".
    31 PASS   ConvolverNode with buffer of 26 channels threw NotSupportedError: "The operation is not supported.".
    32 PASS   ConvolverNode with buffer of 27 channels threw NotSupportedError: "The operation is not supported.".
    33 PASS   ConvolverNode with buffer of 28 channels threw NotSupportedError: "The operation is not supported.".
    34 PASS   ConvolverNode with buffer of 29 channels threw NotSupportedError: "The operation is not supported.".
    35 PASS   ConvolverNode with buffer of 30 channels threw NotSupportedError: "The operation is not supported.".
    36 PASS   ConvolverNode with buffer of 31 channels threw NotSupportedError: "The operation is not supported.".
    37 PASS   ConvolverNode with buffer of 32 channels threw NotSupportedError: "The operation is not supported.".
     10PASS   ConvolverNode with buffer of 5 channels threw NotSupportedError: "Buffer should have 1, 2 or 4 channels".
     11PASS   ConvolverNode with buffer of 6 channels threw NotSupportedError: "Buffer should have 1, 2 or 4 channels".
     12PASS   ConvolverNode with buffer of 7 channels threw NotSupportedError: "Buffer should have 1, 2 or 4 channels".
     13PASS   ConvolverNode with buffer of 8 channels threw NotSupportedError: "Buffer should have 1, 2 or 4 channels".
     14PASS   ConvolverNode with buffer of 9 channels threw NotSupportedError: "Buffer should have 1, 2 or 4 channels".
     15PASS   ConvolverNode with buffer of 10 channels threw NotSupportedError: "Buffer should have 1, 2 or 4 channels".
     16PASS   ConvolverNode with buffer of 11 channels threw NotSupportedError: "Buffer should have 1, 2 or 4 channels".
     17PASS   ConvolverNode with buffer of 12 channels threw NotSupportedError: "Buffer should have 1, 2 or 4 channels".
     18PASS   ConvolverNode with buffer of 13 channels threw NotSupportedError: "Buffer should have 1, 2 or 4 channels".
     19PASS   ConvolverNode with buffer of 14 channels threw NotSupportedError: "Buffer should have 1, 2 or 4 channels".
     20PASS   ConvolverNode with buffer of 15 channels threw NotSupportedError: "Buffer should have 1, 2 or 4 channels".
     21PASS   ConvolverNode with buffer of 16 channels threw NotSupportedError: "Buffer should have 1, 2 or 4 channels".
     22PASS   ConvolverNode with buffer of 17 channels threw NotSupportedError: "Buffer should have 1, 2 or 4 channels".
     23PASS   ConvolverNode with buffer of 18 channels threw NotSupportedError: "Buffer should have 1, 2 or 4 channels".
     24PASS   ConvolverNode with buffer of 19 channels threw NotSupportedError: "Buffer should have 1, 2 or 4 channels".
     25PASS   ConvolverNode with buffer of 20 channels threw NotSupportedError: "Buffer should have 1, 2 or 4 channels".
     26PASS   ConvolverNode with buffer of 21 channels threw NotSupportedError: "Buffer should have 1, 2 or 4 channels".
     27PASS   ConvolverNode with buffer of 22 channels threw NotSupportedError: "Buffer should have 1, 2 or 4 channels".
     28PASS   ConvolverNode with buffer of 23 channels threw NotSupportedError: "Buffer should have 1, 2 or 4 channels".
     29PASS   ConvolverNode with buffer of 24 channels threw NotSupportedError: "Buffer should have 1, 2 or 4 channels".
     30PASS   ConvolverNode with buffer of 25 channels threw NotSupportedError: "Buffer should have 1, 2 or 4 channels".
     31PASS   ConvolverNode with buffer of 26 channels threw NotSupportedError: "Buffer should have 1, 2 or 4 channels".
     32PASS   ConvolverNode with buffer of 27 channels threw NotSupportedError: "Buffer should have 1, 2 or 4 channels".
     33PASS   ConvolverNode with buffer of 28 channels threw NotSupportedError: "Buffer should have 1, 2 or 4 channels".
     34PASS   ConvolverNode with buffer of 29 channels threw NotSupportedError: "Buffer should have 1, 2 or 4 channels".
     35PASS   ConvolverNode with buffer of 30 channels threw NotSupportedError: "Buffer should have 1, 2 or 4 channels".
     36PASS   ConvolverNode with buffer of 31 channels threw NotSupportedError: "Buffer should have 1, 2 or 4 channels".
     37PASS   ConvolverNode with buffer of 32 channels threw NotSupportedError: "Buffer should have 1, 2 or 4 channels".
    3838PASS < [channel-count-test] All assertions passed. (total 32 assertions)
    3939PASS # AUDIT TASK RUNNER FINISHED: 1 tasks ran successfully.
  • trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/ctor-convolver-expected.txt

    r267649 r268812  
    5353PASS < [nullable buffer] All assertions passed. (total 2 assertions)
    5454PASS > [illegal sample-rate]
    55 PASS   node1 = new ConvolverNode(c, {"buffer":{}} threw NotSupportedError: "The operation is not supported.".
     55PASS   node1 = new ConvolverNode(c, {"buffer":{}} threw NotSupportedError: "Buffer sample rate does not match the context's sample rate".
    5656PASS < [illegal sample-rate] All assertions passed. (total 1 assertions)
    5757PASS > [construct with options]
  • trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-delaynode-interface/delaynode-maxdelaylimit-expected.txt

    r267649 r268812  
    44PASS Audit report
    55PASS > [test] Tests attribute and maximum allowed delay of DelayNode
    6 PASS   Setting Delay length to 180 seconds or more threw NotSupportedError: "The operation is not supported.".
    7 PASS   Setting Delay length to 0 seconds threw NotSupportedError: "The operation is not supported.".
    8 PASS   Setting Delay length to negative threw NotSupportedError: "The operation is not supported.".
     6PASS   Setting Delay length to 180 seconds or more threw NotSupportedError: "maxDelayTime should be less than 180".
     7PASS   Setting Delay length to 0 seconds threw NotSupportedError: "maxDelayTime should be a positive value".
     8PASS   Setting Delay length to negative threw NotSupportedError: "maxDelayTime should be a positive value".
    99PASS   Setting Delay length to NaN threw TypeError: "The provided value is non-finite".
    1010PASS   delay.delayTime.value = 0.5 is equal to 0.5.
  • trunk/LayoutTests/webaudio/Oscillator/oscillator-basic-expected.txt

    r267644 r268812  
    2121PASS   Calling stop() before start() threw InvalidStateError: "cannot call stop without calling start first.".
    2222PASS   start(-1) threw RangeError: "when value should be positive".
    23 PASS   Calling start() twice threw InvalidStateError: "The object is in an invalid state.".
     23PASS   Calling start() twice threw InvalidStateError: "Cannot call start() more than once".
    2424PASS   stop(-1) threw RangeError: "when value should be positive".
    2525PASS   stop(NaN) threw TypeError: "The provided value is non-finite".
  • trunk/LayoutTests/webaudio/ScriptProcessor/scriptprocessornode-expected.txt

    r267644 r268812  
    44PASS Audit report
    55PASS > [test] Basic ScriptProcessorNode properties
    6 PASS   createScriptProcessor(512, 0, 0) threw NotSupportedError: "The operation is not supported.".
     6PASS   createScriptProcessor(512, 0, 0) threw NotSupportedError: "numberOfInputChannels and numberOfOutputChannels cannot both be 0".
    77PASS   context.createScriptProcessor(512, 1, 0) did not throw an exception.
    88PASS   context.createScriptProcessor(512, 2, 0) did not throw an exception.
    99PASS   context.createScriptProcessor(512, 0, 1) did not throw an exception.
    1010PASS   context.createScriptProcessor(512, 0, 2) did not throw an exception.
    11 PASS   context.createScriptProcessor(511, 1, 1) threw IndexSizeError: "The index is not in the allowed range.".
     11PASS   context.createScriptProcessor(511, 1, 1) threw IndexSizeError: "Unsupported buffer size for ScriptProcessorNode".
    1212PASS   context.createScriptProcessor(256, 1, 1) did not throw an exception.
    1313PASS   context.createScriptProcessor(512, 1, 1) did not throw an exception.
  • trunk/LayoutTests/webaudio/convolver-channels-expected.txt

    r219663 r268812  
    88PASS function () {
    99                convolver.buffer = buffer;
    10             } threw exception NotSupportedError: The operation is not supported..
     10            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
    1111PASS ConvolverNode with buffer of 4 channels did not throw exception.
    1212PASS function () {
    1313                convolver.buffer = buffer;
    14             } threw exception NotSupportedError: The operation is not supported..
     14            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
    1515PASS function () {
    1616                convolver.buffer = buffer;
    17             } threw exception NotSupportedError: The operation is not supported..
     17            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
    1818PASS function () {
    1919                convolver.buffer = buffer;
    20             } threw exception NotSupportedError: The operation is not supported..
     20            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
    2121PASS function () {
    2222                convolver.buffer = buffer;
    23             } threw exception NotSupportedError: The operation is not supported..
     23            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
    2424PASS function () {
    2525                convolver.buffer = buffer;
    26             } threw exception NotSupportedError: The operation is not supported..
     26            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
    2727PASS function () {
    2828                convolver.buffer = buffer;
    29             } threw exception NotSupportedError: The operation is not supported..
     29            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
    3030PASS function () {
    3131                convolver.buffer = buffer;
    32             } threw exception NotSupportedError: The operation is not supported..
     32            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
    3333PASS function () {
    3434                convolver.buffer = buffer;
    35             } threw exception NotSupportedError: The operation is not supported..
     35            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
    3636PASS function () {
    3737                convolver.buffer = buffer;
    38             } threw exception NotSupportedError: The operation is not supported..
     38            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
    3939PASS function () {
    4040                convolver.buffer = buffer;
    41             } threw exception NotSupportedError: The operation is not supported..
     41            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
    4242PASS function () {
    4343                convolver.buffer = buffer;
    44             } threw exception NotSupportedError: The operation is not supported..
     44            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
    4545PASS function () {
    4646                convolver.buffer = buffer;
    47             } threw exception NotSupportedError: The operation is not supported..
     47            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
    4848PASS function () {
    4949                convolver.buffer = buffer;
    50             } threw exception NotSupportedError: The operation is not supported..
     50            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
    5151PASS function () {
    5252                convolver.buffer = buffer;
    53             } threw exception NotSupportedError: The operation is not supported..
     53            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
    5454PASS function () {
    5555                convolver.buffer = buffer;
    56             } threw exception NotSupportedError: The operation is not supported..
     56            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
    5757PASS function () {
    5858                convolver.buffer = buffer;
    59             } threw exception NotSupportedError: The operation is not supported..
     59            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
    6060PASS function () {
    6161                convolver.buffer = buffer;
    62             } threw exception NotSupportedError: The operation is not supported..
     62            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
    6363PASS function () {
    6464                convolver.buffer = buffer;
    65             } threw exception NotSupportedError: The operation is not supported..
     65            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
    6666PASS function () {
    6767                convolver.buffer = buffer;
    68             } threw exception NotSupportedError: The operation is not supported..
     68            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
    6969PASS function () {
    7070                convolver.buffer = buffer;
    71             } threw exception NotSupportedError: The operation is not supported..
     71            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
    7272PASS function () {
    7373                convolver.buffer = buffer;
    74             } threw exception NotSupportedError: The operation is not supported..
     74            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
    7575PASS function () {
    7676                convolver.buffer = buffer;
    77             } threw exception NotSupportedError: The operation is not supported..
     77            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
    7878PASS function () {
    7979                convolver.buffer = buffer;
    80             } threw exception NotSupportedError: The operation is not supported..
     80            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
    8181PASS function () {
    8282                convolver.buffer = buffer;
    83             } threw exception NotSupportedError: The operation is not supported..
     83            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
    8484PASS function () {
    8585                convolver.buffer = buffer;
    86             } threw exception NotSupportedError: The operation is not supported..
     86            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
    8787PASS function () {
    8888                convolver.buffer = buffer;
    89             } threw exception NotSupportedError: The operation is not supported..
     89            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
    9090PASS function () {
    9191                convolver.buffer = buffer;
    92             } threw exception NotSupportedError: The operation is not supported..
     92            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
    9393PASS function () {
    9494                convolver.buffer = buffer;
    95             } threw exception NotSupportedError: The operation is not supported..
     95            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
    9696PASS successfullyParsed is true
    9797
  • trunk/LayoutTests/webaudio/convolver-setBuffer-different-samplerate-expected.txt

    r219663 r268812  
    44
    55
    6 PASS convolver.buffer = context.createBuffer(1, 256, 22050) threw exception NotSupportedError: The operation is not supported..
     6PASS convolver.buffer = context.createBuffer(1, 256, 22050) threw exception NotSupportedError: Buffer sample rate does not match the context's sample rate.
    77PASS convolver.buffer = context.createBuffer(1, 256, 44100) did not throw exception.
    88PASS successfullyParsed is true
  • trunk/LayoutTests/webaudio/delaynode-maxdelaylimit-expected.txt

    r219663 r268812  
    33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
    44
    5 PASS context.createDelay(180) threw exception NotSupportedError: The operation is not supported..
    6 PASS context.createDelay(0) threw exception NotSupportedError: The operation is not supported..
    7 PASS context.createDelay(-1) threw exception NotSupportedError: The operation is not supported..
     5PASS context.createDelay(180) threw exception NotSupportedError: maxDelayTime should be less than 180.
     6PASS context.createDelay(0) threw exception NotSupportedError: maxDelayTime should be a positive value.
     7PASS context.createDelay(-1) threw exception NotSupportedError: maxDelayTime should be a positive value.
    88PASS delay.delayTime.value === 0.5 is true
    99PASS Test signal was correctly delayed by 0.5 sec.
  • trunk/LayoutTests/webaudio/dom-exceptions-expected.txt

    r267644 r268812  
    5050PASS < [createMediaStreamSource] All assertions passed. (total 1 assertions)
    5151PASS > [createScriptProcessor]
    52 PASS   context.createScriptProcessor(1, 1, 1) threw IndexSizeError: "The index is not in the allowed range.".
    53 PASS   context.createScriptProcessor(4096, 100, 1) threw NotSupportedError: "The operation is not supported.".
    54 PASS   context.createScriptProcessor(4096, 1, 100) threw NotSupportedError: "The operation is not supported.".
     52PASS   context.createScriptProcessor(1, 1, 1) threw IndexSizeError: "Unsupported buffer size for ScriptProcessorNode".
     53PASS   context.createScriptProcessor(4096, 100, 1) threw NotSupportedError: "numberOfInputChannels exceeds maximum number of channels".
     54PASS   context.createScriptProcessor(4096, 1, 100) threw NotSupportedError: "numberOfOutputChannels exceeds maximum number of channels".
    5555PASS   context.createScriptProcessor() did not throw an exception.
    5656PASS   context.createScriptProcessor(0) did not throw an exception.
     
    223223PASS   conv = oc.createConvolver() did not throw an exception.
    224224PASS   conv.buffer = {} threw TypeError: "The ConvolverNode.buffer attribute must be an instance of AudioBuffer".
    225 PASS   conv.buffer = oc.createBuffer(1, 100, 22050) threw NotSupportedError: "The operation is not supported.".
     225PASS   conv.buffer = oc.createBuffer(1, 100, 22050) threw NotSupportedError: "Buffer sample rate does not match the context's sample rate".
    226226PASS   conv.buffer is equal to null.
    227227PASS < [convolver] All assertions passed. (total 5 assertions)
  • trunk/Source/WebCore/ChangeLog

    r268809 r268812  
     12020-10-21  Chris Dumez  <cdumez@apple.com>
     2
     3        Make sure WebAudio API throws exceptions with useful error messages
     4        https://bugs.webkit.org/show_bug.cgi?id=218033
     5
     6        Reviewed by Darin Adler.
     7
     8        Make sure WebAudio API throws exceptions with useful error messages to be
     9        more developer friendly.
     10
     11        No new tests, rebaselined existing tests.
     12
     13        * Modules/webaudio/AudioContext.cpp:
     14        (WebCore::AudioContext::create):
     15        * Modules/webaudio/AudioScheduledSourceNode.cpp:
     16        (WebCore::AudioScheduledSourceNode::startLater):
     17        * Modules/webaudio/AudioWorkletGlobalScope.cpp:
     18        (WebCore::AudioWorkletGlobalScope::registerProcessor):
     19        * Modules/webaudio/BaseAudioContext.cpp:
     20        (WebCore::BaseAudioContext::createScriptProcessor):
     21        (WebCore::BaseAudioContext::finishedRendering):
     22        * Modules/webaudio/ConvolverNode.cpp:
     23        (WebCore::ConvolverNode::setBuffer):
     24        * Modules/webaudio/DefaultAudioDestinationNode.cpp:
     25        (WebCore::DefaultAudioDestinationNode::startRendering):
     26        * Modules/webaudio/DelayNode.cpp:
     27        (WebCore::DelayNode::create):
     28        * Modules/webaudio/OfflineAudioContext.cpp:
     29        (WebCore::OfflineAudioContext::create):
     30        * Modules/webaudio/OfflineAudioDestinationNode.cpp:
     31        (WebCore::OfflineAudioDestinationNode::startRendering):
     32
    1332020-10-21  Antoine Quint  <graouts@webkit.org>
    234
  • trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp

    r268728 r268812  
    8787#if OS(WINDOWS)
    8888    if (s_hardwareContextCount >= maxHardwareContexts)
    89         return Exception { QuotaExceededError };
     89        return Exception { QuotaExceededError, "Reached maximum number of hardware contexts on this platform"_s };
    9090#endif
    9191   
  • trunk/Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.cpp

    r268728 r268812  
    154154
    155155    if (m_playbackState != UNSCHEDULED_STATE)
    156         return Exception { InvalidStateError };
     156        return Exception { InvalidStateError, "Cannot call start() more than once"_s };
    157157
    158158    if (!std::isfinite(when) || when < 0)
  • trunk/Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.cpp

    r268517 r268812  
    7777
    7878    auto prototype = jsConstructor->getPrototype(vm, globalObject);
    79     RETURN_IF_EXCEPTION(scope, Exception { TypeError });
     79    RETURN_IF_EXCEPTION(scope, Exception { ExistingExceptionError });
    8080
    8181    if (!prototype.isObject())
     
    8383
    8484    auto parameterDescriptorsValue = jsConstructor->get(globalObject, JSC::Identifier::fromString(vm, "parameterDescriptors"));
    85     RETURN_IF_EXCEPTION(scope, Exception { TypeError });
     85    RETURN_IF_EXCEPTION(scope, Exception { ExistingExceptionError });
    8686
    8787    Vector<AudioParamDescriptor> parameterDescriptors;
    8888    if (!parameterDescriptorsValue.isUndefined()) {
    8989        parameterDescriptors = convert<IDLSequence<IDLDictionary<AudioParamDescriptor>>>(*globalObject, parameterDescriptorsValue);
    90         RETURN_IF_EXCEPTION(scope, Exception { TypeError });
     90        RETURN_IF_EXCEPTION(scope, Exception { ExistingExceptionError });
    9191        UNUSED_PARAM(parameterDescriptors);
    9292        HashSet<String> paramNames;
  • trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.cpp

    r268728 r268812  
    415415        break;
    416416    default:
    417         return Exception { IndexSizeError };
     417        return Exception { IndexSizeError, "Unsupported buffer size for ScriptProcessorNode"_s };
    418418    }
    419419
     
    423423
    424424    if (!numberOfInputChannels && !numberOfOutputChannels)
    425         return Exception { NotSupportedError };
     425        return Exception { NotSupportedError, "numberOfInputChannels and numberOfOutputChannels cannot both be 0"_s };
    426426
    427427    // This parameter [numberOfInputChannels] determines the number of channels for this node's input. Values of
     
    429429
    430430    if (numberOfInputChannels > maxNumberOfChannels())
    431         return Exception { NotSupportedError };
     431        return Exception { NotSupportedError, "numberOfInputChannels exceeds maximum number of channels"_s };
    432432
    433433    // This parameter [numberOfOutputChannels] determines the number of channels for this node's output. Values of
     
    435435
    436436    if (numberOfOutputChannels > maxNumberOfChannels())
    437         return Exception { NotSupportedError };
     437        return Exception { NotSupportedError, "numberOfOutputChannels exceeds maximum number of channels"_s };
    438438
    439439    return ScriptProcessorNode::create(*this, bufferSize, numberOfInputChannels, numberOfOutputChannels);
     
    926926    ASSERT(isMainThread());
    927927    auto finishedRenderingScope = WTF::makeScopeExit([this] {
    928         didFinishOfflineRendering(Exception { InvalidStateError });
     928        didFinishOfflineRendering(Exception { InvalidStateError, "Offline rendering failed"_s });
    929929    });
    930930
  • trunk/Source/WebCore/Modules/webaudio/ConvolverNode.cpp

    r268001 r268812  
    119119
    120120    if (buffer->sampleRate() != context().sampleRate())
    121         return Exception { NotSupportedError };
     121        return Exception { NotSupportedError, "Buffer sample rate does not match the context's sample rate"_s };
    122122
    123123    unsigned numberOfChannels = buffer->numberOfChannels();
     
    126126    // The current implementation supports only 1-, 2-, or 4-channel impulse responses, with the
    127127    // 4-channel response being interpreted as true-stereo (see Reverb class).
    128     bool isChannelCountGood = (numberOfChannels == 1 || numberOfChannels == 2 || numberOfChannels == 4) && bufferLength;
     128    bool isChannelCountGood = (numberOfChannels == 1 || numberOfChannels == 2 || numberOfChannels == 4);
    129129
    130130    if (!isChannelCountGood)
    131         return Exception { NotSupportedError };
     131        return Exception { NotSupportedError, "Buffer should have 1, 2 or 4 channels"_s };
     132
     133    if (!bufferLength)
     134        return Exception { NotSupportedError, "Buffer length cannot be 0"_s };
    132135
    133136    // Wrap the AudioBuffer by an AudioBus. It's an efficient pointer set and not a memcpy().
  • trunk/Source/WebCore/Modules/webaudio/DefaultAudioDestinationNode.cpp

    r267859 r268812  
    124124    ASSERT(isInitialized());
    125125    if (!isInitialized())
    126         return Exception { InvalidStateError };
     126        return Exception { InvalidStateError, "AudioDestinationNode is not initialized"_s };
    127127
    128128    m_destination->start(dispatchToRenderThreadFunction());
  • trunk/Source/WebCore/Modules/webaudio/DelayNode.cpp

    r267639 r268812  
    5050ExceptionOr<Ref<DelayNode>> DelayNode::create(BaseAudioContext& context, const DelayOptions& options)
    5151{
    52     if (options.maxDelayTime <= 0 || options.maxDelayTime >= maximumAllowedDelayTime)
    53         return Exception { NotSupportedError };
     52    if (options.maxDelayTime <= 0)
     53        return Exception { NotSupportedError, "maxDelayTime should be a positive value"_s };
     54
     55    if (options.maxDelayTime >= maximumAllowedDelayTime)
     56        return Exception { NotSupportedError, makeString("maxDelayTime should be less than ", maximumAllowedDelayTime) };
    5457
    5558    auto delayNode = adoptRef(*new DelayNode(context, options.maxDelayTime));
  • trunk/Source/WebCore/Modules/webaudio/OfflineAudioContext.cpp

    r268600 r268812  
    4646ExceptionOr<Ref<OfflineAudioContext>> OfflineAudioContext::create(ScriptExecutionContext& context, unsigned numberOfChannels, size_t length, float sampleRate)
    4747{
    48     // FIXME: Add support for workers.
    4948    if (!is<Document>(context))
    50         return Exception { NotSupportedError };
     49        return Exception { NotSupportedError, "OfflineAudioContext is only supported in Document contexts"_s };
    5150    if (!numberOfChannels || numberOfChannels > maxNumberOfChannels())
    5251        return Exception { SyntaxError, "Number of channels is not in range"_s };
  • trunk/Source/WebCore/Modules/webaudio/OfflineAudioDestinationNode.cpp

    r267859 r268812  
    9292    ASSERT(m_renderTarget.get());
    9393    if (!m_renderTarget.get())
    94         return Exception { InvalidStateError };
     94        return Exception { InvalidStateError, "OfflineAudioContextNode has no rendering buffer"_s };
    9595   
    9696    if (m_startedRendering)
Note: See TracChangeset for help on using the changeset viewer.