Title: [265196] trunk
Revision
265196
Author
[email protected]
Date
2020-08-03 08:51:42 -0700 (Mon, 03 Aug 2020)

Log Message

Added Constructor to AnalyserNode
https://bugs.webkit.org/show_bug.cgi?id=215040

Patch by Clark Wang <[email protected]> on 2020-08-03
Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

Re-baselined existing tests.

* web-platform-tests/webaudio/idlharness.https.window-expected.txt:
* web-platform-tests/webaudio/the-audio-api/the-analysernode-interface/ctor-analyser-expected.txt:
* web-platform-tests/webaudio/the-audio-api/the-analysernode-interface/realtimeanalyser-fft-sizing-expected.txt:
* web-platform-tests/webaudio/the-audio-api/the-analysernode-interface/test-analysernode-expected.txt:

Source/WebCore:

Introduced AnalyserNode constructor and AnalyserOptions according to spec:
https://www.w3.org/TR/webaudio/#AnalyserNode-constructors.

Re-baselined existing tests.

* CMakeLists.txt:
* DerivedSources-input.xcfilelist:
* DerivedSources-output.xcfilelist:
* DerivedSources.make:
* Modules/webaudio/AnalyserNode.cpp:
(WebCore::AnalyserNode::create):
(WebCore::AnalyserNode::AnalyserNode):
(WebCore::AnalyserNode::setFftSize):
(WebCore::AnalyserNode::setMinMaxDecibels):
(WebCore::AnalyserNode::setMinDecibels):
(WebCore::AnalyserNode::setMaxDecibels):
* Modules/webaudio/AnalyserNode.h:
* Modules/webaudio/AnalyserNode.idl:
* Modules/webaudio/AnalyserOptions.h: Added.
* Modules/webaudio/AnalyserOptions.idl: Added.
* Modules/webaudio/BaseAudioContext.cpp:
(WebCore::BaseAudioContext::createAnalyser):
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:

LayoutTests:

Re-baselined existing tests.

* webaudio/analyser-exception-expected.txt:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (265195 => 265196)


--- trunk/LayoutTests/ChangeLog	2020-08-03 12:29:30 UTC (rev 265195)
+++ trunk/LayoutTests/ChangeLog	2020-08-03 15:51:42 UTC (rev 265196)
@@ -1,3 +1,14 @@
+2020-08-03  Clark Wang  <[email protected]>
+
+        Added Constructor to AnalyserNode
+        https://bugs.webkit.org/show_bug.cgi?id=215040
+
+        Reviewed by Chris Dumez.
+
+        Re-baselined existing tests.
+
+        * webaudio/analyser-exception-expected.txt:
+
 2020-08-02  Darin Adler  <[email protected]>
 
         Write a script to find duplicate files and delete some duplicate tests in LayoutTests

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (265195 => 265196)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-08-03 12:29:30 UTC (rev 265195)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-08-03 15:51:42 UTC (rev 265196)
@@ -1,3 +1,17 @@
+2020-08-03  Clark Wang  <[email protected]>
+
+        Added Constructor to AnalyserNode
+        https://bugs.webkit.org/show_bug.cgi?id=215040
+
+        Reviewed by Chris Dumez.
+
+        Re-baselined existing tests.
+
+        * web-platform-tests/webaudio/idlharness.https.window-expected.txt:
+        * web-platform-tests/webaudio/the-audio-api/the-analysernode-interface/ctor-analyser-expected.txt:
+        * web-platform-tests/webaudio/the-audio-api/the-analysernode-interface/realtimeanalyser-fft-sizing-expected.txt:
+        * web-platform-tests/webaudio/the-audio-api/the-analysernode-interface/test-analysernode-expected.txt:
+
 2020-07-31  Chris Dumez  <[email protected]>
 
         Add OfflineAudioCompletionEvent constructor

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/idlharness.https.window-expected.txt (265195 => 265196)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/idlharness.https.window-expected.txt	2020-08-03 12:29:30 UTC (rev 265195)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/idlharness.https.window-expected.txt	2020-08-03 15:51:42 UTC (rev 265196)
@@ -264,7 +264,7 @@
 PASS AudioScheduledSourceNode interface: operation start(optional double) 
 PASS AudioScheduledSourceNode interface: operation stop(optional double) 
 PASS AnalyserNode interface: existence and properties of interface object 
-FAIL AnalyserNode interface object length assert_equals: wrong value for AnalyserNode.length expected 1 but got 0
+PASS AnalyserNode interface object length 
 PASS AnalyserNode interface object name 
 PASS AnalyserNode interface: existence and properties of interface prototype object 
 PASS AnalyserNode interface: existence and properties of interface prototype object's "constructor" property 
@@ -278,44 +278,44 @@
 PASS AnalyserNode interface: attribute minDecibels 
 PASS AnalyserNode interface: attribute maxDecibels 
 PASS AnalyserNode interface: attribute smoothingTimeConstant 
