Title: [268812] trunk
Revision
268812
Author
[email protected]
Date
2020-10-21 11:38:48 -0700 (Wed, 21 Oct 2020)

Log 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:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (268811 => 268812)


--- trunk/LayoutTests/ChangeLog	2020-10-21 18:33:17 UTC (rev 268811)
+++ trunk/LayoutTests/ChangeLog	2020-10-21 18:38:48 UTC (rev 268812)
@@ -1,3 +1,19 @@
+2020-10-21  Chris Dumez  <[email protected]>
+
+        Make sure WebAudio API throws exceptions with useful error messages
+        https://bugs.webkit.org/show_bug.cgi?id=218033
+
+        Reviewed by Darin Adler.
+
+        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:
+
 2020-10-21  Antoine Quint  <[email protected]>
 
         REGRESSION (r263729): transform transition doesn't restart

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (268811 => 268812)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-10-21 18:33:17 UTC (rev 268811)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-10-21 18:38:48 UTC (rev 268812)
@@ -1,3 +1,17 @@
+2020-10-21  Chris Dumez  <[email protected]>
+
+        Make sure WebAudio API throws exceptions with useful error messages
+        https://bugs.webkit.org/show_bug.cgi?id=218033
+
+        Reviewed by Darin Adler.
+
+        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:
+
 2020-10-20  Sergio Villar Senin  <[email protected]>
 
         [css-flexbox] flex-basis not animatable

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-constantsourcenode-interface/constant-source-basic-expected.txt (268811 => 268812)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-constantsourcenode-interface/constant-source-basic-expected.txt	2020-10-21 18:33:17 UTC (rev 268811)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-constantsourcenode-interface/constant-source-basic-expected.txt	2020-10-21 18:38:48 UTC (rev 268812)
@@ -36,7 +36,7 @@
 PASS   start(-Infinity) threw TypeError: "The provided value is non-finite".
 PASS   Calling stop() before start() threw InvalidStateError: "cannot call stop without calling start first.".
 PASS   start(-1) threw RangeError: "when value should be positive".
-PASS   Calling start() twice threw InvalidStateError: "The object is in an invalid state.".
+PASS   Calling start() twice threw InvalidStateError: "Cannot call start() more than once".
 PASS   stop(-1) threw RangeError: "when value should be positive".
 PASS   stop(NaN) threw TypeError: "The provided value is non-finite".
 PASS   stop(Infinity) threw TypeError: "The provided value is non-finite".

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/convolver-channels-expected.txt (268811 => 268812)


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

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/ctor-convolver-expected.txt (268811 => 268812)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/ctor-convolver-expected.txt	2020-10-21 18:33:17 UTC (rev 268811)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-convolvernode-interface/ctor-convolver-expected.txt	2020-10-21 18:38:48 UTC (rev 268812)
@@ -52,7 +52,7 @@
 PASS   node1.buffer is equal to null.
 PASS < [nullable buffer] All assertions passed. (total 2 assertions)
 PASS > [illegal sample-rate]
