Bug 1203616 - Test that waveshaper nodes don't corrupt their input buffer. r=karlt

This commit is contained in:
Paul Adenot 2015-10-08 11:16:31 +02:00
parent a65bb299b6
commit 7de0462cdc
2 changed files with 52 additions and 0 deletions

View File

@ -172,6 +172,7 @@ skip-if = (toolkit == 'gonk' && !debug) || android_version == '10' || android_ve
[test_stereoPanningWithGain.html]
[test_waveDecoder.html]
[test_waveShaper.html]
[test_waveShaperGain.html]
[test_waveShaperNoCurve.html]
[test_waveShaperPassThrough.html]
[test_waveShaperInvalidLengthCurve.html]

View File

@ -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>