Bug 949474 - Reflect the fact that the nominal range for the sampleRate argument of the AudioContext.createBuffer changed in the spec. r=ehsan

This commit is contained in:
Paul Adenot 2013-12-12 16:05:31 +01:00
parent e8916602ba
commit 74caf2eca4
2 changed files with 13 additions and 7 deletions

View File

@ -174,8 +174,8 @@ AudioContext::CreateBuffer(JSContext* aJSContext, uint32_t aNumberOfChannels,
uint32_t aLength, float aSampleRate, uint32_t aLength, float aSampleRate,
ErrorResult& aRv) ErrorResult& aRv)
{ {
if (aSampleRate < 8000 || aSampleRate > 96000 || !aLength) { if (aSampleRate < 8000 || aSampleRate > 192000 || !aLength || !aNumberOfChannels) {
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR); aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
return nullptr; return nullptr;
} }

View File

@ -81,15 +81,21 @@ addLoadEvent(function() {
expectException(function() { expectException(function() {
context.createBuffer(2, 2048, 7999); context.createBuffer(2, 2048, 7999);
}, DOMException.NOT_SUPPORTED_ERR); }, DOMException.INDEX_SIZE_ERR);
expectException(function() { expectException(function() {
context.createBuffer(2, 2048, 96001); context.createBuffer(2, 2048, 192001);
}, DOMException.NOT_SUPPORTED_ERR); }, DOMException.INDEX_SIZE_ERR);
context.createBuffer(2, 2048, 8000); // no exception context.createBuffer(2, 2048, 8000); // no exception
context.createBuffer(2, 2048, 96000); // no exception context.createBuffer(2, 2048, 192000); // no exception
context.createBuffer(32, 2048, 48000); // no exception
// Null length
expectException(function() { expectException(function() {
context.createBuffer(2, 0, 48000); context.createBuffer(2, 0, 48000);
}, DOMException.NOT_SUPPORTED_ERR); }, DOMException.INDEX_SIZE_ERR);
// Null number of channels
expectException(function() {
context.createBuffer(0, 2048, 48000);
}, DOMException.INDEX_SIZE_ERR);
SimpleTest.finish(); SimpleTest.finish();
}); });