diff --git a/content/media/webaudio/test/test_scriptProcessorNode.html b/content/media/webaudio/test/test_scriptProcessorNode.html index e1fb82ab01d..6982ae36c94 100644 --- a/content/media/webaudio/test/test_scriptProcessorNode.html +++ b/content/media/webaudio/test/test_scriptProcessorNode.html @@ -96,11 +96,12 @@ addLoadEvent(function() { is(e.outputBuffer.sampleRate, context.sampleRate, "Correct sample rate for the output buffer"); var firstNonZero = findFirstNonZeroSample(e.inputBuffer); + ok(firstNonZero <= 2048, "First non-zero sample within range"); - compareChannels(e.inputBuffer.getChannelData(0), emptyBuffer.getChannelData(0), 0, Math.min(firstNonZero, 2048)); - compareChannels(e.inputBuffer.getChannelData(1), emptyBuffer.getChannelData(0), 0, Math.min(firstNonZero, 2048)); - compareChannels(e.inputBuffer.getChannelData(0), buffer.getChannelData(0), Math.min(firstNonZero, 2048), 2048 - firstNonZero, 0, -firstNonZero); - compareChannels(e.inputBuffer.getChannelData(1), buffer.getChannelData(1), Math.min(firstNonZero, 2048), 2048 - firstNonZero, 0, -firstNonZero); + compareChannels(e.inputBuffer.getChannelData(0), emptyBuffer.getChannelData(0), firstNonZero); + compareChannels(e.inputBuffer.getChannelData(1), emptyBuffer.getChannelData(0), firstNonZero); + compareChannels(e.inputBuffer.getChannelData(0), buffer.getChannelData(0), 2048 - firstNonZero, firstNonZero, 0); + compareChannels(e.inputBuffer.getChannelData(1), buffer.getChannelData(1), 2048 - firstNonZero, firstNonZero, 0); compareChannels(e.outputBuffer.getChannelData(0), emptyBuffer.getChannelData(0)); compareChannels(e.outputBuffer.getChannelData(1), emptyBuffer.getChannelData(0)); @@ -122,10 +123,10 @@ addLoadEvent(function() { is(e.outputBuffer.length, 2048, "Correct length for the output buffer"); is(e.outputBuffer.sampleRate, context.sampleRate, "Correct sample rate for the output buffer"); - compareChannels(e.inputBuffer.getChannelData(0), buffer.getChannelData(0), 0, firstNonZero, 0, 2048 - firstNonZero); - compareChannels(e.inputBuffer.getChannelData(1), buffer.getChannelData(1), 0, firstNonZero, 0, 2048 - firstNonZero); - compareChannels(e.inputBuffer.getChannelData(0), emptyBuffer.getChannelData(0), firstNonZero); - compareChannels(e.inputBuffer.getChannelData(1), emptyBuffer.getChannelData(0), firstNonZero); + compareChannels(e.inputBuffer.getChannelData(0), buffer.getChannelData(0), firstNonZero, 0, 2048 - firstNonZero); + compareChannels(e.inputBuffer.getChannelData(1), buffer.getChannelData(1), firstNonZero, 0, 2048 - firstNonZero); + compareChannels(e.inputBuffer.getChannelData(0), emptyBuffer.getChannelData(0), undefined, firstNonZero); + compareChannels(e.inputBuffer.getChannelData(1), emptyBuffer.getChannelData(0), undefined, firstNonZero); compareChannels(e.outputBuffer.getChannelData(0), emptyBuffer.getChannelData(0)); compareChannels(e.outputBuffer.getChannelData(1), emptyBuffer.getChannelData(0)); diff --git a/content/media/webaudio/test/webaudio.js b/content/media/webaudio/test/webaudio.js index 8ded61b4d91..146aa9ae005 100644 --- a/content/media/webaudio/test/webaudio.js +++ b/content/media/webaudio/test/webaudio.js @@ -28,7 +28,6 @@ function fuzzyCompare(a, b) { } function compareChannels(buf1, buf2, - /*optional*/ offset, /*optional*/ length, /*optional*/ sourceOffset, /*optional*/ destOffset, @@ -36,15 +35,15 @@ function compareChannels(buf1, buf2, if (!skipLengthCheck) { is(buf1.length, buf2.length, "Channels must have the same length"); } - if (length == undefined) { - length = buf1.length - (offset || 0); - } sourceOffset = sourceOffset || 0; destOffset = destOffset || 0; + if (length == undefined) { + length = buf1.length - sourceOffset; + } var difference = 0; var maxDifference = 0; var firstBadIndex = -1; - for (var i = offset || 0; i < Math.min(buf1.length, (offset || 0) + length); ++i) { + for (var i = 0; i < length; ++i) { if (!fuzzyCompare(buf1[i + sourceOffset], buf2[i + destOffset])) { difference++; maxDifference = Math.max(maxDifference, Math.abs(buf1[i + sourceOffset] - buf2[i + destOffset])); @@ -79,7 +78,7 @@ function compareBuffers(got, expected) { for (var i = 0; i < got.numberOfChannels; ++i) { compareChannels(got.getChannelData(i), expected.getChannelData(i), - 0, got.length, 0, 0, true); + got.length, 0, 0, true); } } @@ -194,7 +193,6 @@ function runTest() for (var i = 0; i < e.renderedBuffer.numberOfChannels; ++i) { compareChannels(e.renderedBuffer.getChannelData(i), expectedBuffer.getChannelData(i), - undefined, expectedBuffer.length, samplesSeen, undefined,