tor-browser

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

commit 1cdb26400e1589c588aa400c5a8344fed8a97fbd
parent c4ccfbd5ee7a1918a01804fa3bdf625fed8b045e
Author: punithbnayak <punithbnayak@chromium.org>
Date:   Tue, 21 Oct 2025 10:15:50 +0000

Bug 1994295 [wpt PR 55425] - [webaudio-testharness] Migrate k-rate-oscillator.html, a=testonly

Automatic update from web-platform-tests
[webaudio-testharness] Migrate k-rate-oscillator.html

Convert k-rate-oscillator.html from the legacy
audit.js runner to pure testharness.js

Change-Id: I4e9bee85d70e0245f48324ecf92a7691b15bdd42
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6998771
Reviewed-by: Michael Wilson <mjwilson@chromium.org>
Commit-Queue: Punith Nayak <punithbnayak@chromium.org>
Reviewed-by: Hongchan Choi <hongchan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1529750}

--

wpt-commits: 9c3c070a506ebe231652b4391b58f1468df8a930
wpt-pr: 55425

Diffstat:
Mtesting/web-platform/tests/webaudio/resources/audit-util.js | 14++++++++++++++
Mtesting/web-platform/tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-oscillator.html | 116++++++++++++++++++++++++++++++++++---------------------------------------------
2 files changed, 64 insertions(+), 66 deletions(-)

diff --git a/testing/web-platform/tests/webaudio/resources/audit-util.js b/testing/web-platform/tests/webaudio/resources/audit-util.js @@ -315,3 +315,17 @@ function assert_array_equal_within_eps( ` = ${diff} > ${epsilon}`); } } + +function assert_not_constant_value_of(array, value, description) { + assert_true(array && typeof array.length === 'number' && array.length > 0, + `${description}: input must be a non-empty array`); + + const hasDifferentValues = array.some(element => element !== value); + + // Pass if there's at least one element not strictly equal to `value`. + assert_true( + hasDifferentValues, + `${description}: ${array} should have contained at least `+ + `one value different from ${value}.` + ); +} diff --git a/testing/web-platform/tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-oscillator.html b/testing/web-platform/tests/webaudio/the-audio-api/the-audioparam-interface/k-rate-oscillator.html @@ -5,84 +5,68 @@ <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> </head> <body> <script> - let audit = Audit.createTaskRunner(); - // Arbitrary sample rate and duration. - let sampleRate = 8000; + const sampleRate = 8000; // Only new a few render quanta to verify things are working. - let testDuration = 4 * 128 / sampleRate; + const testDuration = 4 * 128 / sampleRate; [{name: 'detune', initial: 0, final: 1200}, { name: 'frequency', initial: 440, - final: sampleRate / 2 - }].forEach(paramProperty => { - audit.define( - 'Oscillator k-rate ' + paramProperty.name, (task, should) => { - let context = new OfflineAudioContext({ - numberOfChannels: 3, - sampleRate: sampleRate, - length: testDuration * sampleRate - }); - - let merger = new ChannelMergerNode( - context, {numberOfInputs: context.destination.channelCount}); - merger.connect(context.destination); - let inverter = new GainNode(context, {gain: -1}); - inverter.connect(merger, 0, 2); - - let kRateNode = new OscillatorNode(context); - let aRateNode = new OscillatorNode(context); - - kRateNode.connect(merger, 0, 0); - aRateNode.connect(merger, 0, 1); - - kRateNode.connect(merger, 0, 2); - aRateNode.connect(inverter); - - // Set the rate - kRateNode[paramProperty.name].automationRate = 'k-rate'; - - // Automate the offset - kRateNode[paramProperty.name].setValueAtTime( - paramProperty.initial, 0); - kRateNode[paramProperty.name].linearRampToValueAtTime( - paramProperty.final, testDuration); - - aRateNode[paramProperty.name].setValueAtTime( - paramProperty.initial, 0); - aRateNode[paramProperty.name].linearRampToValueAtTime( - paramProperty.final, testDuration); - - kRateNode.start(); - aRateNode.start(); - - context.startRendering() - .then(audioBuffer => { - let kRateOut = audioBuffer.getChannelData(0); - let aRateOut = audioBuffer.getChannelData(1); - let diff = audioBuffer.getChannelData(2); - - // Verify that the outputs are different. - should( - diff, - 'k-rate ' + paramProperty.name + - ': Difference between a-rate and k-rate outputs') - .notBeConstantValueOf(0); - - }) - .then(() => task.done()); - }); + final: sampleRate / 2}].forEach((paramProperty) => { + promise_test(async () => { + const context = new OfflineAudioContext({ + numberOfChannels: 3, + sampleRate: sampleRate, + length: testDuration * sampleRate + }); + + const merger = new ChannelMergerNode( + context, {numberOfInputs: context.destination.channelCount}); + merger.connect(context.destination); + const inverter = new GainNode(context, {gain: -1}); + inverter.connect(merger, 0, 2); + + const kRateNode = new OscillatorNode(context); + const aRateNode = new OscillatorNode(context); + + kRateNode.connect(merger, 0, 0); + aRateNode.connect(merger, 0, 1); + + kRateNode.connect(merger, 0, 2); + aRateNode.connect(inverter); + + // Set the rate + kRateNode[paramProperty.name].automationRate = 'k-rate'; + + // Automate the offset + kRateNode[paramProperty.name].setValueAtTime( + paramProperty.initial, 0); + kRateNode[paramProperty.name].linearRampToValueAtTime( + paramProperty.final, testDuration); + + aRateNode[paramProperty.name].setValueAtTime( + paramProperty.initial, 0); + aRateNode[paramProperty.name].linearRampToValueAtTime( + paramProperty.final, testDuration); + + kRateNode.start(); + aRateNode.start(); + + const audioBuffer = await context.startRendering(); + const diff = audioBuffer.getChannelData(2); + // Verify that the outputs are different. + assert_not_constant_value_of( + diff, 0, + `k-rate ${paramProperty.name}: ` + + `Difference between a-rate and k-rate outputs`); + }, `Oscillator k-rate ${paramProperty.name}`); }); - - - audit.run(); </script> </body> </html>