blob: f9b1e8458b496a44d886a198e4790838f1e2e9ea [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="../fast/js/resources/js-test-style.css"/>
<script src="resources/audio-testing.js"></script>
<script src="../fast/js/resources/js-test-pre.js"></script>
<script src="resources/biquad-testing.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description("Tests DOM exception messages");
var context;
var otherContext;
var node;
var node2;
var mode;
function runTest() {
if (window.testRunner) {
testRunner.dumpAsText();
}
context = new webkitAudioContext();
otherContext = new webkitAudioContext();
// Test creation of various objects
// Invalid number of channels: NotSupportedError
shouldThrow("context.createBuffer(99, 1, context.sampleRate)");
// Invalid sample rate: NotSupportedError
shouldThrow("context.createBuffer(1, 1, 1)");
shouldThrow("context.createBuffer(1, 1, 1e6)");
// Invalid number of frames: NotSupportedError
shouldThrow("context.createBuffer(1, 0, context.sampleRate)");
// Invalid ArrayBuffer (unspecified error)
shouldThrow("context.createBuffer(new ArrayBuffer(100), true)");
// Invalid ArrayBuffer (unspecified error)
shouldThrow("context.decodeAudioData(null, function() {}, function () {})");
// Invalid sources (unspecified error)
shouldThrow("context.createMediaElementSource(null)");
shouldThrow("context.createMediaStreamSource(null)");
// Invalid buffer size: IndexSizeError
shouldThrow("context.createScriptProcessor(1, 1, 1)");
// Invalid number of inputs and outputs: IndexSizeError
shouldThrow("context.createScriptProcessor(4096, 100, 1)");
shouldThrow("context.createScriptProcessor(4096, 1, 100)");
shouldNotThrow("context.createScriptProcessor()");
shouldNotThrow("context.createScriptProcessor(0)");
// Invalid number of channels: IndexSizeError
shouldThrow("context.createChannelSplitter(0)");
shouldThrow("context.createChannelSplitter(99)");
shouldThrow("context.createChannelMerger(0)");
shouldThrow("context.createChannelMerger(99)");
// Invalid real/imag arrays: IndexSizeError
shouldThrow("context.createPeriodicWave(null, null)");
shouldThrow("context.createPeriodicWave(new Float32Array(10), null)");
shouldThrow("context.createPeriodicWave(new Float32Array(4100), new Float32Array(4100))");
// Real and imaginary arrays must have the same size: IndexSizeError
shouldThrow("context.createPeriodicWave(new Float32Array(10), new Float32Array(7))");
// Analysers
node = context.createAnalyser();
// Invalid fftSize: IndexSizeError
shouldThrow("node.fftSize = 42");
shouldThrow("node.fftSize = 16");
shouldThrow("node.fftSize = 4096");
shouldThrow("node.minDecibels = -10");
shouldThrow("node.maxDecibels = -150");
shouldThrow("node.smoothingTimeConstant = -0.1");
shouldThrow("node.smoothingTimeConstant = 1.5");
// AudioBuffers
node = context.createBuffer(1,1, context.sampleRate);
// Invalid channel index: IndexSizeError
shouldThrow("node.getChannelData(2)");
// AudioNode connections
node = context.createGain();
node2 = context.createGain();
// Invalid destination node (unspecified error)
shouldThrow("node.connect(null, 0, 0)");
// Invalid input or output index: IndexSizeError
shouldThrow("node.connect(context.destination, 100, 0)");
shouldThrow("node.connect(context.destination, 0, 100)");
shouldThrow("node.connect(node2.gain, 100)");
shouldThrow("node.disconnect(99)");
// Can't connect to a different context (unspecified error)
shouldThrow("node.connect(otherContext.destination)");
// Invalid channel count: NotSupportedError
shouldThrow("node.channelCount = 99");
// Invalid mode or interpretation (unspecified error)
mode = "fancy";
shouldThrow("node.channelCountMode = mode");
shouldThrow("node.channelInterpretation = mode");
// Destination: IndexSizeError
shouldThrow("context.destination.channelCount = 99");
// Delay nodes are tested elsewhere, so don't duplicate that work here.
// OfflineAudioContext
// Invalid number of channels (unspecified error)
shouldThrow("new webkitOfflineAudioContext(99, 100, context.sampleRate)");
// Invalid sample rate. (unspecified error)
shouldThrow("new webkitOfflineAudioContext(1, 100, 1)");
shouldThrow("new webkitOfflineAudioContext(1, 100, 1e6)");
// WaveShaper types
node = context.createWaveShaper();
shouldThrow("node.oversample = '9x'");
// Start/stop for AudioBufferSourceNodes
buffer = context.createBuffer(1,1, context.sampleRate);
shouldNotThrow("source = context.createBufferSource()");
shouldNotThrow("source.buffer = buffer");
shouldNotThrow("source.start()");
shouldNotThrow("source.stop()");
// It's valid to start a source that has no associated buffer.
shouldNotThrow("source = context.createBufferSource()");
shouldNotThrow("source.start()");
shouldNotThrow("source.stop()");
// Start/stop for OscillatorNodes
shouldNotThrow("source = context.createOscillator()");
shouldNotThrow("source.start()");
shouldNotThrow("source.stop()");
}
runTest();
successfullyParsed = true;
</script>
<script src="../fast/js/resources/js-test-post.js"></script>
</body>
</html>