Title: [267376] trunk
Revision
267376
Author
[email protected]
Date
2020-09-21 15:50:47 -0700 (Mon, 21 Sep 2020)

Log Message

Throw when AudioConnect::connect() is called for an output that has no channels
https://bugs.webkit.org/show_bug.cgi?id=216802

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Rebaseline existing tests because I improved exception messages.

* web-platform-tests/webaudio/the-audio-api/the-audionode-interface/audionode-connect-method-chaining-expected.txt:
* web-platform-tests/webaudio/the-audio-api/the-audionode-interface/audionode-expected.txt:

Source/WebCore:

Throw when AudioConnect::connect() is called for an output that has no channels, for consistency
with Blink. The ScriptProcessorNode cannot have an output node that has zero channels.

No new tests, rebaselined existing tests.

* Modules/webaudio/AudioNode.cpp:
(WebCore::AudioNode::connect):

LayoutTests:

* webaudio/MediaElementAudioSource/mediaelementaudiosourcenode-expected.txt:
* webaudio/dom-exceptions-expected.txt:
Rebaseline existing tests because I improved exception messages.

* webaudio/ScriptProcessor/scriptprocessornode-0-output-channels-expected.txt:
Rebaseline test that is now passing.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (267375 => 267376)


--- trunk/LayoutTests/ChangeLog	2020-09-21 22:29:02 UTC (rev 267375)
+++ trunk/LayoutTests/ChangeLog	2020-09-21 22:50:47 UTC (rev 267376)
@@ -1,3 +1,17 @@
+2020-09-21  Chris Dumez  <[email protected]>
+
+        Throw when AudioConnect::connect() is called for an output that has no channels
+        https://bugs.webkit.org/show_bug.cgi?id=216802
+
+        Reviewed by Darin Adler.
+
+        * webaudio/MediaElementAudioSource/mediaelementaudiosourcenode-expected.txt:
+        * webaudio/dom-exceptions-expected.txt:
+        Rebaseline existing tests because I improved exception messages.
+
+        * webaudio/ScriptProcessor/scriptprocessornode-0-output-channels-expected.txt:
+        Rebaseline test that is now passing.
+
 2020-09-21  Jiewen Tan  <[email protected]>
 
         [WebAuthn] Don't set the UV option if the authenticator doesn't support it

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (267375 => 267376)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-09-21 22:29:02 UTC (rev 267375)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-09-21 22:50:47 UTC (rev 267376)
@@ -1,5 +1,17 @@
 2020-09-21  Chris Dumez  <[email protected]>
 
+        Throw when AudioConnect::connect() is called for an output that has no channels
+        https://bugs.webkit.org/show_bug.cgi?id=216802
+
+        Reviewed by Darin Adler.
+
+        Rebaseline existing tests because I improved exception messages.
+
+        * web-platform-tests/webaudio/the-audio-api/the-audionode-interface/audionode-connect-method-chaining-expected.txt:
+        * web-platform-tests/webaudio/the-audio-api/the-audionode-interface/audionode-expected.txt:
+
+2020-09-21  Chris Dumez  <[email protected]>
+
         Vectorize linearRampToValueAtTime processing in AudioParamTimeline
         https://bugs.webkit.org/show_bug.cgi?id=216788
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audionode-interface/audionode-connect-method-chaining-expected.txt (267375 => 267376)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audionode-interface/audionode-connect-method-chaining-expected.txt	2020-09-21 22:29:02 UTC (rev 267375)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audionode-interface/audionode-connect-method-chaining-expected.txt	2020-09-21 22:50:47 UTC (rev 267376)
@@ -58,8 +58,8 @@
 PASS   The return value of MediaStreamAudioSourceNode.connect(ChannelMergerNode, 0, 1) matches the destination ChannelMergerNode is equal to true. 
 PASS < [media-group] All assertions passed. (total 6 assertions) 
 PASS > [invalid-operation]  
-PASS   Connecting with an invalid output threw IndexSizeError: "The index is not in the allowed range.". 
-PASS   Connecting to a node from the different context threw SyntaxError: "The string did not match the expected pattern.". 
+PASS   Connecting with an invalid output threw IndexSizeError: "Output index exceeds number of outputs". 
+PASS   Connecting to a node from the different context threw SyntaxError: "Source and destination nodes belong to different audio contexts". 
 PASS < [invalid-operation] All assertions passed. (total 2 assertions) 
 PASS > [verification]  
 PASS   The output of chained connection of gain nodes contains only the constant 0.125. 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audionode-interface/audionode-expected.txt (267375 => 267376)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audionode-interface/audionode-expected.txt	2020-09-21 22:29:02 UTC (rev 267375)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-audionode-interface/audionode-expected.txt	2020-09-21 22:50:47 UTC (rev 267376)
