crashtest for bug 1274083 r=jesup

This needed some fine tuning to produce the crash, and so is a very specific
test.  It is still of value because this specific situation is not otherwise
tested, and it provides input to fuzzers for potential similar situations.

--HG--
extra : rebase_source : d87ec7d1e483a0a3045f07d7686b2be1b80a2e7f
This commit is contained in:
Karl Tomlinson 2017-04-04 16:18:19 +12:00
Родитель 8bd97a5230
Коммит cb207295b9
2 изменённых файлов: 35 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,34 @@
<!DOCTYPE html>
<html class="reftest-wait">
<script>
const blockSize = 128;
// The sample rate is a prime number so that the resampler is not expected to
// simplify in/out fractions.
const rate = 44101;
var context = new window.OfflineAudioContext(1, 3 * blockSize, rate);
// Non-zero buffer, so it can't be optimized away.
var buffer = context.createBuffer(1, 128, rate);
buffer.getChannelData(0)[0] = 1.0;
var source = context.createBufferSource();
source.buffer = buffer;
source.loop = true;
// Initialize the resampler with a slow input rate.
// With the current (Mar 2017) implementation, very slow rates give the
// resampler a very large denominator.
source.playbackRate.setValueAtTime(rate / 0x7fffffff, 0.0);
// Change to a moderate input rate.
// With the current implementation, skip_frac_num increases by den_rate for
// each output sample and so one block before the change in playback rate is
// enough for high skip_frac_num at the time of the change.
const changeBlock = 1;
const changeBlockSeconds = changeBlock * blockSize / rate;
// With the current speex_resampler_set_rate_frac() implementation, the
// moderate resampler denominator is still large enough to trigger overflow of
// 32-bit unsigned integer arithmetic.
source.playbackRate.setValueAtTime(rate / (rate + 1), changeBlockSeconds);
source.start(0);
context.startRendering().
then(function() {
document.documentElement.removeAttribute("class");
});
</script>

Просмотреть файл

@ -92,6 +92,7 @@ load audiocontext-double-suspend.html
load buffer-source-duration-1.html
load buffer-source-ended-1.html
load buffer-source-resampling-start-1.html
load buffer-source-slow-resampling-1.html
load doppler-1.html
HTTP load media-element-source-seek-1.html
load offline-buffer-source-ended-1.html