Throw errors when changing channelCount and channelCountMode for ScriptProcessors
The channelCount and channelCountMode for a ScriptProcessor node
cannot be changed after creation. Thus, throw errors if the
the user tries to change channelCount to a different value or tries to
change channelCountMode to something other than 'explicit'.
Also fixes a bug that creation of a ScriptProcessor did not set
channelCount to the number of input channels and the channelCountMode
to 'explicit'.
See https://github.com/WebAudio/web-audio-api/issues/357
Tests added.
BUG=418224
Review URL: https://codereview.chromium.org/605403002
git-svn-id: svn://svn.chromium.org/blink/trunk@182870 bbb929c8-8fbe-4397-9dbb-9b2b20218538
diff --git a/third_party/WebKit/LayoutTests/webaudio/dom-exceptions.html b/third_party/WebKit/LayoutTests/webaudio/dom-exceptions.html
index a23b3c3..ba43ba31 100644
--- a/third_party/WebKit/LayoutTests/webaudio/dom-exceptions.html
+++ b/third_party/WebKit/LayoutTests/webaudio/dom-exceptions.html
@@ -20,6 +20,7 @@
var node2;
var mode;
var panner;
+var script;
function runTest() {
if (window.testRunner) {
@@ -233,6 +234,20 @@
shouldNotThrow("panner.channelCountMode = 'explicit'");
shouldNotThrow("panner.channelCountMode = 'clamped-max'");
shouldNotThrow("panner.channelCountMode = 'junk'");
+
+ // Test channel count and mode for a ScriptProcessor.
+ shouldNotThrow("script = context.createScriptProcessor(256, 3)");
+ // Make sure the channelCount and mode are set correctly.
+ shouldBeEqualToNumber("script.channelCount", 3);
+ shouldBeEqualToString("script.channelCountMode", "explicit");
+ // Cannot change the channelCount or mode to anything else
+ shouldNotThrow("script.channelCount = 3");
+ shouldThrow("script.channelCount = 1");
+ shouldThrow("script.channelCount = 7");
+ shouldNotThrow("script.channelCountMode = 'explicit'");
+ shouldThrow("script.channelCountMode = 'max'");
+ shouldThrow("script.channelCountMode = 'clamped-max'");
+ shouldNotThrow("script.channelCountMode = 'junk'");
}
runTest();