-PASS   node1 = new ConvolverNode(c, {"buffer":{}} threw NotSupportedError: "The operation is not supported.".
+PASS   node1 = new ConvolverNode(c, {"buffer":{}} threw NotSupportedError: "Buffer sample rate does not match the context's sample rate".
 PASS < [illegal sample-rate] All assertions passed. (total 1 assertions)
 PASS > [construct with options]
 PASS   node = new ConvolverNode(c, {"buffer":{},"disableNormalization":false}) did not throw an exception.

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-delaynode-interface/delaynode-maxdelaylimit-expected.txt (268811 => 268812)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-delaynode-interface/delaynode-maxdelaylimit-expected.txt	2020-10-21 18:33:17 UTC (rev 268811)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-delaynode-interface/delaynode-maxdelaylimit-expected.txt	2020-10-21 18:38:48 UTC (rev 268812)
@@ -3,9 +3,9 @@
 PASS Executing "test"
 PASS Audit report
 PASS > [test] Tests attribute and maximum allowed delay of DelayNode
-PASS   Setting Delay length to 180 seconds or more threw NotSupportedError: "The operation is not supported.".
-PASS   Setting Delay length to 0 seconds threw NotSupportedError: "The operation is not supported.".
-PASS   Setting Delay length to negative threw NotSupportedError: "The operation is not supported.".
+PASS   Setting Delay length to 180 seconds or more threw NotSupportedError: "maxDelayTime should be less than 180".
+PASS   Setting Delay length to 0 seconds threw NotSupportedError: "maxDelayTime should be a positive value".
+PASS   Setting Delay length to negative threw NotSupportedError: "maxDelayTime should be a positive value".
 PASS   Setting Delay length to NaN threw TypeError: "The provided value is non-finite".
 PASS   delay.delayTime.value = 0.5 is equal to 0.5.
 PASS   Delaying test signal by 0.5 sec was done correctly

Modified: trunk/LayoutTests/webaudio/Oscillator/oscillator-basic-expected.txt (268811 => 268812)


--- trunk/LayoutTests/webaudio/Oscillator/oscillator-basic-expected.txt	2020-10-21 18:33:17 UTC (rev 268811)
+++ trunk/LayoutTests/webaudio/Oscillator/oscillator-basic-expected.txt	2020-10-21 18:38:48 UTC (rev 268812)
@@ -20,7 +20,7 @@
 PASS   start(-Infinity) threw TypeError: "The provided value is non-finite".
 PASS   Calling stop() before start() threw InvalidStateError: "cannot call stop without calling start first.".
 PASS   start(-1) threw RangeError: "when value should be positive".
-PASS   Calling start() twice threw InvalidStateError: "The object is in an invalid state.".
+PASS   Calling start() twice threw InvalidStateError: "Cannot call start() more than once".
 PASS   stop(-1) threw RangeError: "when value should be positive".
 PASS   stop(NaN) threw TypeError: "The provided value is non-finite".
 PASS   stop(Infinity) threw TypeError: "The provided value is non-finite".

Modified: trunk/LayoutTests/webaudio/ScriptProcessor/scriptprocessornode-expected.txt (268811 => 268812)


--- trunk/LayoutTests/webaudio/ScriptProcessor/scriptprocessornode-expected.txt	2020-10-21 18:33:17 UTC (rev 268811)
+++ trunk/LayoutTests/webaudio/ScriptProcessor/scriptprocessornode-expected.txt	2020-10-21 18:38:48 UTC (rev 268812)
@@ -3,12 +3,12 @@
 PASS Executing "test"
 PASS Audit report
 PASS > [test] Basic ScriptProcessorNode properties
-PASS   createScriptProcessor(512, 0, 0) threw NotSupportedError: "The operation is not supported.".
+PASS   createScriptProcessor(512, 0, 0) threw NotSupportedError: "numberOfInputChannels and numberOfOutputChannels cannot both be 0".
 PASS   context.createScriptProcessor(512, 1, 0) did not throw an exception.
 PASS   context.createScriptProcessor(512, 2, 0) did not throw an exception.
 PASS   context.createScriptProcessor(512, 0, 1) did not throw an exception.
 PASS   context.createScriptProcessor(512, 0, 2) did not throw an exception.
-PASS   context.createScriptProcessor(511, 1, 1) threw IndexSizeError: "The index is not in the allowed range.".
+PASS   context.createScriptProcessor(511, 1, 1) threw IndexSizeError: "Unsupported buffer size for ScriptProcessorNode".
 PASS   context.createScriptProcessor(256, 1, 1) did not throw an exception.
 PASS   context.createScriptProcessor(512, 1, 1) did not throw an exception.
 PASS   context.createScriptProcessor(1024, 1, 1) did not throw an exception.

Modified: trunk/LayoutTests/webaudio/convolver-channels-expected.txt (268811 => 268812)


--- trunk/LayoutTests/webaudio/convolver-channels-expected.txt	2020-10-21 18:33:17 UTC (rev 268811)
+++ trunk/LayoutTests/webaudio/convolver-channels-expected.txt	2020-10-21 18:38:48 UTC (rev 268812)
@@ -7,92 +7,92 @@
 PASS ConvolverNode with buffer of 2 channels did not throw exception.
 PASS function () {
                 convolver.buffer = buffer;
-            } threw exception NotSupportedError: The operation is not supported..
+            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
 PASS ConvolverNode with buffer of 4 channels did not throw exception.
 PASS function () {
                 convolver.buffer = buffer;
-            } threw exception NotSupportedError: The operation is not supported..
+            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
 PASS function () {
                 convolver.buffer = buffer;
-            } threw exception NotSupportedError: The operation is not supported..
+            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
 PASS function () {
                 convolver.buffer = buffer;
-            } threw exception NotSupportedError: The operation is not supported..
+            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
 PASS function () {
                 convolver.buffer = buffer;
-            } threw exception NotSupportedError: The operation is not supported..
+            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
 PASS function () {
                 convolver.buffer = buffer;
-            } threw exception NotSupportedError: The operation is not supported..
+            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
 PASS function () {
                 convolver.buffer = buffer;
-            } threw exception NotSupportedError: The operation is not supported..
+            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
 PASS function () {
                 convolver.buffer = buffer;
-            } threw exception NotSupportedError: The operation is not supported..
+            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
 PASS function () {
                 convolver.buffer = buffer;
-            } threw exception NotSupportedError: The operation is not supported..
+            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
 PASS function () {
                 convolver.buffer = buffer;
-            } threw exception NotSupportedError: The operation is not supported..
+            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
 PASS function () {
                 convolver.buffer = buffer;
-            } threw exception NotSupportedError: The operation is not supported..
+            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
 PASS function () {
                 convolver.buffer = buffer;
-            } threw exception NotSupportedError: The operation is not supported..
+            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
 PASS function () {
                 convolver.buffer = buffer;
-            } threw exception NotSupportedError: The operation is not supported..
+            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
 PASS function () {
                 convolver.buffer = buffer;
-            } threw exception NotSupportedError: The operation is not supported..
+            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
 PASS function () {
                 convolver.buffer = buffer;
-            } threw exception NotSupportedError: The operation is not supported..
+            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
 PASS function () {
                 convolver.buffer = buffer;
-            } threw exception NotSupportedError: The operation is not supported..
+            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
 PASS function () {
                 convolver.buffer = buffer;
-            } threw exception NotSupportedError: The operation is not supported..
+            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
 PASS function () {
                 convolver.buffer = buffer;
-            } threw exception NotSupportedError: The operation is not supported..
+            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
 PASS function () {
                 convolver.buffer = buffer;
-            } threw exception NotSupportedError: The operation is not supported..
+            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
 PASS function () {
                 convolver.buffer = buffer;
-            } threw exception NotSupportedError: The operation is not supported..
+            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
 PASS function () {
                 convolver.buffer = buffer;
-            } threw exception NotSupportedError: The operation is not supported..
+            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
 PASS function () {
                 convolver.buffer = buffer;
-            } threw exception NotSupportedError: The operation is not supported..
+            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
 PASS function () {
                 convolver.buffer = buffer;
-            } threw exception NotSupportedError: The operation is not supported..
+            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
 PASS function () {
                 convolver.buffer = buffer;
-            } threw exception NotSupportedError: The operation is not supported..
+            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
 PASS function () {
                 convolver.buffer = buffer;
-            } threw exception NotSupportedError: The operation is not supported..
+            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
 PASS function () {
                 convolver.buffer = buffer;
-            } threw exception NotSupportedError: The operation is not supported..
+            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
 PASS function () {
                 convolver.buffer = buffer;
-            } threw exception NotSupportedError: The operation is not supported..
+            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
 PASS function () {
                 convolver.buffer = buffer;
-            } threw exception NotSupportedError: The operation is not supported..
+            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
 PASS function () {
                 convolver.buffer = buffer;
-            } threw exception NotSupportedError: The operation is not supported..
+            } threw exception NotSupportedError: Buffer should have 1, 2 or 4 channels.
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/webaudio/convolver-setBuffer-different-samplerate-expected.txt (268811 => 268812)


--- trunk/LayoutTests/webaudio/convolver-setBuffer-different-samplerate-expected.txt	2020-10-21 18:33:17 UTC (rev 268811)
+++ trunk/LayoutTests/webaudio/convolver-setBuffer-different-samplerate-expected.txt	2020-10-21 18:38:48 UTC (rev 268812)
@@ -3,7 +3,7 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS convolver.buffer = context.createBuffer(1, 256, 22050) threw exception NotSupportedError: The operation is not supported..
+PASS convolver.buffer = context.createBuffer(1, 256, 22050) threw exception NotSupportedError: Buffer sample rate does not match the context's sample rate.
 PASS convolver.buffer = context.createBuffer(1, 256, 44100) did not throw exception.
 PASS successfullyParsed is true
 

Modified: trunk/LayoutTests/webaudio/delaynode-maxdelaylimit-expected.txt (268811 => 268812)


--- trunk/LayoutTests/webaudio/delaynode-maxdelaylimit-expected.txt	2020-10-21 18:33:17 UTC (rev 268811)
+++ trunk/LayoutTests/webaudio/delaynode-maxdelaylimit-expected.txt	2020-10-21 18:38:48 UTC (rev 268812)
@@ -2,9 +2,9 @@
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
-PASS context.createDelay(180) threw exception NotSupportedError: The operation is not supported..
-PASS context.createDelay(0) threw exception NotSupportedError: The operation is not supported..
-PASS context.createDelay(-1) threw exception NotSupportedError: The operation is not supported..
+PASS context.createDelay(180) threw exception NotSupportedError: maxDelayTime should be less than 180.
+PASS context.createDelay(0) threw exception NotSupportedError: maxDelayTime should be a positive value.
+PASS context.createDelay(-1) threw exception NotSupportedError: maxDelayTime should be a positive value.
 PASS delay.delayTime.value === 0.5 is true
 PASS Test signal was correctly delayed by 0.5 sec.
 PASS successfullyParsed is true

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


--- trunk/LayoutTests/webaudio/dom-exceptions-expected.txt	2020-10-21 18:33:17 UTC (rev 268811)
+++ trunk/LayoutTests/webaudio/dom-exceptions-expected.txt	2020-10-21 18:38:48 UTC (rev 268812)
@@ -49,9 +49,9 @@
 PASS   context.createMediaStreamSource(null) threw TypeError: "Argument 1 ('mediaStream') to AudioContext.createMediaStreamSource must be an instance of MediaStream".
 PASS < [createMediaStreamSource] All assertions passed. (total 1 assertions)
 PASS > [createScriptProcessor]
-PASS   context.createScriptProcessor(1, 1, 1) threw IndexSizeError: "The index is not in the allowed range.".
-PASS   context.createScriptProcessor(4096, 100, 1) threw NotSupportedError: "The operation is not supported.".
-PASS   context.createScriptProcessor(4096, 1, 100) threw NotSupportedError: "The operation is not supported.".
+PASS   context.createScriptProcessor(1, 1, 1) threw IndexSizeError: "Unsupported buffer size for ScriptProcessorNode".
+PASS   context.createScriptProcessor(4096, 100, 1) threw NotSupportedError: "numberOfInputChannels exceeds maximum number of channels".
+PASS   context.createScriptProcessor(4096, 1, 100) threw NotSupportedError: "numberOfOutputChannels exceeds maximum number of channels".
 PASS   context.createScriptProcessor() did not throw an exception.
 PASS   context.createScriptProcessor(0) did not throw an exception.
 PASS < [createScriptProcessor] All assertions passed. (total 5 assertions)
@@ -222,7 +222,7 @@
 PASS   oc = new OfflineAudioContext(1, 44100, 44100) did not throw an exception.
 PASS   conv = oc.createConvolver() did not throw an exception.
 PASS   conv.buffer = {} threw TypeError: "The ConvolverNode.buffer attribute must be an instance of AudioBuffer".
-PASS   conv.buffer = oc.createBuffer(1, 100, 22050) threw NotSupportedError: "The operation is not supported.".
+PASS   conv.buffer = oc.createBuffer(1, 100, 22050) threw NotSupportedError: "Buffer sample rate does not match the context's sample rate".
 PASS   conv.buffer is equal to null.
 PASS < [convolver] All assertions passed. (total 5 assertions)
 PASS > [panner]

Modified: trunk/Source/WebCore/ChangeLog (268811 => 268812)


--- trunk/Source/WebCore/ChangeLog	2020-10-21 18:33:17 UTC (rev 268811)
+++ trunk/Source/WebCore/ChangeLog	2020-10-21 18:38:48 UTC (rev 268812)
@@ -1,3 +1,35 @@
+2020-10-21  Chris Dumez  <[email protected]>
+
+        Make sure WebAudio API throws exceptions with useful error messages
+        https://bugs.webkit.org/show_bug.cgi?id=218033
+
+        Reviewed by Darin Adler.
+
+        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):
+
 2020-10-21  Antoine Quint  <[email protected]>
 
         REGRESSION (r263729): transform transition doesn't restart

