Diff
Modified: trunk/LayoutTests/ChangeLog (207671 => 207672)
--- trunk/LayoutTests/ChangeLog 2016-10-21 16:02:39 UTC (rev 207671)
+++ trunk/LayoutTests/ChangeLog 2016-10-21 16:09:28 UTC (rev 207672)
@@ -1,3 +1,15 @@
+2016-10-21 Chris Dumez <cdu...@apple.com>
+
+ AudioNode.connect(): First parameter should not be nullable
+ https://bugs.webkit.org/show_bug.cgi?id=163773
+
+ Reviewed by Darin Adler.
+
+ Improve test coverage.
+
+ * webaudio/audionode-expected.txt:
+ * webaudio/audionode.html:
+
2016-10-21 Wenson Hsieh <wenson_hs...@apple.com>
Implement InputEvent.getTargetRanges() for the input events spec
Modified: trunk/LayoutTests/webaudio/audionode-expected.txt (207671 => 207672)
--- trunk/LayoutTests/webaudio/audionode-expected.txt 2016-10-21 16:02:39 UTC (rev 207671)
+++ trunk/LayoutTests/webaudio/audionode-expected.txt 2016-10-21 16:09:28 UTC (rev 207672)
@@ -6,7 +6,8 @@
PASS Source AudioNode has one output.
PASS Destination AudioNode has one input.
PASS Destination AudioNode has no outputs.
-PASS connect() exception thrown for illegal destination AudioNode.
+PASS audioNode.connect(0, 0, 0) threw exception TypeError: Argument 1 ('destination') to AudioNode.connect must be an instance of AudioNode.
+PASS audioNode.connect(null, 0, 0) threw exception TypeError: Argument 1 ('destination') to AudioNode.connect must be an instance of AudioNode.
PASS connect() exception thrown for illegal output index.
PASS connect() exception thrown for illegal input index.
PASS audioNode.connect(context.destination) succeeded.
Modified: trunk/LayoutTests/webaudio/audionode.html (207671 => 207672)
--- trunk/LayoutTests/webaudio/audionode.html 2016-10-21 16:02:39 UTC (rev 207671)
+++ trunk/LayoutTests/webaudio/audionode.html 2016-10-21 16:09:28 UTC (rev 207672)
@@ -51,12 +51,8 @@
// Try calling connect() method with illegal values.
- try {
- audioNode.connect(0, 0, 0);
- testFailed("connect() exception should be thrown for illegal destination AudioNode.");
- } catch(e) {
- testPassed("connect() exception thrown for illegal destination AudioNode.");
- }
+ shouldThrowErrorName("audioNode.connect(0, 0, 0)", "TypeError");
+ shouldThrowErrorName("audioNode.connect(null, 0, 0)", "TypeError");
try {
audioNode.connect(context.destination, 5, 0);
Modified: trunk/Source/WebCore/ChangeLog (207671 => 207672)
--- trunk/Source/WebCore/ChangeLog 2016-10-21 16:02:39 UTC (rev 207671)
+++ trunk/Source/WebCore/ChangeLog 2016-10-21 16:09:28 UTC (rev 207672)
@@ -1,3 +1,26 @@
+2016-10-21 Chris Dumez <cdu...@apple.com>
+
+ AudioNode.connect(): First parameter should not be nullable
+ https://bugs.webkit.org/show_bug.cgi?id=163773
+
+ Reviewed by Darin Adler.
+
+ AudioNode.connect()'s first parameter should not be nullable:
+ - https://webaudio.github.io/web-audio-api/#idl-def-AudioNode.
+
+ 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:
+
2016-10-21 Wenson Hsieh <wenson_hs...@apple.com>
Implement InputEvent.getTargetRanges() for the input events spec
Modified: trunk/Source/WebCore/Modules/webaudio/AudioBasicInspectorNode.cpp (207671 => 207672)
--- trunk/Source/WebCore/Modules/webaudio/AudioBasicInspectorNode.cpp 2016-10-21 16:02:39 UTC (rev 207671)
+++ trunk/Source/WebCore/Modules/webaudio/AudioBasicInspectorNode.cpp 2016-10-21 16:09:28 UTC (rev 207672)
@@ -49,7 +49,7 @@
input(0)->pull(output(0)->bus(), framesToProcess);
}
-ExceptionOr<void> AudioBasicInspectorNode::connect(AudioNode* destination, unsigned outputIndex, unsigned inputIndex)
+ExceptionOr<void> AudioBasicInspectorNode::connect(AudioNode& destination, unsigned outputIndex, unsigned inputIndex)
{
ASSERT(isMainThread());
Modified: trunk/Source/WebCore/Modules/webaudio/AudioBasicInspectorNode.h (207671 => 207672)
--- trunk/Source/WebCore/Modules/webaudio/AudioBasicInspectorNode.h 2016-10-21 16:02:39 UTC (rev 207671)
+++ trunk/Source/WebCore/Modules/webaudio/AudioBasicInspectorNode.h 2016-10-21 16:09:28 UTC (rev 207672)
@@ -37,7 +37,7 @@
private:
void pullInputs(size_t framesToProcess) override;
- ExceptionOr<void> connect(AudioNode*, unsigned outputIndex, unsigned inputIndex) override;
+ ExceptionOr<void> connect(AudioNode&, unsigned outputIndex, unsigned inputIndex) override;
ExceptionOr<void> disconnect(unsigned outputIndex) override;
void checkNumberOfChannelsForInput(AudioNodeInput*) override;
Modified: trunk/Source/WebCore/Modules/webaudio/AudioNode.cpp (207671 => 207672)
--- trunk/Source/WebCore/Modules/webaudio/AudioNode.cpp 2016-10-21 16:02:39 UTC (rev 207671)
+++ trunk/Source/WebCore/Modules/webaudio/AudioNode.cpp 2016-10-21 16:09:28 UTC (rev 207672)
@@ -123,25 +123,22 @@
return nullptr;
}
-ExceptionOr<void> AudioNode::connect(AudioNode* destination, unsigned outputIndex, unsigned inputIndex)
+ExceptionOr<void> AudioNode::connect(AudioNode& destination, unsigned outputIndex, unsigned inputIndex)
{
ASSERT(isMainThread());
AudioContext::AutoLocker locker(context());
- if (!destination)
- return Exception { SYNTAX_ERR };
-
// Sanity check input and output indices.
if (outputIndex >= numberOfOutputs())
return Exception { INDEX_SIZE_ERR };
- if (destination && inputIndex >= destination->numberOfInputs())
+ if (inputIndex >= destination.numberOfInputs())
return Exception { INDEX_SIZE_ERR };
- if (context() != destination->context())
+ if (context() != destination.context())
return Exception { SYNTAX_ERR };
- auto* input = destination->input(inputIndex);
+ auto* input = destination.input(inputIndex);
auto* output = this->output(outputIndex);
input->connect(output);
@@ -151,22 +148,19 @@
return { };
}
-ExceptionOr<void> AudioNode::connect(AudioParam* param, unsigned outputIndex)
+ExceptionOr<void> AudioNode::connect(AudioParam& param, unsigned outputIndex)
{
ASSERT(isMainThread());
AudioContext::AutoLocker locker(context());
- if (!param)
- return Exception { SYNTAX_ERR };
-
if (outputIndex >= numberOfOutputs())
return Exception { INDEX_SIZE_ERR };
- if (context() != param->context())
+ if (context() != param.context())
return Exception { SYNTAX_ERR };
auto* output = this->output(outputIndex);
- param->connect(output);
+ param.connect(output);
return { };
}
Modified: trunk/Source/WebCore/Modules/webaudio/AudioNode.h (207671 => 207672)
--- trunk/Source/WebCore/Modules/webaudio/AudioNode.h 2016-10-21 16:02:39 UTC (rev 207671)
+++ trunk/Source/WebCore/Modules/webaudio/AudioNode.h 2016-10-21 16:09:28 UTC (rev 207672)
@@ -121,8 +121,8 @@
AudioNodeOutput* output(unsigned);
// Called from main thread by corresponding _javascript_ methods.
- virtual ExceptionOr<void> connect(AudioNode*, unsigned outputIndex, unsigned inputIndex);
- ExceptionOr<void> connect(AudioParam*, unsigned outputIndex);
+ virtual ExceptionOr<void> connect(AudioNode&, unsigned outputIndex, unsigned inputIndex);
+ ExceptionOr<void> connect(AudioParam&, unsigned outputIndex);
virtual ExceptionOr<void> disconnect(unsigned outputIndex);
virtual float sampleRate() const { return m_sampleRate; }
Modified: trunk/Source/WebCore/Modules/webaudio/AudioNode.idl (207671 => 207672)
--- trunk/Source/WebCore/Modules/webaudio/AudioNode.idl 2016-10-21 16:02:39 UTC (rev 207671)
+++ trunk/Source/WebCore/Modules/webaudio/AudioNode.idl 2016-10-21 16:09:28 UTC (rev 207672)
@@ -34,7 +34,7 @@
[SetterMayThrowException] attribute DOMString channelCountMode;
[SetterMayThrowException] attribute DOMString channelInterpretation;
- [MayThrowException] void connect(AudioNode? destination, optional unsigned long output = 0, optional unsigned long input = 0);
- [MayThrowException] void connect(AudioParam? destination, optional unsigned long output = 0);
+ [MayThrowException] void connect(AudioNode destination, optional unsigned long output = 0, optional unsigned long input = 0);
+ [MayThrowException] void connect(AudioParam destination, optional unsigned long output = 0);
[MayThrowException] void disconnect(optional unsigned long output = 0);
};