blob: 37c28ceb43d6139e988c779037e69105fc442aaf [file] [log] [blame]
[email protected]2da6ffa2013-10-01 00:31:351<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html>
3<head>
4<link rel="stylesheet" href="../fast/js/resources/js-test-style.css"/>
5<script src="resources/audio-testing.js"></script>
6<script src="../fast/js/resources/js-test-pre.js"></script>
7<script src="resources/biquad-testing.js"></script>
8</head>
9
10<body>
11
12<div id="description"></div>
13<div id="console"></div>
14<script>
15description("Tests DOM exception messages");
16
17var context;
18var otherContext;
19var node;
20var node2;
21var mode;
22
23function runTest() {
24 if (window.testRunner) {
25 testRunner.dumpAsText();
26 }
27
28 context = new webkitAudioContext();
29 otherContext = new webkitAudioContext();
30
31 // Test createion of various objects
32
33 // Invalid number of channels
34 shouldThrow("context.createBuffer(99, 1, context.sampleRate)");
35 // Invalid sample rate
36 shouldThrow("context.createBuffer(1, 1, 1)");
37 shouldThrow("context.createBuffer(1, 1, 1e6)");
38 // Invalid ArrayBuffer
39 shouldThrow("context.createBuffer(new ArrayBuffer(100), true)");
40 // Invalid ArrayBuffer
41 shouldThrow("context.decodeAudioData(null, function() {}, function () {})");
42 // Invalid sources
43 shouldThrow("context.createMediaElementSource(null)");
44 shouldThrow("context.createMediaStreamSource(null)");
45 // Invalid buffer size
46 shouldThrow("context.createScriptProcessor(1, 1, 1)");
47 // Invalid number of inputs and outputs
48 shouldThrow("context.createScriptProcessor(4096, 100, 1)");
49 shouldThrow("context.createScriptProcessor(4096, 1, 100)");
[email protected]ad2e0e32013-10-04 05:16:2050 shouldNotThrow("context.createScriptProcessor()");
51 shouldNotThrow("context.createScriptProcessor(0)");
52
[email protected]2da6ffa2013-10-01 00:31:3553 // Invalid number of channels
54 shouldThrow("context.createChannelSplitter(0)");
55 shouldThrow("context.createChannelSplitter(99)");
56 shouldThrow("context.createChannelMerger(0)");
57 shouldThrow("context.createChannelMerger(99)");
58 // Invalid real/imag arrays
59 shouldThrow("context.createPeriodicWave(null, null)");
60 shouldThrow("context.createPeriodicWave(new Float32Array(10), null)");
61 // Real and imaginary arrays must have the same size
62 shouldThrow("context.createPeriodicWave(new Float32Array(10), new Float32Array(7))");
63
64 // Analysers
65 node = context.createAnalyser();
66 // Invalid fftSize
67 shouldThrow("node.fftSize = 42");
68
[email protected]db30267b2013-10-03 18:43:2669 shouldThrow("node.minDecibels = -10");
70 shouldThrow("node.maxDecibels = -150");
71 shouldThrow("node.smoothingTimeConstant = -0.1");
72 shouldThrow("node.smoothingTimeConstant = 1.5");
73
[email protected]2da6ffa2013-10-01 00:31:3574 // AudioBuffers
75 node = context.createBuffer(1,1, context.sampleRate);
76 // Invalid channel index
77 shouldThrow("node.getChannelData(2)");
78
79 // AudioNode connections
80 node = context.createGain();
81 node2 = context.createGain();
82 // Invalid destination node
83 shouldThrow("node.connect(null, 0, 0)");
84 // Invalid input or output index
85 shouldThrow("node.connect(context.destination, 100, 0)");
86 shouldThrow("node.connect(context.destination, 0, 100)");
87 shouldThrow("node.connect(node2.gain, 100)");
88 shouldThrow("node.disconnect(99)");
89 // Can't connect to a different context
90 shouldThrow("node.connect(otherContext.destination)");
91
92 // Invalid channel count
93 shouldThrow("node.channelCount = 99");
94 // Invalid mode or interpretation
95 mode = "fancy";
96 shouldThrow("node.channelCountMode = mode");
97 shouldThrow("node.channelInterpretation = mode");
98
99 // Destination
100 shouldThrow("context.destination.channelCount = 99");
101
102 // Delay nodes are tested elsewhere, so don't duplicate that work here.
103
104 // OfflineAudioContext
105 // Invalid number of channels
106 shouldThrow("new webkitOfflineAudioContext(99, 100, context.sampleRate)");
107 // Invalid sample rate.
108 shouldThrow("new webkitOfflineAudioContext(1, 100, 1)");
109 shouldThrow("new webkitOfflineAudioContext(1, 100, 1e6)");
110
[email protected]4e10d032013-10-02 21:48:00111 // WaveShaper types
112 node = context.createWaveShaper();
113 shouldThrow("node.oversample = '9x'");
[email protected]2da6ffa2013-10-01 00:31:35114}
115
116runTest();
117successfullyParsed = true;
118
119</script>
120<script src="../fast/js/resources/js-test-post.js"></script>
121</body>
122</html>