Changeset 207672 in webkit


Ignore:
Timestamp:
Oct 21, 2016 9:09:28 AM (7 years ago)
Author:
Chris Dumez
Message:

AudioNode.connect(): First parameter should not be nullable
https://bugs.webkit.org/show_bug.cgi?id=163773

Reviewed by Darin Adler.

Source/WebCore:

AudioNode.connect()'s first parameter should not be nullable:

We were throwing a SYNTAX_ERR when passing null, we now throw
a TypeError instead.

No new tests, updated existing test.

  • Modules/webaudio/AudioBasicInspectorNode.cpp:

(WebCore::AudioBasicInspectorNode::connect):

  • Modules/webaudio/AudioBasicInspectorNode.h:
  • Modules/webaudio/AudioNode.cpp:

(WebCore::AudioNode::connect):

  • Modules/webaudio/AudioNode.h:
  • Modules/webaudio/AudioNode.idl:

LayoutTests:

Improve test coverage.

  • webaudio/audionode-expected.txt:
  • webaudio/audionode.html:
Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r207670 r207672  
     12016-10-21  Chris Dumez  <cdumez@apple.com>
     2
     3        AudioNode.connect(): First parameter should not be nullable
     4        https://bugs.webkit.org/show_bug.cgi?id=163773
     5
     6        Reviewed by Darin Adler.
     7
     8        Improve test coverage.
     9
     10        * webaudio/audionode-expected.txt:
     11        * webaudio/audionode.html:
     12
    1132016-10-21  Wenson Hsieh  <wenson_hsieh@apple.com>
    214
  • trunk/LayoutTests/webaudio/audionode-expected.txt

    r205088 r207672  
    77PASS Destination AudioNode has one input.
    88PASS Destination AudioNode has no outputs.
    9 PASS connect() exception thrown for illegal destination AudioNode.
     9PASS audioNode.connect(0, 0, 0) threw exception TypeError: Argument 1 ('destination') to AudioNode.connect must be an instance of AudioNode.
     10PASS audioNode.connect(null, 0, 0) threw exception TypeError: Argument 1 ('destination') to AudioNode.connect must be an instance of AudioNode.
    1011PASS connect() exception thrown for illegal output index.
    1112PASS connect() exception thrown for illegal input index.
  • trunk/LayoutTests/webaudio/audionode.html

    r205088 r207672  
    5252    // Try calling connect() method with illegal values.
    5353
    54     try {
    55         audioNode.connect(0, 0, 0);
    56         testFailed("connect() exception should be thrown for illegal destination AudioNode.");
    57     } catch(e) {
    58         testPassed("connect() exception thrown for illegal destination AudioNode.");
    59     }
     54    shouldThrowErrorName("audioNode.connect(0, 0, 0)", "TypeError");
     55    shouldThrowErrorName("audioNode.connect(null, 0, 0)", "TypeError");
    6056
    6157    try {
  • trunk/Source/WebCore/ChangeLog

    r207670 r207672  
     12016-10-21  Chris Dumez  <cdumez@apple.com>
     2
     3        AudioNode.connect(): First parameter should not be nullable
     4        https://bugs.webkit.org/show_bug.cgi?id=163773
     5
     6        Reviewed by Darin Adler.
     7
     8        AudioNode.connect()'s first parameter should not be nullable:
     9        - https://webaudio.github.io/web-audio-api/#idl-def-AudioNode.
     10
     11        We were throwing a SYNTAX_ERR when passing null, we now throw
     12        a TypeError instead.
     13
     14        No new tests, updated existing test.
     15
     16        * Modules/webaudio/AudioBasicInspectorNode.cpp:
     17        (WebCore::AudioBasicInspectorNode::connect):
     18        * Modules/webaudio/AudioBasicInspectorNode.h:
     19        * Modules/webaudio/AudioNode.cpp:
     20        (WebCore::AudioNode::connect):
     21        * Modules/webaudio/AudioNode.h:
     22        * Modules/webaudio/AudioNode.idl:
     23
    1242016-10-21  Wenson Hsieh  <wenson_hsieh@apple.com>
    225
  • trunk/Source/WebCore/Modules/webaudio/AudioBasicInspectorNode.cpp

    r207050 r207672  
    5050}
    5151
    52 ExceptionOr<void> AudioBasicInspectorNode::connect(AudioNode* destination, unsigned outputIndex, unsigned inputIndex)
     52ExceptionOr<void> AudioBasicInspectorNode::connect(AudioNode& destination, unsigned outputIndex, unsigned inputIndex)
    5353{
    5454    ASSERT(isMainThread());
  • trunk/Source/WebCore/Modules/webaudio/AudioBasicInspectorNode.h

    r207050 r207672  
    3838private:
    3939    void pullInputs(size_t framesToProcess) override;
    40     ExceptionOr<void> connect(AudioNode*, unsigned outputIndex, unsigned inputIndex) override;
     40    ExceptionOr<void> connect(AudioNode&, unsigned outputIndex, unsigned inputIndex) override;
    4141    ExceptionOr<void> disconnect(unsigned outputIndex) override;
    4242    void checkNumberOfChannelsForInput(AudioNodeInput*) override;
  • trunk/Source/WebCore/Modules/webaudio/AudioNode.cpp

    r207050 r207672  
    124124}
    125125
    126 ExceptionOr<void> AudioNode::connect(AudioNode* destination, unsigned outputIndex, unsigned inputIndex)
     126ExceptionOr<void> AudioNode::connect(AudioNode& destination, unsigned outputIndex, unsigned inputIndex)
    127127{
    128128    ASSERT(isMainThread());
    129129    AudioContext::AutoLocker locker(context());
    130 
    131     if (!destination)
    132         return Exception { SYNTAX_ERR };
    133130
    134131    // Sanity check input and output indices.
     
    136133        return Exception { INDEX_SIZE_ERR };
    137134
    138     if (destination && inputIndex >= destination->numberOfInputs())
     135    if (inputIndex >= destination.numberOfInputs())
    139136        return Exception { INDEX_SIZE_ERR };
    140137
    141     if (context() != destination->context())
     138    if (context() != destination.context())
    142139        return Exception { SYNTAX_ERR };
    143140
    144     auto* input = destination->input(inputIndex);
     141    auto* input = destination.input(inputIndex);
    145142    auto* output = this->output(outputIndex);
    146143    input->connect(output);
     
    152149}
    153150
    154 ExceptionOr<void> AudioNode::connect(AudioParam* param, unsigned outputIndex)
     151ExceptionOr<void> AudioNode::connect(AudioParam& param, unsigned outputIndex)
    155152{
    156153    ASSERT(isMainThread());
    157154    AudioContext::AutoLocker locker(context());
    158155
    159     if (!param)
    160         return Exception { SYNTAX_ERR };
    161 
    162156    if (outputIndex >= numberOfOutputs())
    163157        return Exception { INDEX_SIZE_ERR };
    164158
    165     if (context() != param->context())
     159    if (context() != param.context())
    166160        return Exception { SYNTAX_ERR };
    167161
    168162    auto* output = this->output(outputIndex);
    169     param->connect(output);
     163    param.connect(output);
    170164
    171165    return { };
  • trunk/Source/WebCore/Modules/webaudio/AudioNode.h

    r207050 r207672  
    122122
    123123    // Called from main thread by corresponding JavaScript methods.
    124     virtual ExceptionOr<void> connect(AudioNode*, unsigned outputIndex, unsigned inputIndex);
    125     ExceptionOr<void> connect(AudioParam*, unsigned outputIndex);
     124    virtual ExceptionOr<void> connect(AudioNode&, unsigned outputIndex, unsigned inputIndex);
     125    ExceptionOr<void> connect(AudioParam&, unsigned outputIndex);
    126126    virtual ExceptionOr<void> disconnect(unsigned outputIndex);
    127127
  • trunk/Source/WebCore/Modules/webaudio/AudioNode.idl

    r207050 r207672  
    3535    [SetterMayThrowException] attribute DOMString channelInterpretation;
    3636
    37     [MayThrowException] void connect(AudioNode? destination, optional unsigned long output = 0, optional unsigned long input = 0);
    38     [MayThrowException] void connect(AudioParam? destination, optional unsigned long output = 0);
     37    [MayThrowException] void connect(AudioNode destination, optional unsigned long output = 0, optional unsigned long input = 0);
     38    [MayThrowException] void connect(AudioParam destination, optional unsigned long output = 0);
    3939    [MayThrowException] void disconnect(optional unsigned long output = 0);
    4040};
Note: See TracChangeset for help on using the changeset viewer.