# HG changeset patch # User Paul Adenot # Date 1484736850 -3600 # Wed Jan 18 11:54:10 2017 +0100 # Node ID d7f07762a7e4578f4190eb500c75fd13b0ce291f # Parent d8fe4d4f40d98dda4985171b6ce5e3a7f61c494c Bug 1320705 - Add a test to check that decoding an Opus file does to produce a long tail. r?jya MozReview-Commit-ID: B4IlW1cWYlX diff --git a/dom/media/webaudio/test/mochitest.ini b/dom/media/webaudio/test/mochitest.ini --- a/dom/media/webaudio/test/mochitest.ini +++ b/dom/media/webaudio/test/mochitest.ini @@ -23,16 +23,17 @@ support-files = ting-48k-1ch.ogg ting-48k-2ch.ogg ting-44.1k-1ch.wav ting-44.1k-2ch.wav ting-48k-1ch.wav ting-48k-2ch.wav webaudio.js + [test_analyserNode.html] [test_analyserScale.html] [test_analyserNodeOutput.html] [test_analyserNodePassThrough.html] [test_analyserNodeWithGain.html] [test_AudioBuffer.html] [test_audioBufferSourceNode.html] [test_audioBufferSourceNodeEnded.html] @@ -107,16 +108,17 @@ skip-if = (android_version == '18' && de [test_convolverNodeChannelCount.html] [test_convolverNodeDelay.html] [test_convolverNodeFiniteInfluence.html] [test_convolverNodePassThrough.html] [test_convolverNodeWithGain.html] [test_currentTime.html] [test_decodeMultichannel.html] [test_decodeAudioDataPromise.html] +[test_decodeOpusTail.html] [test_delayNode.html] [test_delayNodeAtMax.html] [test_delayNodeChannelChanges.html] skip-if = toolkit == 'android' # bug 1056706 [test_delayNodeCycles.html] [test_delayNodePassThrough.html] [test_delayNodeSmallMaxDelay.html] [test_delayNodeTailIncrease.html] diff --git a/dom/media/webaudio/test/test_mediaElementAudioSourceNodeFidelity.html b/dom/media/webaudio/test/test_mediaElementAudioSourceNodeFidelity.html --- a/dom/media/webaudio/test/test_mediaElementAudioSourceNodeFidelity.html +++ b/dom/media/webaudio/test/test_mediaElementAudioSourceNodeFidelity.html @@ -1,41 +1,21 @@ Test MediaStreamAudioSourceNode doesn't get data from cross-origin media resources +
 
diff --git a/dom/media/webaudio/test/webaudio.js b/dom/media/webaudio/test/webaudio.js
--- a/dom/media/webaudio/test/webaudio.js
+++ b/dom/media/webaudio/test/webaudio.js
@@ -262,8 +262,38 @@ function runTest()
   };
 
   if (document.readyState !== 'complete') {
     addLoadEvent(runTestFunction);
   } else {
     runTestFunction();
   }
 }
+
+// Get an Opus file containing a sine wave at maximum amplitude, of duration
+// `lengthSeconds`, and of frequency `frequency`.
+function getSineWaveFile(frequency, lengthSeconds, callback) {
+  console.log("1\n");
+  SpecialPowers.pushPrefEnv(
+    {'set': [['media.recorder.audio_node.enabled', true]]},
+    function() {
+      console.log("2\n");
+      var chunks = [];
+      var off = new OfflineAudioContext(1, lengthSeconds * 48000, 48000);
+      var osc = off.createOscillator();
+      var rec = new MediaRecorder(osc);
+      rec.ondataavailable = function(e) {
+        chunks.push(e.data);
+      console.log("3\n");
+      };
+      rec.onstop = function(e) {
+        var blob = new Blob(chunks, { 'type' : 'audio/ogg; codecs=opus' });
+        console.log("4\n");
+        callback(blob);
+      }
+      osc.frequency.value = 1.0;
+      osc.start();
+      rec.start();
+      off.startRendering().then(function(buffer) {
+        rec.stop();
+    });
+  });
+}