4 <script src="../fast/js/resources/js-test-pre.js"></script>
5 <script src="resources/audio-testing.js"></script>
9 <div id="description"></div>
10 <div id="console"></div>
13 description("Basic tests for BiquadFilterNode.");
18 if (window.testRunner) {
19 testRunner.dumpAsText();
20 testRunner.waitUntilDone();
23 window.jsTestIsAsync = true;
25 context = new webkitAudioContext();
26 var filter = context.createBiquadFilter();
28 if (filter.numberOfInputs === 1)
29 testPassed("BiquadFilterNode has one input.");
31 testFailed("BiquadFilterNode should have one input.");
33 if (filter.numberOfOutputs === 1)
34 testPassed("BiquadFilterNode has one output.");
36 testFailed("BiquadFilterNode should have one output.");
38 if (filter.type === "lowpass")
39 testPassed("Biquad filter defaults to low-pass filter.");
41 testFailed("Biquad filter should default to low-pass filter.");
43 // Check that all legal filter types can be set.
44 var filterTypeArray = [{type: "lowpass", integerType: filter.LOWPASS},
45 {type: "highpass", integerType: filter.HIGHPASS},
46 {type: "bandpass", integerType: filter.BANDPASS},
47 {type: "lowshelf", integerType: filter.LOWSHELF},
48 {type: "highshelf", integerType: filter.HIGHSHELF},
49 {type: "peaking", integerType: filter.PEAKING},
50 {type: "notch", integerType: filter.NOTCH},
51 {type: "allpass", integerType: filter.ALLPASS}];
53 for (var i = 0; i < filterTypeArray.length; ++i) {
55 filter.type = filterTypeArray[i].type;
56 if (filter.type === filterTypeArray[i].type) {
57 var message = "Biquad filter type '" + filterTypeArray[i].type + "' is settable.";
60 var message = "Biquad filter type '" + filterTypeArray[i].type + "' was not correctly set.";
64 var message = "Biquad filter type " + i + " should not throw exception.";
69 // For legacy support, verify that we can set the type attribute as an integer value and
70 // verify that this translates correctly to the WebIDL enum value.
71 for (var i = 0; i < filterTypeArray.length; ++i) {
73 filter.type = filterTypeArray[i].integerType;
74 if (filter.type === filterTypeArray[i].type && filterTypeArray[i].integerType === i) {
75 var message = "Biquad filter type " + i + " is settable using legacy integer value.";
78 var message = "Biquad filter type " + i + " was not correctly set using legacy integer value.";
82 var message = "Biquad filter type " + i + " should not throw exception using legacy integer value.";
87 // Check that illegal filter type throws.
89 filter.type = filter.ALLPASS + 1;
90 testFailed("Illegal filter type should throw exception.");
92 testPassed("Illegal filter type correctly throws exception.");
95 // Check specifically that we throw a TypeError.
96 shouldThrowTypeError(function() { filter.type = "xyz12349jfksd"; }, "Setting .type to illegal string value");
97 shouldThrowTypeError(function() { filter.type = new Float32Array(1); }, "Setting .type to illegal type of Float32Array");
106 <script src="../fast/js/resources/js-test-post.js"></script>