@@ -9,10 +9,10 @@
 PASS   AudioContext.destination.numberOfOutputs is equal to 0. 
 PASS   audioNode.connect(0, 0, 0) threw TypeError: "Argument 1 ('destination') to AudioNode.connect must be an instance of AudioNode". 
 PASS   audioNode.connect(null, 0, 0) threw TypeError: "Argument 1 ('destination') to AudioNode.connect must be an instance of AudioNode". 
-PASS   audioNode.connect(context.destination, 5, 0) threw IndexSizeError: "The index is not in the allowed range.". 
-PASS   audioNode.connect(context.destination, 0, 5) threw IndexSizeError: "The index is not in the allowed range.". 
+PASS   audioNode.connect(context.destination, 5, 0) threw IndexSizeError: "Output index exceeds number of outputs". 
+PASS   audioNode.connect(context.destination, 0, 5) threw IndexSizeError: "Input index exceeds number of inputs". 
 PASS   audioNode.connect(context.destination, 0, 0) did not throw an exception. 
-PASS   Connecting a node to a different context threw SyntaxError: "The string did not match the expected pattern.". 
+PASS   Connecting a node to a different context threw SyntaxError: "Source and destination nodes belong to different audio contexts". 
 PASS   context3 = new AudioContext(1, 44100, 44100) threw TypeError: "Type error". 
 PASS   AudioNode is an EventTarget is true. 
 PASS < [test] All assertions passed. (total 12 assertions) 

Modified: trunk/LayoutTests/webaudio/MediaElementAudioSource/mediaelementaudiosourcenode-expected.txt (267375 => 267376)


--- trunk/LayoutTests/webaudio/MediaElementAudioSource/mediaelementaudiosourcenode-expected.txt	2020-09-21 22:29:02 UTC (rev 267375)
+++ trunk/LayoutTests/webaudio/MediaElementAudioSource/mediaelementaudiosourcenode-expected.txt	2020-09-21 22:50:47 UTC (rev 267376)
@@ -6,8 +6,8 @@
 PASS   audioNode.numberOfInputs is equal to 0. 
 PASS   audioNode.numberOfOutputs is equal to 1. 
 PASS   audioNode.connect(0, 0, 0) threw TypeError: "Argument 1 ('destination') to AudioNode.connect must be an instance of AudioNode". 
-PASS   audioNode.connect(context.destination, 5, 0) threw IndexSizeError: "The index is not in the allowed range.". 
-PASS   audioNode.connect(context.destination, 0, 5) threw IndexSizeError: "The index is not in the allowed range.". 
+PASS   audioNode.connect(context.destination, 5, 0) threw IndexSizeError: "Output index exceeds number of outputs". 
+PASS   audioNode.connect(context.destination, 0, 5) threw IndexSizeError: "Input index exceeds number of inputs". 
 PASS   mediaSource.mediaElement instanceof HTMLMediaElement is true. 
 PASS   mediaSource.mediaElement is same object is true. 
 PASS   audioNode.connect(context.destination, 0, 0) did not throw an exception. 

Modified: trunk/LayoutTests/webaudio/ScriptProcessor/scriptprocessornode-0-output-channels-expected.txt (267375 => 267376)


--- trunk/LayoutTests/webaudio/ScriptProcessor/scriptprocessornode-0-output-channels-expected.txt	2020-09-21 22:29:02 UTC (rev 267375)
+++ trunk/LayoutTests/webaudio/ScriptProcessor/scriptprocessornode-0-output-channels-expected.txt	2020-09-21 22:50:47 UTC (rev 267376)
@@ -10,8 +10,8 @@
 PASS   scriptNode2 = context.createScriptProcessor(1024, 1, 1) did not throw an exception. 
 PASS < [initialize] All assertions passed. (total 4 assertions) 
 PASS > [test]  
-FAIL X scriptNode1.connect(analyzer) did not throw an exception. assert_true: expected true got false
+PASS   scriptNode1.connect(analyzer) threw InvalidAccessError: "Node has zero output channels". 
 PASS   scriptNode2.connect(analyzer) did not throw an exception. 
-FAIL < [test] 1 out of 2 assertions were failed. assert_true: expected true got false
-FAIL # AUDIT TASK RUNNER FINISHED: 1 out of 2 tasks were failed. assert_true: expected true got false
+PASS < [test] All assertions passed. (total 2 assertions) 
+PASS # AUDIT TASK RUNNER FINISHED: 2 tasks ran successfully. 
 

Modified: trunk/LayoutTests/webaudio/dom-exceptions-expected.txt (267375 => 267376)