Modified: trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp (268811 => 268812)


--- trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp	2020-10-21 18:33:17 UTC (rev 268811)
+++ trunk/Source/WebCore/Modules/webaudio/AudioContext.cpp	2020-10-21 18:38:48 UTC (rev 268812)
@@ -86,7 +86,7 @@
     ASSERT(isMainThread());
 #if OS(WINDOWS)
     if (s_hardwareContextCount >= maxHardwareContexts)
-        return Exception { QuotaExceededError };
+        return Exception { QuotaExceededError, "Reached maximum number of hardware contexts on this platform"_s };
 #endif
     
     if (!document.isFullyActive())

Modified: trunk/Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.cpp (268811 => 268812)


--- trunk/Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.cpp	2020-10-21 18:33:17 UTC (rev 268811)
+++ trunk/Source/WebCore/Modules/webaudio/AudioScheduledSourceNode.cpp	2020-10-21 18:38:48 UTC (rev 268812)
@@ -153,7 +153,7 @@
     ALWAYS_LOG(LOGIDENTIFIER, when);
 
     if (m_playbackState != UNSCHEDULED_STATE)
-        return Exception { InvalidStateError };
+        return Exception { InvalidStateError, "Cannot call start() more than once"_s };
 
     if (!std::isfinite(when) || when < 0)
         return Exception { RangeError, "when value should be positive"_s };