-FAIL AnalyserNode must be primary interface of new AnalyserNode(context) assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL Stringification of new AnalyserNode(context) assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AnalyserNode interface: new AnalyserNode(context) must inherit property "getFloatFrequencyData(Float32Array)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AnalyserNode interface: calling getFloatFrequencyData(Float32Array) on new AnalyserNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AnalyserNode interface: new AnalyserNode(context) must inherit property "getByteFrequencyData(Uint8Array)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AnalyserNode interface: calling getByteFrequencyData(Uint8Array) on new AnalyserNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AnalyserNode interface: new AnalyserNode(context) must inherit property "getFloatTimeDomainData(Float32Array)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AnalyserNode interface: calling getFloatTimeDomainData(Float32Array) on new AnalyserNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AnalyserNode interface: new AnalyserNode(context) must inherit property "getByteTimeDomainData(Uint8Array)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AnalyserNode interface: calling getByteTimeDomainData(Uint8Array) on new AnalyserNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AnalyserNode interface: new AnalyserNode(context) must inherit property "fftSize" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AnalyserNode interface: new AnalyserNode(context) must inherit property "frequencyBinCount" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AnalyserNode interface: new AnalyserNode(context) must inherit property "minDecibels" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AnalyserNode interface: new AnalyserNode(context) must inherit property "maxDecibels" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AnalyserNode interface: new AnalyserNode(context) must inherit property "smoothingTimeConstant" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AudioNode interface: new AnalyserNode(context) must inherit property "connect(AudioNode, optional unsigned long, optional unsigned long)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AudioNode interface: calling connect(AudioNode, optional unsigned long, optional unsigned long) on new AnalyserNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AudioNode interface: new AnalyserNode(context) must inherit property "connect(AudioParam, optional unsigned long)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AudioNode interface: calling connect(AudioParam, optional unsigned long) on new AnalyserNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AudioNode interface: new AnalyserNode(context) must inherit property "disconnect()" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AudioNode interface: new AnalyserNode(context) must inherit property "disconnect(unsigned long)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AudioNode interface: calling disconnect(unsigned long) on new AnalyserNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AudioNode interface: new AnalyserNode(context) must inherit property "disconnect(AudioNode)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AudioNode interface: calling disconnect(AudioNode) on new AnalyserNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AudioNode interface: new AnalyserNode(context) must inherit property "disconnect(AudioNode, unsigned long)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AudioNode interface: calling disconnect(AudioNode, unsigned long) on new AnalyserNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AudioNode interface: new AnalyserNode(context) must inherit property "disconnect(AudioNode, unsigned long, unsigned long)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AudioNode interface: calling disconnect(AudioNode, unsigned long, unsigned long) on new AnalyserNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AudioNode interface: new AnalyserNode(context) must inherit property "disconnect(AudioParam)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AudioNode interface: calling disconnect(AudioParam) on new AnalyserNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AudioNode interface: new AnalyserNode(context) must inherit property "disconnect(AudioParam, unsigned long)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AudioNode interface: calling disconnect(AudioParam, unsigned long) on new AnalyserNode(context) with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AudioNode interface: new AnalyserNode(context) must inherit property "context" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AudioNode interface: new AnalyserNode(context) must inherit property "numberOfInputs" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AudioNode interface: new AnalyserNode(context) must inherit property "numberOfOutputs" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AudioNode interface: new AnalyserNode(context) must inherit property "channelCount" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AudioNode interface: new AnalyserNode(context) must inherit property "channelCountMode" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
-FAIL AudioNode interface: new AnalyserNode(context) must inherit property "channelInterpretation" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: function is not a constructor (evaluating 'new AnalyserNode(context)')"
+PASS AnalyserNode must be primary interface of new AnalyserNode(context) 
+PASS Stringification of new AnalyserNode(context) 
+PASS AnalyserNode interface: new AnalyserNode(context) must inherit property "getFloatFrequencyData(Float32Array)" with the proper type 
+PASS AnalyserNode interface: calling getFloatFrequencyData(Float32Array) on new AnalyserNode(context) with too few arguments must throw TypeError 
+PASS AnalyserNode interface: new AnalyserNode(context) must inherit property "getByteFrequencyData(Uint8Array)" with the proper type 
+PASS AnalyserNode interface: calling getByteFrequencyData(Uint8Array) on new AnalyserNode(context) with too few arguments must throw TypeError 
+PASS AnalyserNode interface: new AnalyserNode(context) must inherit property "getFloatTimeDomainData(Float32Array)" with the proper type 
+PASS AnalyserNode interface: calling getFloatTimeDomainData(Float32Array) on new AnalyserNode(context) with too few arguments must throw TypeError 
+PASS AnalyserNode interface: new AnalyserNode(context) must inherit property "getByteTimeDomainData(Uint8Array)" with the proper type 
+PASS AnalyserNode interface: calling getByteTimeDomainData(Uint8Array) on new AnalyserNode(context) with too few arguments must throw TypeError 
+PASS AnalyserNode interface: new AnalyserNode(context) must inherit property "fftSize" with the proper type 
+PASS AnalyserNode interface: new AnalyserNode(context) must inherit property "frequencyBinCount" with the proper type 
+PASS AnalyserNode interface: new AnalyserNode(context) must inherit property "minDecibels" with the proper type 
+PASS AnalyserNode interface: new AnalyserNode(context) must inherit property "maxDecibels" with the proper type 
+PASS AnalyserNode interface: new AnalyserNode(context) must inherit property "smoothingTimeConstant" with the proper type 
+PASS AudioNode interface: new AnalyserNode(context) must inherit property "connect(AudioNode, optional unsigned long, optional unsigned long)" with the proper type 
+PASS AudioNode interface: calling connect(AudioNode, optional unsigned long, optional unsigned long) on new AnalyserNode(context) with too few arguments must throw TypeError 
+PASS AudioNode interface: new AnalyserNode(context) must inherit property "connect(AudioParam, optional unsigned long)" with the proper type 
+PASS AudioNode interface: calling connect(AudioParam, optional unsigned long) on new AnalyserNode(context) with too few arguments must throw TypeError 
+PASS AudioNode interface: new AnalyserNode(context) must inherit property "disconnect()" with the proper type 
+PASS AudioNode interface: new AnalyserNode(context) must inherit property "disconnect(unsigned long)" with the proper type 
+PASS AudioNode interface: calling disconnect(unsigned long) on new AnalyserNode(context) with too few arguments must throw TypeError 
+PASS AudioNode interface: new AnalyserNode(context) must inherit property "disconnect(AudioNode)" with the proper type 
+PASS AudioNode interface: calling disconnect(AudioNode) on new AnalyserNode(context) with too few arguments must throw TypeError 
+PASS AudioNode interface: new AnalyserNode(context) must inherit property "disconnect(AudioNode, unsigned long)" with the proper type 
+PASS AudioNode interface: calling disconnect(AudioNode, unsigned long) on new AnalyserNode(context) with too few arguments must throw TypeError 
+PASS AudioNode interface: new AnalyserNode(context) must inherit property "disconnect(AudioNode, unsigned long, unsigned long)" with the proper type 
+PASS AudioNode interface: calling disconnect(AudioNode, unsigned long, unsigned long) on new AnalyserNode(context) with too few arguments must throw TypeError 
+PASS AudioNode interface: new AnalyserNode(context) must inherit property "disconnect(AudioParam)" with the proper type 
+PASS AudioNode interface: calling disconnect(AudioParam) on new AnalyserNode(context) with too few arguments must throw TypeError 
+PASS AudioNode interface: new AnalyserNode(context) must inherit property "disconnect(AudioParam, unsigned long)" with the proper type 
+PASS AudioNode interface: calling disconnect(AudioParam, unsigned long) on new AnalyserNode(context) with too few arguments must throw TypeError 
+PASS AudioNode interface: new AnalyserNode(context) must inherit property "context" with the proper type 
+PASS AudioNode interface: new AnalyserNode(context) must inherit property "numberOfInputs" with the proper type 
+PASS AudioNode interface: new AnalyserNode(context) must inherit property "numberOfOutputs" with the proper type 
+PASS AudioNode interface: new AnalyserNode(context) must inherit property "channelCount" with the proper type 
+PASS AudioNode interface: new AnalyserNode(context) must inherit property "channelCountMode" with the proper type 
+PASS AudioNode interface: new AnalyserNode(context) must inherit property "channelInterpretation" with the proper type 
 PASS AudioBufferSourceNode interface: existence and properties of interface object 
 FAIL AudioBufferSourceNode interface object length assert_equals: wrong value for AudioBufferSourceNode.length expected 1 but got 0
 PASS AudioBufferSourceNode interface object name 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-analysernode-interface/ctor-analyser-expected.txt (265195 => 265196)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-analysernode-interface/ctor-analyser-expected.txt	2020-08-03 12:29:30 UTC (rev 265195)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-analysernode-interface/ctor-analyser-expected.txt	2020-08-03 15:51:42 UTC (rev 265196)