--- trunk/LayoutTests/webaudio/dom-exceptions-expected.txt	2020-09-21 22:29:02 UTC (rev 267375)
+++ trunk/LayoutTests/webaudio/dom-exceptions-expected.txt	2020-09-21 22:50:47 UTC (rev 267376)
@@ -103,11 +103,11 @@
 PASS < [Init test nodes] All assertions passed. (total 2 assertions) 
 PASS > [connections] AudioNode connections 
 PASS   node.connect(null, 0, 0) threw TypeError: "Argument 1 ('destination') to AudioNode.connect must be an instance of AudioNode". 
-PASS   node.connect(context.destination, 100, 0) threw IndexSizeError: "The index is not in the allowed range.". 
-PASS   node.connect(context.destination, 0, 100) threw IndexSizeError: "The index is not in the allowed range.". 
-PASS   node.connect(node2.gain, 100) threw IndexSizeError: "The index is not in the allowed range.". 
+PASS   node.connect(context.destination, 100, 0) threw IndexSizeError: "Output index exceeds number of outputs". 
+PASS   node.connect(context.destination, 0, 100) threw IndexSizeError: "Input index exceeds number of inputs". 
+PASS   node.connect(node2.gain, 100) threw IndexSizeError: "Output index exceeds number of outputs". 
 PASS   node.disconnect(99) threw IndexSizeError: "output index is out of bounds". 
-PASS   node.connect(otherContext.destination) threw SyntaxError: "The string did not match the expected pattern.". 
+PASS   node.connect(otherContext.destination) threw SyntaxError: "Source and destination nodes belong to different audio contexts". 
 PASS < [connections] All assertions passed. (total 6 assertions) 
 PASS > [channel-stuff] channelCount, channelCountMode, channelInterpretation 
 PASS   GainNode.channelCount = 99 threw IndexSizeError: "Channel count exceeds maximum limit". 

Modified: trunk/Source/WebCore/ChangeLog (267375 => 267376)


--- trunk/Source/WebCore/ChangeLog	2020-09-21 22:29:02 UTC (rev 267375)
+++ trunk/Source/WebCore/ChangeLog	2020-09-21 22:50:47 UTC (rev 267376)
@@ -1,3 +1,18 @@
+2020-09-21  Chris Dumez  <[email protected]>
+
+        Throw when AudioConnect::connect() is called for an output that has no channels
+        https://bugs.webkit.org/show_bug.cgi?id=216802
+
+        Reviewed by Darin Adler.
+
+        Throw when AudioConnect::connect() is called for an output that has no channels, for consistency
+        with Blink. The ScriptProcessorNode cannot have an output node that has zero channels.
+
+        No new tests, rebaselined existing tests.
+
+        * Modules/webaudio/AudioNode.cpp:
+        (WebCore::AudioNode::connect):
+
 2020-09-21  Yusuke Suzuki  <[email protected]>
 
         [JSC] BigInt should work with Map / Set

Modified: trunk/Source/WebCore/Modules/webaudio/AudioNode.cpp (267375 => 267376)


--- trunk/Source/WebCore/Modules/webaudio/AudioNode.cpp	2020-09-21 22:29:02 UTC (rev 267375)
+++ trunk/Source/WebCore/Modules/webaudio/AudioNode.cpp	2020-09-21 22:50:47 UTC (rev 267376)
@@ -195,16 +195,20 @@
     
     // Sanity check input and output indices.
     if (outputIndex >= numberOfOutputs())
-        return Exception { IndexSizeError };
+        return Exception { IndexSizeError, "Output index exceeds number of outputs"_s };
 
     if (inputIndex >= destination.numberOfInputs())
-        return Exception { IndexSizeError };
+        return Exception { IndexSizeError, "Input index exceeds number of inputs"_s };
 
     if (&context() != &destination.context())
-        return Exception { SyntaxError };
+        return Exception { SyntaxError, "Source and destination nodes belong to different audio contexts"_s };
 
     auto* input = destination.input(inputIndex);
     auto* output = this->output(outputIndex);
+
+    if (!output->numberOfChannels())
+        return Exception { InvalidAccessError, "Node has zero output channels"_s };
+
     input->connect(output);
 
     // Let context know that a connection has been made.
@@ -224,10 +228,10 @@
     INFO_LOG(LOGIDENTIFIER, param.name(), ", output = ", outputIndex);
 
     if (outputIndex >= numberOfOutputs())
-        return Exception { IndexSizeError };
+        return Exception { IndexSizeError, "Output index exceeds number of outputs"_s };
 
     if (&context() != &param.context())
-        return Exception { SyntaxError };
+        return Exception { SyntaxError, "Node and AudioParam belong to different audio contexts"_s };
 
     auto* output = this->output(outputIndex);
     param.connect(output);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to