Modified: trunk/Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.cpp (268811 => 268812)


--- trunk/Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.cpp	2020-10-21 18:33:17 UTC (rev 268811)
+++ trunk/Source/WebCore/Modules/webaudio/AudioWorkletGlobalScope.cpp	2020-10-21 18:38:48 UTC (rev 268812)
@@ -76,18 +76,18 @@
         return Exception { TypeError, "Class definitition passed to registerProcessor() is not a constructor"_s };
 
     auto prototype = jsConstructor->getPrototype(vm, globalObject);
-    RETURN_IF_EXCEPTION(scope, Exception { TypeError });
+    RETURN_IF_EXCEPTION(scope, Exception { ExistingExceptionError });
 
     if (!prototype.isObject())
         return Exception { TypeError, "Class definitition passed to registerProcessor() has invalid prototype"_s };
 
     auto parameterDescriptorsValue = jsConstructor->get(globalObject, JSC::Identifier::fromString(vm, "parameterDescriptors"));
-    RETURN_IF_EXCEPTION(scope, Exception { TypeError });
+    RETURN_IF_EXCEPTION(scope, Exception { ExistingExceptionError });
 
     Vector<AudioParamDescriptor> parameterDescriptors;
     if (!parameterDescriptorsValue.isUndefined()) {
         parameterDescriptors = convert<IDLSequence<IDLDictionary<AudioParamDescriptor>>>(*globalObject, parameterDescriptorsValue);
-        RETURN_IF_EXCEPTION(scope, Exception { TypeError });
+        RETURN_IF_EXCEPTION(scope, Exception { ExistingExceptionError });
         UNUSED_PARAM(parameterDescriptors);
         HashSet<String> paramNames;
         for (auto& descriptor : parameterDescriptors) {

Modified: trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.cpp (268811 => 268812)


--- trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.cpp	2020-10-21 18:33:17 UTC (rev 268811)
+++ trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.cpp	2020-10-21 18:38:48 UTC (rev 268812)
@@ -414,7 +414,7 @@
     case 16384:
         break;
     default:
-        return Exception { IndexSizeError };
+        return Exception { IndexSizeError, "Unsupported buffer size for ScriptProcessorNode"_s };
     }
 
     // An IndexSizeError exception must be thrown if bufferSize or numberOfInputChannels or numberOfOutputChannels
@@ -422,19 +422,19 @@
     // In this case an IndexSizeError must be thrown.
 
     if (!numberOfInputChannels && !numberOfOutputChannels)
-        return Exception { NotSupportedError };
+        return Exception { NotSupportedError, "numberOfInputChannels and numberOfOutputChannels cannot both be 0"_s };
 
     // This parameter [numberOfInputChannels] determines the number of channels for this node's input. Values of
     // up to 32 must be supported. A NotSupportedError must be thrown if the number of channels is not supported.
 
     if (numberOfInputChannels > maxNumberOfChannels())
-        return Exception { NotSupportedError };
+        return Exception { NotSupportedError, "numberOfInputChannels exceeds maximum number of channels"_s };
 
     // This parameter [numberOfOutputChannels] determines the number of channels for this node's output. Values of
     // up to 32 must be supported. A NotSupportedError must be thrown if the number of channels is not supported.
 
     if (numberOfOutputChannels > maxNumberOfChannels())
-        return Exception { NotSupportedError };
+        return Exception { NotSupportedError, "numberOfOutputChannels exceeds maximum number of channels"_s };
 
     return ScriptProcessorNode::create(*this, bufferSize, numberOfInputChannels, numberOfOutputChannels);
 }
