Bug 1457013 - In AudioBuffer return NOT_SUPPORTED error message for various cases to align with the spec. r?padenot draft
authorAlex Chronopoulos <achronop@gmail.com>
Thu, 26 Apr 2018 17:15:53 +0200
changeset 789110 678eec54aa9b31193aea8dc4a59a3bcd21363315
parent 789058 8a52ed4fdc284c84a4c418913ec05df1b8f5033a
child 789111 7feba3816fe4041d719a423da88012f8868f9837
push id108183
push userachronop@gmail.com
push dateFri, 27 Apr 2018 16:18:26 +0000
reviewerspadenot
bugs1457013
milestone61.0a1
Bug 1457013 - In AudioBuffer return NOT_SUPPORTED error message for various cases to align with the spec. r?padenot MozReview-Commit-ID: LdT7rwSK4D0
dom/media/webaudio/AudioBuffer.cpp
--- 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;
   }