@@ -2,10 +2,10 @@
 PASS # AUDIT TASK RUNNER STARTED. 
 PASS Executing "initialize" 
 PASS Executing "invalid constructor" 
-FAIL Executing "default constructor" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'node.numberOfInputs')"
-FAIL Executing "test AudioNodeOptions" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'node.channelCount')"
-FAIL Executing "constructor with options" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'node.fftSize')"
-FAIL Executing "construct invalid options" promise_test: Unhandled rejection with value: object "TypeError: undefined is not an object (evaluating 'node.frequencyBinCount')"
+PASS Executing "default constructor" 
+PASS Executing "test AudioNodeOptions" 
+PASS Executing "constructor with options" 
+PASS Executing "construct invalid options" 
 PASS Executing "setting min/max" 
 PASS Audit report 
 PASS > [initialize]  
@@ -12,31 +12,69 @@
 PASS   context = new OfflineAudioContext(...) did not throw an exception. 
 PASS < [initialize] All assertions passed. (total 1 assertions) 
 PASS > [invalid constructor]  
-PASS   new AnalyserNode() threw TypeError: "function is not a constructor (evaluating 'new window[name]()')". 
-PASS   new AnalyserNode(1) threw TypeError: "function is not a constructor (evaluating 'new window[name](1)')". 
-PASS   new AnalyserNode(context, 42) threw TypeError: "function is not a constructor (evaluating 'new window[name](context, 42)')". 
+PASS   new AnalyserNode() threw TypeError: "Not enough arguments". 
+PASS   new AnalyserNode(1) threw TypeError: "Argument 1 ('context') to the AnalyserNode constructor must be an instance of BaseAudioContext". 
+PASS   new AnalyserNode(context, 42) threw TypeError: "Type error". 
 PASS < [invalid constructor] All assertions passed. (total 3 assertions) 
 PASS > [default constructor]  
-FAIL X node0 = new AnalyserNode(context) incorrectly threw TypeError: "function is not a constructor (evaluating 'new window[name](context, options.constructorOptions)')". assert_true: expected true got false
-FAIL X node0 instanceof AnalyserNode is not equal to true. Got false. assert_true: expected true got false
+PASS   node0 = new AnalyserNode(context) did not throw an exception. 
+PASS   node0 instanceof AnalyserNode is equal to true. 
+PASS   node0.numberOfInputs is equal to 1. 
+PASS   node0.numberOfOutputs is equal to 1. 
+PASS   node0.channelCount is equal to 2. 
+PASS   node0.channelCountMode is equal to max. 
+PASS   node0.channelInterpretation is equal to speakers. 
+PASS   node0.fftSize is equal to 2048. 
+PASS   node0.frequencyBinCount is equal to 1024. 
+PASS   node0.minDecibels is equal to -100. 
+PASS   node0.maxDecibels is equal to -30. 
+PASS   node0.smoothingTimeConstant is equal to 0.8. 
+PASS < [default constructor] All assertions passed. (total 12 assertions) 
 PASS > [test AudioNodeOptions]  
