tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 462419f6f65aa8a0af75c08e50748c1a588b3cf2
parent 0d4b2d6c2be309b3247e25849d6176a52aa1dbc3
Author: Saqlain <2mesaqlain@gmail.com>
Date:   Wed, 15 Oct 2025 08:23:54 +0000

Bug 1993572 [wpt PR 55314] - [webaudio-testharness] Migrate audiobuffersource-multi-channels.html, a=testonly

Automatic update from web-platform-tests
[webaudio-testharness] Migrate audiobuffersource-multi-channels.html

Convert audiobuffersource-multi-channels.html from the legacy audit.js
runner to pure testharness.js

Bug: 396477778
Change-Id: I12be99f3f7522bc1806871ec6a77eefc7901813c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7002987
Reviewed-by: Michael Wilson <mjwilson@chromium.org>
Reviewed-by: Hongchan Choi <hongchan@chromium.org>
Commit-Queue: Saqlain <2mesaqlain@gmail.com>
Cr-Commit-Position: refs/heads/main@{#1527747}

--

wpt-commits: c0c16af998c3cbd9bcef24c527ea67f6395a324d
wpt-pr: 55314

Diffstat:
Mtesting/web-platform/tests/webaudio/the-audio-api/the-audiobuffersourcenode-interface/audiobuffersource-multi-channels.html | 96+++++++++++++++++++++++++++++++------------------------------------------------
1 file changed, 38 insertions(+), 58 deletions(-)

diff --git a/testing/web-platform/tests/webaudio/the-audio-api/the-audiobuffersourcenode-interface/audiobuffersource-multi-channels.html b/testing/web-platform/tests/webaudio/the-audio-api/the-audiobuffersourcenode-interface/audiobuffersource-multi-channels.html @@ -1,78 +1,58 @@ <!DOCTYPE html> -<!-- -Test AudioBufferSourceNode supports 5.1 channel. ---> <html> <head> <title> - audiobuffersource-multi-channels.html + Test AudioBufferSourceNode supports 5.1 channel playback </title> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> <script src="/webaudio/resources/audit-util.js"></script> - <script src="/webaudio/resources/audit.js"></script> <script src="/webaudio/resources/mix-testing.js"></script> </head> <body> - <script id="layout-test-code"> - let audit = Audit.createTaskRunner(); - let context; - let expectedAudio; + <script> + // Test AudioBufferSourceNode supports 5.1 channel. + // Creating context and fetching expected audio. + promise_test(async () => { + const sampleRate = 44100.0; + const context = new OfflineAudioContext( + 6, sampleRate * toneLengthSeconds, sampleRate); - audit.define('initialize', (task, should) => { - // Create offline audio context - let sampleRate = 44100.0; - should(() => { - context = new OfflineAudioContext( - 6, sampleRate * toneLengthSeconds, sampleRate); - }, 'Creating context for testing').notThrow(); - should( - Audit - .loadFileFromUrl('resources/audiobuffersource-multi-channels-expected.wav') - .then(arrayBuffer => { - context.decodeAudioData(arrayBuffer).then(audioBuffer => { - expectedAudio = audioBuffer; - task.done(); - }).catch(error => { - assert_unreached("Could not decode audio data due to " + error.message); - }) - }) - , 'Fetching expected audio').beResolved(); - }); + let expectedAudio; - audit.define( - {label: 'test', description: 'AudioBufferSource with 5.1 buffer'}, - (task, should) => { - let toneBuffer = - createToneBuffer(context, 440, toneLengthSeconds, 6); + const response = await fetch( + 'resources/audiobuffersource-multi-channels-expected.wav'); + const arrayBuffer = await response.arrayBuffer(); + try { + expectedAudio = await context.decodeAudioData(arrayBuffer); + } catch (error) { + assert_unreached( + `Could not decode audio data due to ${error.message}`); + } - let source = context.createBufferSource(); - source.buffer = toneBuffer; + // Render and verify output. + const toneBuffer = createToneBuffer(context, 440, toneLengthSeconds, 6); + const source = new AudioBufferSourceNode(context, {buffer:toneBuffer}); - source.connect(context.destination); - source.start(0); + source.connect(context.destination); + source.start(); - context.startRendering() - .then(renderedAudio => { - // Compute a threshold based on the maximum error, |maxUlp|, - // in ULP. This is experimentally determined. Assuming that - // the reference file is a 16-bit wav file, the max values in - // the wave file are +/- 32768. - let maxUlp = 1; - let threshold = maxUlp / 32768; - for (let k = 0; k < renderedAudio.numberOfChannels; ++k) { - should( - renderedAudio.getChannelData(k), - 'Rendered audio for channel ' + k) - .beCloseToArray( - expectedAudio.getChannelData(k), - {absoluteThreshold: threshold}); - } - }) - .then(() => task.done()); - }); + const renderedAudio = await context.startRendering(); - audit.run(); + // Compute a threshold based on the maximum error, |maxUlp|, + // in ULP. This is experimentally determined. Assuming that + // the reference file is a 16-bit wav file, the max values in + // the wave file are +/- 32768. + const maxUlp = 1; + const threshold = maxUlp / 32768; + for (let k = 0; k < renderedAudio.numberOfChannels; ++k) { + assert_array_approx_equals( + renderedAudio.getChannelData(k), + expectedAudio.getChannelData(k), + threshold, + `Rendered audio for channel ${k}`); + } + }, 'AudioBufferSourceNode 5.1 channel playback verification'); </script> </body> </html>