bug 1184801 Test output of AnalyserNode with GainNode
authorKarl Tomlinson <karlt+@karlt.net>
Tue, 28 Jul 2015 11:03:31 +1200
changeset 287886 ca7db7d4382b329b41968e503cc9aad30bf02b4d
parent 287885 63646a4fb768fceaaac385d4cf00176b35daad66
child 287887 def7ba7179be24f99dcc7d5730566b727df8c11d
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1184801
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 1184801 Test output of AnalyserNode with GainNode
dom/media/webaudio/test/test_analyserNodeWithGain.html
--- a/dom/media/webaudio/test/test_analyserNodeWithGain.html
+++ b/dom/media/webaudio/test/test_analyserNodeWithGain.html
@@ -1,22 +1,24 @@
 <!DOCTYPE html>
 <title>Test effect of AnalyserNode on GainNode output</title>
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <script>
-async_test(function(t) {
-  // fftSize <= 128 so that the time domain data is full of input after
-  // notification that the first block has been processed.
+promise_test(function() {
+  // fftSize <= bufferSize so that the time domain data is full of input after
+  // processing the buffer.
   const fftSize = 32;
+  const bufferSize = 128;
 
-  var context = new AudioContext();
+  var context = new OfflineAudioContext(1, bufferSize, 48000);
 
   var analyser1 = context.createAnalyser();
   analyser1.fftSize = fftSize;
+  analyser1.connect(context.destination);
   var analyser2 = context.createAnalyser();
   analyser2.fftSize = fftSize;
 
   var gain = context.createGain();
   gain.gain.value = 2.0;
   gain.connect(analyser1);
   gain.connect(analyser2);
 
@@ -25,23 +27,21 @@ async_test(function(t) {
   var buffer = context.createBuffer(1, 1, context.sampleRate);
   buffer.getChannelData(0)[0] = 1.0 / gain.gain.value;
   var source = context.createBufferSource();
   source.buffer = buffer;
   source.loop = true;
   source.connect(gain);
   source.start();
 
-  // Waiting for an ended event ensures that the AnalyserNode has received the
-  // signal.
-  var timer = context.createBufferSource();
-  timer.buffer = buffer;
-  timer.onended = t.step_func_done(function() {
-    var data = new Float32Array(1);
-    analyser1.getFloatTimeDomainData(data);
-    assert_equals(data[0], 1.0, "analyser1 time domain data");
-    analyser2.getFloatTimeDomainData(data);
-    assert_equals(data[0], 1.0, "analyser2 time domain data");
-  });
+  return context.startRendering().
+    then(function(buffer) {
+      assert_equals(buffer.getChannelData(0)[0], 1.0,
+                    "analyser1 output");
 
-  timer.start()
+      var data = new Float32Array(1);
+      analyser1.getFloatTimeDomainData(data);
+      assert_equals(data[0], 1.0, "analyser1 time domain data");
+      analyser2.getFloatTimeDomainData(data);
+      assert_equals(data[0], 1.0, "analyser2 time domain data");
+    });
 });
 </script>