-FAIL X new AnalyserNode(c, {channelCount: 17}) incorrectly threw TypeError: "function is not a constructor (evaluating 'new window[nodeName]')". assert_true: expected true got false
+PASS   new AnalyserNode(c, {channelCount: 17}) did not throw an exception. 
+PASS   node.channelCount is equal to 17. 
+PASS   new AnalyserNode(c, {channelCount: 0}) threw InvalidStateError: "The object is in an invalid state.". 
+PASS   new AnalyserNode(c, {channelCount: 99}) threw InvalidStateError: "The object is in an invalid state.". 
+PASS   new AnalyserNode(c, {channelCountMode: "max"} did not throw an exception. 
+PASS   node.channelCountMode is equal to max. 
+PASS   new AnalyserNode(c, {channelCountMode: "max"}) did not throw an exception. 
+PASS   node.channelCountMode after valid setter is equal to max. 
+PASS   new AnalyserNode(c, {channelCountMode: "clamped-max"}) did not throw an exception. 
+PASS   node.channelCountMode after valid setter is equal to clamped-max. 
+PASS   new AnalyserNode(c, {channelCountMode: "explicit"}) did not throw an exception. 
+PASS   node.channelCountMode after valid setter is equal to explicit. 
+PASS   new AnalyserNode(c, {channelCountMode: "foobar"} threw TypeError: "Type error". 
+PASS   node.channelCountMode after invalid setter is equal to explicit. 
+PASS   new AnalyserNode(c, {channelInterpretation: "speakers"}) did not throw an exception. 
+PASS   node.channelInterpretation is equal to speakers. 
+PASS   new AnalyserNode(c, {channelInterpretation: "discrete"}) did not throw an exception. 
+PASS   node.channelInterpretation is equal to discrete. 
+PASS   new AnalyserNode(c, {channelInterpretation: "foobar"}) threw TypeError: "Type error". 
+PASS   node.channelInterpretation after invalid setter is equal to discrete. 
+PASS < [test AudioNodeOptions] All assertions passed. (total 20 assertions) 
 PASS > [constructor with options]  
-FAIL X node1 = new AnalyserNode(c, {"fftSize":32,"maxDecibels":1,"minDecibels":-13,"smoothingTimeConstant":0.125}) incorrectly threw TypeError: "function is not a constructor (evaluating 'new AnalyserNode(context, options)')". assert_true: expected true got false
-FAIL X node1 instanceof AnalyserNode is not equal to true. Got false. assert_true: expected true got false
+PASS   node1 = new AnalyserNode(c, {"fftSize":32,"maxDecibels":1,"minDecibels":-13,"smoothingTimeConstant":0.125}) did not throw an exception. 
+PASS   node1 instanceof AnalyserNode is equal to true. 
+PASS   node1.fftSize is equal to 32. 
+PASS   node1.maxDecibels is equal to 1. 
+PASS   node1.minDecibels is equal to -13. 
+PASS   node1.smoothingTimeConstant is equal to 0.125. 
+PASS < [constructor with options] All assertions passed. (total 6 assertions) 
 PASS > [construct invalid options]  
-FAIL X node = new AnalyserNode(c, { fftSize: 33 }) threw "TypeError" instead of IndexSizeError. assert_true: expected true got false
-FAIL X node = new AnalyserNode(c, { maxDecibels: -500 }) threw "TypeError" instead of IndexSizeError. assert_true: expected true got false
-FAIL X node = new AnalyserNode(c, { minDecibels: -10 }) threw "TypeError" instead of IndexSizeError. assert_true: expected true got false
-FAIL X node = new AnalyserNode(c, { smoothingTimeConstant: 2 }) threw "TypeError" instead of IndexSizeError. assert_true: expected true got false
-FAIL X node = new AnalyserNode(c, { frequencyBinCount: 33 }) incorrectly threw TypeError: "function is not a constructor (evaluating 'new AnalyserNode(context, {frequencyBinCount: 33})')". assert_true: expected true got false
+PASS   node = new AnalyserNode(c, { fftSize: 33 }) threw IndexSizeError: "fftSize must be power of 2 in the range 32 to 32768.". 
+PASS   node = new AnalyserNode(c, { maxDecibels: -500 }) threw IndexSizeError: "minDecibels must be less than maxDecibels.". 
+PASS   node = new AnalyserNode(c, { minDecibels: -10 }) threw IndexSizeError: "minDecibels must be less than maxDecibels.". 
+PASS   node = new AnalyserNode(c, { smoothingTimeConstant: 2 }) threw IndexSizeError: "The index is not in the allowed range.". 
+PASS   node = new AnalyserNode(c, { frequencyBinCount: 33 }) did not throw an exception. 
+PASS   node.frequencyBinCount is equal to 1024. 
+PASS < [construct invalid options] All assertions passed. (total 6 assertions) 
 PASS > [setting min/max]  
-FAIL X node = new AnalyserNode(c, {"minDecibels":-10,"maxDecibels":20}) incorrectly threw TypeError: "function is not a constructor (evaluating 'new AnalyserNode(context, options)')". assert_true: expected true got false
-FAIL X node = new AnalyserNode(c, {"maxDecibels":20,"minDecibels":-10}) incorrectly threw TypeError: "function is not a constructor (evaluating 'new AnalyserNode(context, options)')". assert_true: expected true got false
-FAIL X node = new AnalyserNode(c, {"minDecibels":-200,"maxDecibels":-150}) incorrectly threw TypeError: "function is not a constructor (evaluating 'new AnalyserNode(context, options)')". assert_true: expected true got false
-FAIL X node = new AnalyserNode(c, {"maxDecibels":-150,"minDecibels":-200}) incorrectly threw TypeError: "function is not a constructor (evaluating 'new AnalyserNode(context, options)')". assert_true: expected true got false
-FAIL X node = new AnalyserNode(c, {"maxDecibels":-150,"minDecibels":-10}) threw "TypeError" instead of IndexSizeError. assert_true: expected true got false
-FAIL X node = new AnalyserNode(c, {"minDecibels":-10,"maxDecibels":-150}) threw "TypeError" instead of IndexSizeError. assert_true: expected true got false
-FAIL < [setting min/max] 6 out of 6 assertions were failed. assert_true: expected true got false
-FAIL # AUDIT TASK RUNNER FINISHED: 5 out of 7 tasks were failed. assert_true: expected true got false
+PASS   node = new AnalyserNode(c, {"minDecibels":-10,"maxDecibels":20}) did not throw an exception. 
+PASS   node = new AnalyserNode(c, {"maxDecibels":20,"minDecibels":-10}) did not throw an exception. 
+PASS   node = new AnalyserNode(c, {"minDecibels":-200,"maxDecibels":-150}) did not throw an exception. 
+PASS   node = new AnalyserNode(c, {"maxDecibels":-150,"minDecibels":-200}) did not throw an exception. 
+PASS   node = new AnalyserNode(c, {"maxDecibels":-150,"minDecibels":-10}) threw IndexSizeError: "minDecibels must be less than maxDecibels.". 
+PASS   node = new AnalyserNode(c, {"minDecibels":-10,"maxDecibels":-150}) threw IndexSizeError: "minDecibels must be less than maxDecibels.". 
+PASS < [setting min/max] All assertions passed. (total 6 assertions) 
+PASS # AUDIT TASK RUNNER FINISHED: 7 tasks ran successfully. 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-analysernode-interface/realtimeanalyser-fft-sizing-expected.txt (265195 => 265196)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-analysernode-interface/realtimeanalyser-fft-sizing-expected.txt	2020-08-03 12:29:30 UTC (rev 265195)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-analysernode-interface/realtimeanalyser-fft-sizing-expected.txt	2020-08-03 15:51:42 UTC (rev 265196)
@@ -3,43 +3,43 @@
 PASS Executing "FFT size test" 
 PASS Audit report 
 PASS > [FFT size test] Test that re-sizing the FFT arrays does not fail. 
-PASS   Setting fftSize to -1 threw IndexSizeError: "The index is not in the allowed range.". 
-PASS   Setting fftSize to 0 threw IndexSizeError: "The index is not in the allowed range.". 
-PASS   Setting fftSize to 1 threw IndexSizeError: "The index is not in the allowed range.". 
-PASS   Setting fftSize to 2 threw IndexSizeError: "The index is not in the allowed range.". 
-PASS   Setting fftSize to 3 threw IndexSizeError: "The index is not in the allowed range.". 
-PASS   Setting fftSize to 4 threw IndexSizeError: "The index is not in the allowed range.". 
-PASS   Setting fftSize to 5 threw IndexSizeError: "The index is not in the allowed range.". 
-PASS   Setting fftSize to 8 threw IndexSizeError: "The index is not in the allowed range.". 
-PASS   Setting fftSize to 9 threw IndexSizeError: "The index is not in the allowed range.". 
-PASS   Setting fftSize to 16 threw IndexSizeError: "The index is not in the allowed range.". 
-PASS   Setting fftSize to 17 threw IndexSizeError: "The index is not in the allowed range.". 
+PASS   Setting fftSize to -1 threw IndexSizeError: "fftSize must be power of 2 in the range 32 to 32768.". 
+PASS   Setting fftSize to 0 threw IndexSizeError: "fftSize must be power of 2 in the range 32 to 32768.". 
+PASS   Setting fftSize to 1 threw IndexSizeError: "fftSize must be power of 2 in the range 32 to 32768.". 
+PASS   Setting fftSize to 2 threw IndexSizeError: "fftSize must be power of 2 in the range 32 to 32768.". 
+PASS   Setting fftSize to 3 threw IndexSizeError: "fftSize must be power of 2 in the range 32 to 32768.". 
+PASS   Setting fftSize to 4 threw IndexSizeError: "fftSize must be power of 2 in the range 32 to 32768.". 
+PASS   Setting fftSize to 5 threw IndexSizeError: "fftSize must be power of 2 in the range 32 to 32768.". 
+PASS   Setting fftSize to 8 threw IndexSizeError: "fftSize must be power of 2 in the range 32 to 32768.". 
+PASS   Setting fftSize to 9 threw IndexSizeError: "fftSize must be power of 2 in the range 32 to 32768.". 
+PASS   Setting fftSize to 16 threw IndexSizeError: "fftSize must be power of 2 in the range 32 to 32768.". 
+PASS   Setting fftSize to 17 threw IndexSizeError: "fftSize must be power of 2 in the range 32 to 32768.". 
 PASS   Setting fftSize to 32 did not throw an exception. 
-PASS   Setting fftSize to 33 threw IndexSizeError: "The index is not in the allowed range.". 
+PASS   Setting fftSize to 33 threw IndexSizeError: "fftSize must be power of 2 in the range 32 to 32768.". 
 PASS   Setting fftSize to 64 did not throw an exception. 
-PASS   Setting fftSize to 65 threw IndexSizeError: "The index is not in the allowed range.". 
+PASS   Setting fftSize to 65 threw IndexSizeError: "fftSize must be power of 2 in the range 32 to 32768.". 
 PASS   Setting fftSize to 128 did not throw an exception. 
-PASS   Setting fftSize to 129 threw IndexSizeError: "The index is not in the allowed range.". 
+PASS   Setting fftSize to 129 threw IndexSizeError: "fftSize must be power of 2 in the range 32 to 32768.". 
 PASS   Setting fftSize to 256 did not throw an exception. 
-PASS   Setting fftSize to 257 threw IndexSizeError: "The index is not in the allowed range.". 
+PASS   Setting fftSize to 257 threw IndexSizeError: "fftSize must be power of 2 in the range 32 to 32768.". 
 PASS   Setting fftSize to 512 did not throw an exception. 
-PASS   Setting fftSize to 513 threw IndexSizeError: "The index is not in the allowed range.". 
+PASS   Setting fftSize to 513 threw IndexSizeError: "fftSize must be power of 2 in the range 32 to 32768.". 
 PASS   Setting fftSize to 1024 did not throw an exception. 
-PASS   Setting fftSize to 1025 threw IndexSizeError: "The index is not in the allowed range.". 
+PASS   Setting fftSize to 1025 threw IndexSizeError: "fftSize must be power of 2 in the range 32 to 32768.". 
 PASS   Setting fftSize to 2048 did not throw an exception. 
-PASS   Setting fftSize to 2049 threw IndexSizeError: "The index is not in the allowed range.". 
+PASS   Setting fftSize to 2049 threw IndexSizeError: "fftSize must be power of 2 in the range 32 to 32768.". 
 PASS   Setting fftSize to 4096 did not throw an exception. 
-PASS   Setting fftSize to 4097 threw IndexSizeError: "The index is not in the allowed range.". 
+PASS   Setting fftSize to 4097 threw IndexSizeError: "fftSize must be power of 2 in the range 32 to 32768.". 
 PASS   Setting fftSize to 8192 did not throw an exception. 
-PASS   Setting fftSize to 8193 threw IndexSizeError: "The index is not in the allowed range.". 
+PASS   Setting fftSize to 8193 threw IndexSizeError: "fftSize must be power of 2 in the range 32 to 32768.". 
 PASS   Setting fftSize to 16384 did not throw an exception. 
-PASS   Setting fftSize to 16385 threw IndexSizeError: "The index is not in the allowed range.". 
+PASS   Setting fftSize to 16385 threw IndexSizeError: "fftSize must be power of 2 in the range 32 to 32768.". 
 PASS   Setting fftSize to 32768 did not throw an exception. 
-PASS   Setting fftSize to 32769 threw IndexSizeError: "The index is not in the allowed range.". 
-PASS   Setting fftSize to 65536 threw IndexSizeError: "The index is not in the allowed range.". 
-PASS   Setting fftSize to 65537 threw IndexSizeError: "The index is not in the allowed range.". 
-PASS   Setting fftSize to 131072 threw IndexSizeError: "The index is not in the allowed range.". 
-PASS   Setting fftSize to 131073 threw IndexSizeError: "The index is not in the allowed range.". 
+PASS   Setting fftSize to 32769 threw IndexSizeError: "fftSize must be power of 2 in the range 32 to 32768.". 
+PASS   Setting fftSize to 65536 threw IndexSizeError: "fftSize must be power of 2 in the range 32 to 32768.". 
+PASS   Setting fftSize to 65537 threw IndexSizeError: "fftSize must be power of 2 in the range 32 to 32768.". 
+PASS   Setting fftSize to 131072 threw IndexSizeError: "fftSize must be power of 2 in the range 32 to 32768.". 
+PASS   Setting fftSize to 131073 threw IndexSizeError: "fftSize must be power of 2 in the range 32 to 32768.". 
 PASS < [FFT size test] All assertions passed. (total 37 assertions) 
 PASS # AUDIT TASK RUNNER FINISHED: 1 tasks ran successfully. 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-analysernode-interface/test-analysernode-expected.txt (265195 => 265196)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-analysernode-interface/test-analysernode-expected.txt	2020-08-03 12:29:30 UTC (rev 265195)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webaudio/the-audio-api/the-analysernode-interface/test-analysernode-expected.txt	2020-08-03 15:51:42 UTC (rev 265196)
@@ -1,6 +1,4 @@
 
-FAIL Test AnalyserNode API assert_throws_dom: function "function () {
-        analyser.minDecibels = -30;
-      }" did not throw
-FAIL Test AnalyserNode's ctor API function is not a constructor (evaluating 'new AnalyserNode(context)')
+PASS Test AnalyserNode API 
+PASS Test AnalyserNode's ctor API 
 

Modified: trunk/LayoutTests/webaudio/analyser-exception-expected.txt (265195 => 265196)


--- trunk/LayoutTests/webaudio/analyser-exception-expected.txt	2020-08-03 12:29:30 UTC (rev 265195)
+++ trunk/LayoutTests/webaudio/analyser-exception-expected.txt	2020-08-03 15:51:42 UTC (rev 265196)
@@ -2,8 +2,8 @@
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
-PASS analyser.minDecibels = -20 threw exception IndexSizeError: The index is not in the allowed range..
-PASS analyser.maxDecibels = -120 threw exception IndexSizeError: The index is not in the allowed range..
+PASS analyser.minDecibels = -20 threw exception IndexSizeError: minDecibels must be less than maxDecibels..
+PASS analyser.maxDecibels = -120 threw exception IndexSizeError: maxDecibels must be greater than minDecibels..
 PASS analyser.smoothingTimeConstant = 2 threw exception IndexSizeError: The index is not in the allowed range..
 PASS successfullyParsed is true
 

Modified: trunk/Source/WebCore/CMakeLists.txt (265195 => 265196)


--- trunk/Source/WebCore/CMakeLists.txt	2020-08-03 12:29:30 UTC (rev 265195)
+++ trunk/Source/WebCore/CMakeLists.txt	2020-08-03 15:51:42 UTC (rev 265196)
@@ -446,6 +446,7 @@
     Modules/streams/WritableStream.idl
 
     Modules/webaudio/AnalyserNode.idl
+    Modules/webaudio/AnalyserOptions.idl
     Modules/webaudio/AudioBuffer.idl
     Modules/webaudio/AudioBufferCallback.idl
     Modules/webaudio/AudioBufferSourceNode.idl

Modified: trunk/Source/WebCore/ChangeLog (265195 => 265196)


--- trunk/Source/WebCore/ChangeLog	2020-08-03 12:29:30 UTC (rev 265195)
+++ trunk/Source/WebCore/ChangeLog	2020-08-03 15:51:42 UTC (rev 265196)
@@ -1,3 +1,35 @@
+2020-08-03  Clark Wang  <[email protected]>
+
+        Added Constructor to AnalyserNode
+        https://bugs.webkit.org/show_bug.cgi?id=215040
+
+        Reviewed by Chris Dumez.
+
+        Introduced AnalyserNode constructor and AnalyserOptions according to spec:
+        https://www.w3.org/TR/webaudio/#AnalyserNode-constructors.
+
+        Re-baselined existing tests.
+
+        * CMakeLists.txt:
+        * DerivedSources-input.xcfilelist:
+        * DerivedSources-output.xcfilelist:
+        * DerivedSources.make:
+        * Modules/webaudio/AnalyserNode.cpp:
+        (WebCore::AnalyserNode::create):
+        (WebCore::AnalyserNode::AnalyserNode):
+        (WebCore::AnalyserNode::setFftSize):
+        (WebCore::AnalyserNode::setMinMaxDecibels):
+        (WebCore::AnalyserNode::setMinDecibels):
+        (WebCore::AnalyserNode::setMaxDecibels):
+        * Modules/webaudio/AnalyserNode.h:
+        * Modules/webaudio/AnalyserNode.idl:
+        * Modules/webaudio/AnalyserOptions.h: Added.
+        * Modules/webaudio/AnalyserOptions.idl: Added.
+        * Modules/webaudio/BaseAudioContext.cpp:
+        (WebCore::BaseAudioContext::createAnalyser):
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+
 2020-08-03  Youenn Fablet  <[email protected]>
 
         MediaRecorderPrivateWriter::appendEndOfVideoSampleDurationIfNeeded should only call requestMediaDataWhenReadyOnQueue once

Modified: trunk/Source/WebCore/DerivedSources-input.xcfilelist (265195 => 265196)


--- trunk/Source/WebCore/DerivedSources-input.xcfilelist	2020-08-03 12:29:30 UTC (rev 265195)
+++ trunk/Source/WebCore/DerivedSources-input.xcfilelist	2020-08-03 15:51:42 UTC (rev 265196)
@@ -295,6 +295,7 @@
 $(PROJECT_DIR)/Modules/streams/WritableStream.js
 $(PROJECT_DIR)/Modules/streams/WritableStreamInternals.js
 $(PROJECT_DIR)/Modules/webaudio/AnalyserNode.idl
+$(PROJECT_DIR)/Modules/webaudio/AnalyserOptions.idl
 $(PROJECT_DIR)/Modules/webaudio/AudioBuffer.idl
 $(PROJECT_DIR)/Modules/webaudio/AudioBufferCallback.idl
 $(PROJECT_DIR)/Modules/webaudio/AudioBufferSourceNode.idl

Modified: trunk/Source/WebCore/DerivedSources-output.xcfilelist (265195 => 265196)


--- trunk/Source/WebCore/DerivedSources-output.xcfilelist	2020-08-03 12:29:30 UTC (rev 265195)
+++ trunk/Source/WebCore/DerivedSources-output.xcfilelist	2020-08-03 15:51:42 UTC (rev 265196)
@@ -53,6 +53,8 @@
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAesKeyParams.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAnalyserNode.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAnalyserNode.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAnalyserOptions.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAnalyserOptions.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAnimatable.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAnimatable.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSAnimationEffect.cpp

Modified: trunk/Source/WebCore/DerivedSources.make (265195 => 265196)


--- trunk/Source/WebCore/DerivedSources.make	2020-08-03 12:29:30 UTC (rev 265195)
+++ trunk/Source/WebCore/DerivedSources.make	2020-08-03 15:51:42 UTC (rev 265196)
@@ -378,6 +378,7 @@
     $(WebCore)/Modules/streams/ReadableStreamSource.idl \
     $(WebCore)/Modules/streams/WritableStream.idl \
     $(WebCore)/Modules/webaudio/AnalyserNode.idl \
+    $(WebCore)/Modules/webaudio/AnalyserOptions.idl \
     $(WebCore)/Modules/webaudio/AudioBuffer.idl \
     $(WebCore)/Modules/webaudio/AudioBufferCallback.idl \
     $(WebCore)/Modules/webaudio/AudioBufferSourceNode.idl \

Modified: trunk/Source/WebCore/Modules/webaudio/AnalyserNode.cpp (265195 => 265196)


--- trunk/Source/WebCore/Modules/webaudio/AnalyserNode.cpp	2020-08-03 12:29:30 UTC (rev 265195)
+++ trunk/Source/WebCore/Modules/webaudio/AnalyserNode.cpp	2020-08-03 15:51:42 UTC (rev 265196)
@@ -36,9 +36,45 @@
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(AnalyserNode);
 
-AnalyserNode::AnalyserNode(BaseAudioContext& context, float sampleRate)
-    : AudioBasicInspectorNode(context, sampleRate, 2)
+ExceptionOr<Ref<AnalyserNode>> AnalyserNode::create(BaseAudioContext& context, const AnalyserOptions& options)
 {
+    if (context.isStopped())
+        return Exception { InvalidStateError };
+
+    context.lazyInitialize();
+    
+    auto analyser = adoptRef(*new AnalyserNode(context));
+    
+    auto result = analyser->setChannelCount(options.channelCount.valueOr(2));
+    if (result.hasException())
+        return result.releaseException();
+    
+    result = analyser->setChannelCountMode(options.channelCountMode.valueOr(ChannelCountMode::Max));
+    if (result.hasException())
+        return result.releaseException();
+    
+    result = analyser->setChannelInterpretation(options.channelInterpretation.valueOr(ChannelInterpretation::Speakers));
+    if (result.hasException())
+        return result.releaseException();
+    
+    result = analyser->setMinMaxDecibels(options.minDecibels, options.maxDecibels);
+    if (result.hasException())
+        return result.releaseException();
+    
+    result = analyser->setFftSize(options.fftSize);
+    if (result.hasException())
+        return result.releaseException();
+
+    result = analyser->setSmoothingTimeConstant(options.smoothingTimeConstant);
+    if (result.hasException())
+        return result.releaseException();
+    
+    return analyser;
+}
+
+AnalyserNode::AnalyserNode(BaseAudioContext& context)
+    : AudioBasicInspectorNode(context, context.sampleRate(), 2)
+{
     setNodeType(NodeTypeAnalyser);
     
     initialize();
@@ -77,14 +113,24 @@
 ExceptionOr<void> AnalyserNode::setFftSize(unsigned size)
 {
     if (!m_analyser.setFftSize(size))
-        return Exception { IndexSizeError };
+        return Exception { IndexSizeError, "fftSize must be power of 2 in the range 32 to 32768."_s };
     return { };
 }
 
+ExceptionOr<void> AnalyserNode::setMinMaxDecibels(double minDecibels, double maxDecibels)
+{
+    if (maxDecibels <= minDecibels)
+        return Exception { IndexSizeError, "minDecibels must be less than maxDecibels."_s };
+    
+    m_analyser.setMinDecibels(minDecibels);
+    m_analyser.setMaxDecibels(maxDecibels);
+    return { };
+}
+
 ExceptionOr<void> AnalyserNode::setMinDecibels(double k)
 {
-    if (k > maxDecibels())
-        return Exception { IndexSizeError };
+    if (k >= maxDecibels())
+        return Exception { IndexSizeError, "minDecibels must be less than maxDecibels."_s };
 
     m_analyser.setMinDecibels(k);
     return { };
@@ -92,8 +138,8 @@
 
 ExceptionOr<void> AnalyserNode::setMaxDecibels(double k)
 {
-    if (k < minDecibels())
-        return Exception { IndexSizeError };
+    if (k <= minDecibels())
+        return Exception { IndexSizeError, "maxDecibels must be greater than minDecibels."_s };
 
     m_analyser.setMaxDecibels(k);
     return { };

Modified: trunk/Source/WebCore/Modules/webaudio/AnalyserNode.h (265195 => 265196)


--- trunk/Source/WebCore/Modules/webaudio/AnalyserNode.h	2020-08-03 12:29:30 UTC (rev 265195)
+++ trunk/Source/WebCore/Modules/webaudio/AnalyserNode.h	2020-08-03 15:51:42 UTC (rev 265196)
@@ -24,6 +24,7 @@
 
 #pragma once
 
+#include "AnalyserOptions.h"
 #include "AudioBasicInspectorNode.h"
 #include "RealtimeAnalyser.h"
 
@@ -32,10 +33,7 @@
 class AnalyserNode final : public AudioBasicInspectorNode {
     WTF_MAKE_ISO_ALLOCATED(AnalyserNode);
 public:
-    static Ref<AnalyserNode> create(BaseAudioContext& context, float sampleRate)
-    {
-        return adoptRef(*new AnalyserNode(context, sampleRate));
-    }
+    static ExceptionOr<Ref<AnalyserNode>> create(BaseAudioContext&, const AnalyserOptions& = { });
 
     virtual ~AnalyserNode();
 
@@ -44,6 +42,8 @@
 
     unsigned frequencyBinCount() const { return m_analyser.frequencyBinCount(); }
 
+    ExceptionOr<void> setMinMaxDecibels(double minDecibels, double maxDecibels);
+    
     ExceptionOr<void> setMinDecibels(double);
     double minDecibels() const { return m_analyser.minDecibels(); }
 
@@ -59,7 +59,7 @@
     void getByteTimeDomainData(const Ref<JSC::Uint8Array>& array) { m_analyser.getByteTimeDomainData(array.get()); }
 
 private:
-    AnalyserNode(BaseAudioContext&, float sampleRate);
+    AnalyserNode(BaseAudioContext&);
 
     void process(size_t framesToProcess) final;
     void reset() final;

Modified: trunk/Source/WebCore/Modules/webaudio/AnalyserNode.idl (265195 => 265196)


--- trunk/Source/WebCore/Modules/webaudio/AnalyserNode.idl	2020-08-03 12:29:30 UTC (rev 265195)
+++ trunk/Source/WebCore/Modules/webaudio/AnalyserNode.idl	2020-08-03 15:51:42 UTC (rev 265196)
@@ -26,6 +26,8 @@
     Conditional=WEB_AUDIO,
     JSGenerateToJSObject,
 ] interface AnalyserNode : AudioNode {
+    [MayThrowException, EnabledBySetting=ModernUnprefixedWebAudio] constructor (BaseAudioContext context, optional AnalyserOptions options);
+
     attribute unsigned long fftSize;
     readonly attribute unsigned long frequencyBinCount;
 

Added: trunk/Source/WebCore/Modules/webaudio/AnalyserOptions.h (0 => 265196)


--- trunk/Source/WebCore/Modules/webaudio/AnalyserOptions.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webaudio/AnalyserOptions.h	2020-08-03 15:51:42 UTC (rev 265196)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEB_AUDIO)
+
+#include "AudioNodeOptions.h"
+
+namespace WebCore {
+
+struct AnalyserOptions : AudioNodeOptions {
+    unsigned fftSize { 2048 };
+    double maxDecibels { -30 };
+    double minDecibels { -100 };
+    double smoothingTimeConstant { 0.8 };
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_AUDIO)

Added: trunk/Source/WebCore/Modules/webaudio/AnalyserOptions.idl (0 => 265196)


--- trunk/Source/WebCore/Modules/webaudio/AnalyserOptions.idl	                        (rev 0)
+++ trunk/Source/WebCore/Modules/webaudio/AnalyserOptions.idl	2020-08-03 15:51:42 UTC (rev 265196)
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+    Conditional=WEB_AUDIO,
+] dictionary AnalyserOptions : AudioNodeOptions {
+    unsigned long fftSize = 2048;
+    double maxDecibels = -30;
+    double minDecibels = -100;
+    double smoothingTimeConstant = 0.8;
+};

Modified: trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.cpp (265195 => 265196)


--- trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.cpp	2020-08-03 12:29:30 UTC (rev 265195)
+++ trunk/Source/WebCore/Modules/webaudio/BaseAudioContext.cpp	2020-08-03 15:51:42 UTC (rev 265196)
@@ -549,11 +549,7 @@
     ALWAYS_LOG(LOGIDENTIFIER);
     
     ASSERT(isMainThread());
-    if (m_isStopScheduled)
-        return Exception { InvalidStateError };
-
-    lazyInitialize();
-    return AnalyserNode::create(*this, sampleRate());
+    return AnalyserNode::create(*this);
 }
 
 ExceptionOr<Ref<GainNode>> BaseAudioContext::createGain()

Modified: trunk/Source/WebCore/Sources.txt (265195 => 265196)


--- trunk/Source/WebCore/Sources.txt	2020-08-03 12:29:30 UTC (rev 265195)
+++ trunk/Source/WebCore/Sources.txt	2020-08-03 15:51:42 UTC (rev 265196)
@@ -2621,6 +2621,7 @@
 JSAesGcmParams.cpp
 JSAesKeyParams.cpp
 JSAnalyserNode.cpp
+JSAnalyserOptions.cpp
 JSAnimationEffect.cpp
 JSAnimationEvent.cpp
 JSAnimationPlaybackEvent.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (265195 => 265196)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-08-03 12:29:30 UTC (rev 265195)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2020-08-03 15:51:42 UTC (rev 265196)
@@ -5076,6 +5076,7 @@
 		E785D96124B7F7350014DB21 /* AudioContextOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = E785D95F24B7F7340014DB21 /* AudioContextOptions.h */; };
 		E785D96224B7F7350014DB21 /* AudioContextLatencyCategory.h in Headers */ = {isa = PBXBuildFile; fileRef = E785D96024B7F7340014DB21 /* AudioContextLatencyCategory.h */; };
 		E7CF84A924C6461C00B06B90 /* OfflineAudioContextOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = E7CF84A524C635F400B06B90 /* OfflineAudioContextOptions.h */; };
+		E7E0357224D4E196008DFEFB /* AnalyserOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = E7E0357124D4E191008DFEFB /* AnalyserOptions.h */; };
 		EBE5B226245A26EF003A5A88 /* SQLiteStatementAutoResetScope.h in Headers */ = {isa = PBXBuildFile; fileRef = EBE5B224245A26EE003A5A88 /* SQLiteStatementAutoResetScope.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		EBF5121C1696496C0056BD25 /* JSTypeConversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EBF5121A1696496C0056BD25 /* JSTypeConversions.cpp */; };
 		EBF5121D1696496C0056BD25 /* JSTypeConversions.h in Headers */ = {isa = PBXBuildFile; fileRef = EBF5121B1696496C0056BD25 /* JSTypeConversions.h */; };
