Backed out 2 changesets (bug 1456271) for mda failures in dom/media/webaudio/test/test_periodicWave.html
authorMargareta Eliza Balazs <ebalazs@mozilla.com>
Mon, 16 Jul 2018 17:11:14 +0300
changeset 818995 2613d4453b1ffcc0fde21cd4a0ed0dab08dde553
parent 818994 b99bd412118184d8b8663bdac561b5679dba1b5f
child 818996 e40038281727001cf3da186e14a7fa8eb1e79f09
push id116413
push userbgrinstead@mozilla.com
push dateMon, 16 Jul 2018 22:40:17 +0000
bugs1456271
milestone63.0a1
backs outb99bd412118184d8b8663bdac561b5679dba1b5f
b37a0606d6a0fa4c397e9779c96f8ed879136a15
Backed out 2 changesets (bug 1456271) for mda failures in dom/media/webaudio/test/test_periodicWave.html Backed out changeset b99bd4121181 (bug 1456271) Backed out changeset b37a0606d6a0 (bug 1456271)
dom/media/webaudio/PeriodicWave.cpp
dom/webidl/PeriodicWave.webidl
testing/web-platform/meta/webaudio/idlharness.https.html.ini
--- a/dom/media/webaudio/PeriodicWave.cpp
+++ b/dom/media/webaudio/PeriodicWave.cpp
@@ -21,17 +21,17 @@ PeriodicWave::PeriodicWave(AudioContext*
                            const float* aImagData,
                            const uint32_t aLength,
                            const bool aDisableNormalization,
                            ErrorResult& aRv)
   : mContext(aContext)
   , mDisableNormalization(aDisableNormalization)
 {
   MOZ_ASSERT(aContext);
-  MOZ_ASSERT((aRealData || aImagData) || aLength == 2);
+  MOZ_ASSERT(aRealData || aImagData);
 
   // Caller should have checked this and thrown.
   MOZ_ASSERT(aLength > 0);
   mCoefficients.mDuration = aLength;
 
   // Copy coefficient data.
   // The SharedBuffer and two arrays share a single allocation.
   RefPtr<SharedBuffer> buffer =
@@ -39,67 +39,54 @@ PeriodicWave::PeriodicWave(AudioContext*
   if (!buffer) {
     aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
     return;
   }
 
   auto data = static_cast<float*>(buffer->Data());
   mCoefficients.mBuffer = std::move(buffer);
 
-  if (!aRealData && !aImagData) {
-    PodZero(data, aLength);
-    mCoefficients.mChannelData.AppendElement(data);
-    data += aLength;
-    data[0] = 0.0f;
-    data[1] = 1.0f;
-    mCoefficients.mChannelData.AppendElement(data);
+  if (aRealData) {
+    PodCopy(data, aRealData, aLength);
   } else {
-    if (aRealData) {
-      PodCopy(data, aRealData, aLength);
-    } else {
-      PodZero(data, aLength);
-    }
-    mCoefficients.mChannelData.AppendElement(data);
+    PodZero(data, aLength);
+  }
+  mCoefficients.mChannelData.AppendElement(data);
 
-    data += aLength;
-    if (aImagData) {
-      PodCopy(data, aImagData, aLength);
-    } else {
-      PodZero(data, aLength);
-    }
-    mCoefficients.mChannelData.AppendElement(data);
+  data += aLength;
+  if (aImagData) {
+    PodCopy(data, aImagData, aLength);
+  } else {
+    PodZero(data, aLength);
   }
+  mCoefficients.mChannelData.AppendElement(data);
+
   mCoefficients.mVolume = 1.0f;
   mCoefficients.mBufferFormat = AUDIO_FORMAT_FLOAT32;
 }
 
 /* static */ already_AddRefed<PeriodicWave>
 PeriodicWave::Constructor(const GlobalObject& aGlobal,
                           AudioContext& aAudioContext,
                           const PeriodicWaveOptions& aOptions,
                           ErrorResult& aRv)
 {
+  if (!aOptions.mReal.WasPassed() && !aOptions.mImag.WasPassed()) {
+    aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
+    return nullptr;
+  }
 
   if (aOptions.mReal.WasPassed() && aOptions.mImag.WasPassed() &&
       aOptions.mReal.Value().Length() != aOptions.mImag.Value().Length()) {
     aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
     return nullptr;
   }
 
-  uint32_t length = 0;
-  if (aOptions.mReal.WasPassed()) {
-    length = aOptions.mReal.Value().Length();
-  } else if (aOptions.mImag.WasPassed()) {
-    length = aOptions.mImag.Value().Length();
-  } else {
-    // If nothing has been passed, this PeriodicWave will be a sine wave: 2
-    // elements for each array, the second imaginary component set to 1.0.
-    length = 2;
-  }
-
+  uint32_t length =
+    aOptions.mReal.WasPassed() ? aOptions.mReal.Value().Length() : aOptions.mImag.Value().Length();
   if (length == 0) {
     aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
     return nullptr;
   }
 
   const float* realData =
     aOptions.mReal.WasPassed() ? aOptions.mReal.Value().Elements() : nullptr;
   const float* imagData =
--- a/dom/webidl/PeriodicWave.webidl
+++ b/dom/webidl/PeriodicWave.webidl
@@ -15,11 +15,14 @@ dictionary PeriodicWaveConstraints {
 };
 
 dictionary PeriodicWaveOptions : PeriodicWaveConstraints {
              sequence<float> real;
              sequence<float> imag;
 };
 
 [Pref="dom.webaudio.enabled",
+ // XXXbz The second arg is not optional in the spec, but that looks
+ // like a spec bug to me.  See
+ // <https://github.com/WebAudio/web-audio-api/issues/1116>.
  Constructor(BaseAudioContext context, optional PeriodicWaveOptions options)]
 interface PeriodicWave {
 };
--- a/testing/web-platform/meta/webaudio/idlharness.https.html.ini
+++ b/testing/web-platform/meta/webaudio/idlharness.https.html.ini
@@ -159,16 +159,22 @@
     expected: FAIL
 
   [MediaStreamTrackAudioSourceNode interface: existence and properties of interface prototype object's "constructor" property]
     expected: FAIL
 
   [MediaStreamTrackAudioSourceNode interface: existence and properties of interface prototype object's @@unscopables property]
     expected: FAIL
 
+  [PeriodicWave must be primary interface of new PeriodicWave(context)]
+    expected: FAIL
+
+  [Stringification of new PeriodicWave(context)]
+    expected: FAIL
+
   [AudioWorklet interface: existence and properties of interface object]
     expected: FAIL
 
   [AudioWorklet interface object length]
     expected: FAIL
 
   [AudioWorklet interface object name]
     expected: FAIL