@@ -925,7 +925,7 @@
     ASSERT(isOfflineContext());
     ASSERT(isMainThread());
     auto finishedRenderingScope = WTF::makeScopeExit([this] {
-        didFinishOfflineRendering(Exception { InvalidStateError });
+        didFinishOfflineRendering(Exception { InvalidStateError, "Offline rendering failed"_s });
     });
 
     if (!isMainThread())

Modified: trunk/Source/WebCore/Modules/webaudio/ConvolverNode.cpp (268811 => 268812)


--- trunk/Source/WebCore/Modules/webaudio/ConvolverNode.cpp	2020-10-21 18:33:17 UTC (rev 268811)
+++ trunk/Source/WebCore/Modules/webaudio/ConvolverNode.cpp	2020-10-21 18:38:48 UTC (rev 268812)
@@ -118,7 +118,7 @@
         return { };
 
     if (buffer->sampleRate() != context().sampleRate())
-        return Exception { NotSupportedError };
+        return Exception { NotSupportedError, "Buffer sample rate does not match the context's sample rate"_s };
 
     unsigned numberOfChannels = buffer->numberOfChannels();
     size_t bufferLength = buffer->length();
@@ -125,11 +125,14 @@
 
     // The current implementation supports only 1-, 2-, or 4-channel impulse responses, with the
     // 4-channel response being interpreted as true-stereo (see Reverb class).