@@ -15896,6 +15897,8 @@
 		E7E0352224CF60ED008DFEFB /* ChannelMergerOptions.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = ChannelMergerOptions.idl; sourceTree = "<group>"; };
 		E7E0352424CF715E008DFEFB /* ChannelSplitterOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ChannelSplitterOptions.h; sourceTree = "<group>"; };
 		E7E0352524CF715E008DFEFB /* ChannelSplitterOptions.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = ChannelSplitterOptions.idl; sourceTree = "<group>"; };
+		E7E0356F24D4E190008DFEFB /* AnalyserOptions.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = AnalyserOptions.idl; sourceTree = "<group>"; };
+		E7E0357124D4E191008DFEFB /* AnalyserOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnalyserOptions.h; sourceTree = "<group>"; };
 		EB081CD81696084400553730 /* TypeConversions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TypeConversions.h; sourceTree = "<group>"; };
 		EB081CD91696084400553730 /* TypeConversions.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = TypeConversions.idl; sourceTree = "<group>"; };
 		EBE5B224245A26EE003A5A88 /* SQLiteStatementAutoResetScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SQLiteStatementAutoResetScope.h; sourceTree = "<group>"; };
@@ -29472,6 +29475,8 @@
 				FD315FF312B0267600C1A359 /* AnalyserNode.cpp */,
 				FD315FF412B0267600C1A359 /* AnalyserNode.h */,
 				FD315FF512B0267600C1A359 /* AnalyserNode.idl */,
+				E7E0357124D4E191008DFEFB /* AnalyserOptions.h */,
+				E7E0356F24D4E190008DFEFB /* AnalyserOptions.idl */,
 				FD5686C713AC180200B69C68 /* AsyncAudioDecoder.cpp */,
 				FD5686C813AC180200B69C68 /* AsyncAudioDecoder.h */,
 				FD629EA2154B47160006D026 /* AudioBasicInspectorNode.cpp */,
@@ -29949,6 +29954,7 @@
 				CE08C3D2152B599A0021B8C2 /* AlternativeTextController.h in Headers */,
 				CE7B2DB31586ABAD0098B3FA /* AlternativeTextUIController.h in Headers */,
 				FD31603E12B0267600C1A359 /* AnalyserNode.h in Headers */,
+				E7E0357224D4E196008DFEFB /* AnalyserOptions.h in Headers */,
 				31A795C71888BCB200382F90 /* ANGLEInstancedArrays.h in Headers */,
 				490707E71219C04300D90E51 /* ANGLEWebKitBridge.h in Headers */,
 				49E912AB0EFAC906009D0CAF /* Animation.h in Headers */,
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to