зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1265408 - Add webplatform-test for IIRFilterNode; r=padenot
MozReview-Commit-ID: qSDxvk60j2 --HG-- extra : rebase_source : 548dbfbade6e87722dca06d718fad692ddeaa8f0
This commit is contained in:
Родитель
c846a288b4
Коммит
c28c49d148
|
@ -36041,6 +36041,12 @@
|
|||
"path": "web-animations/timing-model/animations/set-the-timeline-of-an-animation.html",
|
||||
"url": "/web-animations/timing-model/animations/set-the-timeline-of-an-animation.html"
|
||||
}
|
||||
],
|
||||
"webaudio/the-audio-api/the-iirfilternode-interface/test-iirfilternode.html": [
|
||||
{
|
||||
"path": "webaudio/the-audio-api/the-iirfilternode-interface/test-iirfilternode.html",
|
||||
"url": "/webaudio/the-audio-api/the-iirfilternode-interface/test-iirfilternode.html"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>Test the IIRFilterNode Interface</title>
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script>
|
||||
test(function(t) {
|
||||
var ac = new AudioContext();
|
||||
|
||||
function check_args(arg1, arg2, err, desc) {
|
||||
test(function() {
|
||||
assert_throws(err, function() {
|
||||
ac.createIIRFilter(arg1, arg2)
|
||||
})
|
||||
}, desc)
|
||||
}
|
||||
|
||||
check_args([], [1.0], 'NotSupportedError',
|
||||
'feedforward coefficients can not be empty');
|
||||
|
||||
check_args([1.0], [], 'NotSupportedError',
|
||||
'feedback coefficients can not be empty');
|
||||
|
||||
var coeff = new Float32Array(21)
|
||||
coeff[0] = 1.0;
|
||||
|
||||
check_args(coeff, [1.0], 'NotSupportedError',
|
||||
'more than 20 feedforward coefficients can not be used');
|
||||
|
||||
check_args([1.0], coeff, 'NotSupportedError',
|
||||
'more than 20 feedback coefficients can not be used');
|
||||
|
||||
check_args([0.0, 0.0], [1.0], 'InvalidStateError',
|
||||
'at least one feedforward coefficient must be non-zero');
|
||||
|
||||
check_args([0.5, 0.5], [0.0], 'InvalidStateError',
|
||||
'the first feedback coefficient must be non-zero');
|
||||
|
||||
}, "IIRFilterNode coefficients are checked properly");
|
||||
|
||||
test(function(t) {
|
||||
var ac = new AudioContext();
|
||||
|
||||
var frequencies = new Float32Array([-1.0, ac.sampleRate*0.5 - 1.0, ac.sampleRate]);
|
||||
var magResults = new Float32Array(3);
|
||||
var phaseResults = new Float32Array(3);
|
||||
|
||||
var filter = ac.createIIRFilter([0.5, 0.5], [1.0]);
|
||||
filter.getFrequencyResponse(frequencies, magResults, phaseResults);
|
||||
|
||||
assert_true(isNaN(magResults[0]), "Invalid input frequency should give NaN magnitude response");
|
||||
assert_true(!isNaN(magResults[1]), "Valid input frequency should not give NaN magnitude response");
|
||||
assert_true(isNaN(magResults[2]), "Invalid input frequency should give NaN magnitude response");
|
||||
assert_true(isNaN(phaseResults[0]), "Invalid input frequency should give NaN phase response");
|
||||
assert_true(!isNaN(phaseResults[1]), "Valid input frequency should not give NaN phase response");
|
||||
assert_true(isNaN(phaseResults[2]), "Invalid input frequency should give NaN phase response");
|
||||
|
||||
}, "IIRFilterNode getFrequencyResponse handles invalid frequencies properly");
|
||||
</script>
|
Загрузка…
Ссылка в новой задаче