Bug 1203616 - Test that waveshaper nodes don't corrupt their input buffer. r=karlt
authorPaul Adenot <paul@paul.cx>
Thu, 08 Oct 2015 11:16:31 +0200
changeset 266841 240a3f4f4346e547802b4c264cf4ed1d1be8bf6c
parent 266840 a61652a27e8cc83682b24a9f920df0955b4720b4
child 266842 63a841b9c2643493be1915b8272d2315fc6a097b
push id29499
push userkwierso@gmail.com
push dateThu, 08 Oct 2015 21:29:10 +0000
treeherdermozilla-central@46da59584acb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs1203616
milestone44.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 1203616 - Test that waveshaper nodes don't corrupt their input buffer. r=karlt
dom/media/webaudio/test/mochitest.ini
dom/media/webaudio/test/test_waveShaperGain.html
--- a/dom/media/webaudio/test/mochitest.ini
+++ b/dom/media/webaudio/test/mochitest.ini
@@ -167,11 +167,12 @@ skip-if = (toolkit == 'gonk' && !debug) 
 [test_scriptProcessorNodePassThrough.html]
 [test_scriptProcessorNode_playbackTime1.html]
 [test_scriptProcessorNodeZeroInputOutput.html]
 [test_scriptProcessorNodeNotConnected.html]
 [test_singleSourceDest.html]
 [test_stereoPanningWithGain.html]
 [test_waveDecoder.html]
 [test_waveShaper.html]
+[test_waveShaperGain.html]
 [test_waveShaperNoCurve.html]
 [test_waveShaperPassThrough.html]
 [test_waveShaperInvalidLengthCurve.html]
new file mode 100644
--- /dev/null
+++ b/dom/media/webaudio/test/test_waveShaperGain.html
@@ -0,0 +1,51 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<meta charset="utf-8">
+  <title>Test that WaveShaperNode doesn't corrupt its inputs when the gain is !=
+    1.0 (bug 1203616)</title>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<script class="testbody" type="text/javascript">
+SimpleTest.waitForExplicitFinish();
+var samplerate = 44100;
+var context = new OfflineAudioContext(1, 44100, samplerate);
+
+var dc = context.createBufferSource();
+
+var buffer = context.createBuffer(1, 1, samplerate);
+buffer.getChannelData(0)[0] = 1.0;
+dc.buffer = buffer;
+
+var gain = context.createGain();
+var ws2 = context.createWaveShaper();
+var ws = [];
+
+// No-op waveshaper curves.
+for (var i = 0; i < 2; i++) {
+  ws[i] = context.createWaveShaper();
+  var curve = new Float32Array(2);
+  curve[0] = -1.0;
+  curve[1] = 1.0;
+  ws[i].curve = curve;
+  ws[i].connect(context.destination);
+  gain.connect(ws[i]);
+}
+
+dc.connect(gain);
+dc.start();
+
+gain.gain.value = 0.5;
+
+context.startRendering().then(buffer => {
+  document.querySelector("pre").innerHTML = buffer.getChannelData(0)[0];
+  ok(buffer.getChannelData(0)[0] == 1.0, "Volume was handled properly");
+  SimpleTest.finish();
+});
+</script>
+<pre>
+</pre>
+</body>
+