fix(webaudio): convert offline sample rates with WebIDL float

This commit is contained in:
ldm0
2026-11-21 20:03:28 +08:00
parent 4f5868bb2d
commit 74cb2435ef
@@ -84,7 +84,9 @@
assert(reads === 0 && new w.ConvolverNode(context, {disableNormalization: object}).normalize === false, 'ToBoolean has no author hooks');
});
await check(label + '/ConvolverNode/fractional offline context sample-rate', async () => {
for (const sampleRate of [NaN, Infinity, -Infinity, 1e100, Symbol(), 1n]) assert(thrown(() => new w.OfflineAudioContext(1, 16, sampleRate)) instanceof w.TypeError, 'context sample rate uses restricted float');
const offline = new w.OfflineAudioContext(1, 16, 44100.1), rate = Math.fround(44100.1);
assert(offline.sampleRate === rate, 'context preserves converted float sample rate');
const buffer = offline.createBuffer(1, 4, rate), node = new w.ConvolverNode(offline, {buffer});
assert(buffer.sampleRate === rate && node.buffer === buffer, 'matching fractional native buffer accepted');
Object.defineProperty(offline, 'sampleRate', {get() { throw Error('public context metadata'); }});