-    bool isChannelCountGood = (numberOfChannels == 1 || numberOfChannels == 2 || numberOfChannels == 4) && bufferLength;
+    bool isChannelCountGood = (numberOfChannels == 1 || numberOfChannels == 2 || numberOfChannels == 4);
 
     if (!isChannelCountGood)
-        return Exception { NotSupportedError };
+        return Exception { NotSupportedError, "Buffer should have 1, 2 or 4 channels"_s };
 
+    if (!bufferLength)
+        return Exception { NotSupportedError, "Buffer length cannot be 0"_s };
+
     // Wrap the AudioBuffer by an AudioBus. It's an efficient pointer set and not a memcpy().
     // This memory is simply used in the Reverb constructor and no reference to it is kept for later use in that class.
     auto bufferBus = AudioBus::create(numberOfChannels, bufferLength, false);

Modified: trunk/Source/WebCore/Modules/webaudio/DefaultAudioDestinationNode.cpp (268811 => 268812)


--- trunk/Source/WebCore/Modules/webaudio/DefaultAudioDestinationNode.cpp	2020-10-21 18:33:17 UTC (rev 268811)
+++ trunk/Source/WebCore/Modules/webaudio/DefaultAudioDestinationNode.cpp	2020-10-21 18:38:48 UTC (rev 268812)
@@ -123,7 +123,7 @@
 {
     ASSERT(isInitialized());
     if (!isInitialized())
-        return Exception { InvalidStateError };
+        return Exception { InvalidStateError, "AudioDestinationNode is not initialized"_s };
 
     m_destination->start(dispatchToRenderThreadFunction());
     return { };

Modified: trunk/Source/WebCore/Modules/webaudio/DelayNode.cpp (268811 => 268812)


--- trunk/Source/WebCore/Modules/webaudio/DelayNode.cpp	2020-10-21 18:33:17 UTC (rev 268811)
+++ trunk/Source/WebCore/Modules/webaudio/DelayNode.cpp	2020-10-21 18:38:48 UTC (rev 268812)
@@ -49,9 +49,12 @@
 
 ExceptionOr<Ref<DelayNode>> DelayNode::create(BaseAudioContext& context, const DelayOptions& options)
 {
-    if (options.maxDelayTime <= 0 || options.maxDelayTime >= maximumAllowedDelayTime)
-        return Exception { NotSupportedError };
+    if (options.maxDelayTime <= 0)
+        return Exception { NotSupportedError, "maxDelayTime should be a positive value"_s };
 
+    if (options.maxDelayTime >= maximumAllowedDelayTime)
+        return Exception { NotSupportedError, makeString("maxDelayTime should be less than ", maximumAllowedDelayTime) };
+
     auto delayNode = adoptRef(*new DelayNode(context, options.maxDelayTime));
 
     auto result = delayNode->handleAudioNodeOptions(options, { 2, ChannelCountMode::Max, ChannelInterpretation::Speakers });

Modified: trunk/Source/WebCore/Modules/webaudio/OfflineAudioContext.cpp (268811 => 268812)


--- trunk/Source/WebCore/Modules/webaudio/OfflineAudioContext.cpp	2020-10-21 18:33:17 UTC (rev 268811)
+++ trunk/Source/WebCore/Modules/webaudio/OfflineAudioContext.cpp	2020-10-21 18:38:48 UTC (rev 268812)
@@ -45,9 +45,8 @@
 
 ExceptionOr<Ref<OfflineAudioContext>> OfflineAudioContext::create(ScriptExecutionContext& context, unsigned numberOfChannels, size_t length, float sampleRate)
 {
-    // FIXME: Add support for workers.
     if (!is<Document>(context))
-        return Exception { NotSupportedError };
+        return Exception { NotSupportedError, "OfflineAudioContext is only supported in Document contexts"_s };
     if (!numberOfChannels || numberOfChannels > maxNumberOfChannels())
         return Exception { SyntaxError, "Number of channels is not in range"_s };
     if (!length)

Modified: trunk/Source/WebCore/Modules/webaudio/OfflineAudioDestinationNode.cpp (268811 => 268812)


--- trunk/Source/WebCore/Modules/webaudio/OfflineAudioDestinationNode.cpp	2020-10-21 18:33:17 UTC (rev 268811)
+++ trunk/Source/WebCore/Modules/webaudio/OfflineAudioDestinationNode.cpp	2020-10-21 18:38:48 UTC (rev 268812)
@@ -91,7 +91,7 @@
     ASSERT(isMainThread());
     ASSERT(m_renderTarget.get());
     if (!m_renderTarget.get())
-        return Exception { InvalidStateError };
+        return Exception { InvalidStateError, "OfflineAudioContextNode has no rendering buffer"_s };
     
     if (m_startedRendering)
         return Exception { InvalidStateError, "Already started rendering"_s };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to