commit 83d59a988ffd7062789452b6a2390c468dae782a
parent 7149216087a1b0f1dd887276ece80d63380512b0
Author: punithbnayak <punithbnayak@chromium.org>
Date: Thu, 9 Oct 2025 16:28:59 +0000
Bug 1991173 [wpt PR 55111] - [webaudio-testharness] Migrate panner-rolloff-clamping.html, a=testonly
Automatic update from web-platform-tests
[webaudio-testharness] Migrate panner-rolloff-clamping.html
Convert panner-rolloff-clamping.html from the legacy
audit.js runner to pure testharness.js
Change-Id: If94c82d211c78f621581f6d1c023164f6dc803c9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6952332
Commit-Queue: Punith Nayak <punithbnayak@chromium.org>
Reviewed-by: Michael Wilson <mjwilson@chromium.org>
Reviewed-by: Hongchan Choi <hongchan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1521679}
--
wpt-commits: 86c55c64837cd043ccd0d2ada45932efb5f5b222
wpt-pr: 55111
Diffstat:
1 file changed, 23 insertions(+), 41 deletions(-)
diff --git a/testing/web-platform/tests/webaudio/the-audio-api/the-pannernode-interface/panner-rolloff-clamping.html b/testing/web-platform/tests/webaudio/the-audio-api/the-pannernode-interface/panner-rolloff-clamping.html
@@ -6,30 +6,12 @@
</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
- <script src="../../resources/audit-util.js"></script>
- <script src="../../resources/audit.js"></script>
</head>
<body>
- <script id="layout-test-code">
+ <script>
// Fairly arbitrary sample rate and render frames.
- let sampleRate = 16000;
- let renderFrames = 2048;
-
- let audit = Audit.createTaskRunner();
-
- audit.define(
- {
- label: 'linear-clamp-high',
- description: 'rolloffFactor clamping for linear distance model'
- },
- (task, should) => {
- runTest(should, {
- distanceModel: 'linear',
- // Fairly arbitrary value outside the nominal range
- rolloffFactor: 2,
- clampedRolloff: 1
- }).then(() => task.done());
- });
+ const sampleRate = 16000;
+ const renderFrames = 2048;
// Test clamping of the rolloffFactor. The test is done by comparing the
// output of a panner with the rolloffFactor set outside the nominal range
@@ -42,18 +24,18 @@
// nominal range of the distance model.
// clampedRolloff - The rolloffFactor (above) clamped to the nominal
// range for the given distance model.
- function runTest(should, options) {
+ const runTest = async (options) => {
// Offline context with two channels. The first channel is the panner
// node under test. The second channel is the reference panner node.
- let context = new OfflineAudioContext(2, renderFrames, sampleRate);
+ const context = new OfflineAudioContext(2, renderFrames, sampleRate);
// The source for the panner nodes. This is fairly arbitrary.
- let src = new OscillatorNode(context, {type: 'sawtooth'});
+ const src = new OscillatorNode(context, {type: 'sawtooth'});
// Create the test panner with the specified rolloff factor. The
// position is fairly arbitrary, but something that is not the default
// is good to show the distance model had some effect.
- let pannerTest = new PannerNode(context, {
+ const pannerTest = new PannerNode(context, {
rolloffFactor: options.rolloffFactor,
distanceModel: options.distanceModel,
positionX: 5000
@@ -61,7 +43,7 @@
// Create the reference panner with the rolloff factor clamped to the
// appropriate limit.
- let pannerRef = new PannerNode(context, {
+ const pannerRef = new PannerNode(context, {
rolloffFactor: options.clampedRolloff,
distanceModel: options.distanceModel,
positionX: 5000
@@ -69,7 +51,7 @@
// Connect the source to the panners to the destination appropriately.
- let merger = new ChannelMergerNode(context, {numberOfInputs: 2});
+ const merger = new ChannelMergerNode(context, {numberOfInputs: 2});
src.connect(pannerTest).connect(merger, 0, 0);
@@ -79,20 +61,20 @@
src.start();
- return context.startRendering().then(function(resultBuffer) {
- // The two channels should be the same due to the clamping. Verify
- // that they are the same.
- let actual = resultBuffer.getChannelData(0);
- let expected = resultBuffer.getChannelData(1);
-
- let message = 'Panner distanceModel: "' + options.distanceModel +
- '", rolloffFactor: ' + options.rolloffFactor;
-
- should(actual, message).beEqualToArray(expected);
- });
- }
-
- audit.run();
+ const resultBuffer = await context.startRendering();
+ // The two channels should be the same due to the clamping. Verify
+ // that they are the same.
+ const actual = resultBuffer.getChannelData(0);
+ const expected = resultBuffer.getChannelData(1);
+ const message = `Panner distanceModel: "${options.distanceModel}", ` +
+ `rolloffFactor: ${options.rolloffFactor}`;
+ assert_array_equals(actual, expected, message);
+ };
+ promise_test(() => runTest({
+ distanceModel: 'linear',
+ rolloffFactor: 2,
+ clampedRolloff: 1
+ }), 'rolloffFactor clamping for linear distance model');
</script>
</body>
</html>