Bug 1457013 - In AudioBuffer return NOT_SUPPORTED error message for various cases to align with the spec. r?padenot
MozReview-Commit-ID: LdT7rwSK4D0
--- a/dom/media/webaudio/AudioBuffer.cpp
+++ b/dom/media/webaudio/AudioBuffer.cpp
@@ -166,17 +166,17 @@ AudioBuffer::AudioBuffer(nsPIDOMWindowIn
{
// Note that a buffer with zero channels is permitted here for the sake of
// AudioProcessingEvent, where channel counts must match parameters passed
// to createScriptProcessor(), one of which may be zero.
if (aSampleRate < WebAudioUtils::MinSampleRate ||
aSampleRate > WebAudioUtils::MaxSampleRate ||
aNumberOfChannels > WebAudioUtils::MaxChannelCount ||
!aLength || aLength > INT32_MAX) {
- aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
+ aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
return;
}
mSharedChannels.mDuration = aLength;
mJSChannels.SetLength(aNumberOfChannels);
mozilla::HoldJSObjects(this);
AudioBufferMemoryTracker::RegisterAudioBuffer(this);
}
@@ -189,17 +189,17 @@ AudioBuffer::~AudioBuffer()
}
/* static */ already_AddRefed<AudioBuffer>
AudioBuffer::Constructor(const GlobalObject& aGlobal,
const AudioBufferOptions& aOptions,
ErrorResult& aRv)
{
if (!aOptions.mNumberOfChannels) {
- aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
+ aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
return nullptr;
}
nsCOMPtr<nsPIDOMWindowInner> window =
do_QueryInterface(aGlobal.GetAsSupports());
return Create(window, aOptions.mNumberOfChannels, aOptions.mLength,
aOptions.mSampleRate, aRv);
@@ -326,17 +326,17 @@ AudioBuffer::CopyFromChannel(const Float
{
aDestination.ComputeLengthAndData();
uint32_t length = aDestination.Length();
CheckedInt<uint32_t> end = aStartInChannel;
end += length;
if (aChannelNumber >= NumberOfChannels() ||
!end.isValid() || end.value() > Length()) {
- aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
+ aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
return;
}
JS::AutoCheckCannotGC nogc;
JSObject* channelArray = mJSChannels[aChannelNumber];
if (channelArray) {
if (JS_GetTypedArrayLength(channelArray) != Length()) {
// The array's buffer was detached.
@@ -370,17 +370,17 @@ AudioBuffer::CopyToChannel(JSContext* aJ
{
aSource.ComputeLengthAndData();
uint32_t length = aSource.Length();
CheckedInt<uint32_t> end = aStartInChannel;
end += length;
if (aChannelNumber >= NumberOfChannels() ||
!end.isValid() || end.value() > Length()) {
- aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
+ aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
return;
}
if (!RestoreJSChannelData(aJSContext)) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return;
}
@@ -401,17 +401,17 @@ AudioBuffer::CopyToChannel(JSContext* aJ
}
void
AudioBuffer::GetChannelData(JSContext* aJSContext, uint32_t aChannel,
JS::MutableHandle<JSObject*> aRetval,
ErrorResult& aRv)
{
if (aChannel >= NumberOfChannels()) {
- aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
+ aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
return;
}
if (!RestoreJSChannelData(aJSContext)) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return;
}