tor-browser

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

commit 72cf306a676982e8b92ce9490939f3432335a408
parent f537ac2906c76c8827d81ec188b4054a883da996
Author: punithbnayak <punithbnayak@chromium.org>
Date:   Mon, 10 Nov 2025 22:20:00 +0000

Bug 1999002 [wpt PR 55946] - [webaudio-testharness] Migrate audioworklet-messageport.https.html, a=testonly

Automatic update from web-platform-tests
[webaudio-testharness] Migrate audioworklet-messageport.https.html

Convert audioworklet-messageport.https.html from the legacy
audit.js runner to pure testharness.js

Change-Id: I85c47c9d43975bc2882adf8f70c5539ed721103d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7103799
Reviewed-by: Hongchan Choi <hongchan@chromium.org>
Commit-Queue: Punith Nayak <punithbnayak@chromium.org>
Reviewed-by: Dibyajyoti Pal <dibyapal@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1541915}

--

wpt-commits: 0c6afae111ca0a958c1a3341e995ad5b51d4be4f
wpt-pr: 55946

Diffstat:
Mtesting/web-platform/tests/webaudio/the-audio-api/the-audioworklet-interface/audioworklet-messageport.https.html | 107+++++++++++++++++++++++++++++++++++++------------------------------------------
1 file changed, 50 insertions(+), 57 deletions(-)

diff --git a/testing/web-platform/tests/webaudio/the-audio-api/the-audioworklet-interface/audioworklet-messageport.https.html b/testing/web-platform/tests/webaudio/the-audio-api/the-audioworklet-interface/audioworklet-messageport.https.html @@ -6,74 +6,67 @@ </title> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> - <script src="/webaudio/resources/audit.js"></script> </head> <body> - <script id="layout-test-code"> - let audit = Audit.createTaskRunner(); + <script> - let context = new AudioContext(); + // This test verifies the correct operation of MessagePort communication + // between the main thread and the AudioWorklet environment. It checks: + // 1. Messages can be sent/received via the AudioWorkletGlobalScope's + // shared port (context.audioWorklet.port) + // 2. Messages can be sent/received via individual AudioWorkletProcessor + // instance ports (node.port) + // 3. AudioWorkletProcessor instances send initialization messages + // upon creation + promise_test(async () => { + const context = new AudioContext(); + const filePath = 'processors/port-processor.js'; + await context.audioWorklet.addModule(filePath); - let filePath = 'processors/port-processor.js'; + const globalOnMessagePromise = new Promise((resolve) => { + context.audioWorklet.port.onmessage = (event) => { + resolve(event.data); + }; + context.audioWorklet.port.postMessage('hello world'); + }); - // AudioWorket to global communication. - audit.define( - 'Test postMessage from AudioWorklet to AudioWorkletGlobalScope', - (task, should) => { - context.audioWorklet.port.onmessage = (event) => { - should(event.data, - 'The response from AudioWorkletGlobalscope') - .beEqualTo('hello world'); - task.done(); - }; - context.audioWorklet.port.postMessage("hello world"); - }); + assert_equals( + await globalOnMessagePromise, + 'hello world', + 'The response from AudioWorkletGlobalScope'); - // Creates an AudioWorkletNode and sets an EventHandler on MessagePort - // object. The associated PortProcessor will post a message upon its - // construction. Test if the message is received correctly. - audit.define( - 'Test postMessage from AudioWorkletProcessor to AudioWorkletNode', - (task, should) => { - let porterWorkletNode = - new AudioWorkletNode(context, 'port-processor'); + // Creates an AudioWorkletNode and sets an EventHandler on MessagePort + // object. The associated PortProcessor will post a message upon its + // construction. Test if the message is received correctly. + const nodeCreationOnMessagePromise = new Promise((resolve) => { + const node = new AudioWorkletNode(context, 'port-processor'); + node.port.onmessage = (event) => { + resolve(event.data.state); + }; + }); - // Upon the creation of PortProcessor, it will post a message to the - // node with 'created' status. - porterWorkletNode.port.onmessage = (event) => { - should(event.data.state, - 'The initial message from PortProcessor') - .beEqualTo('created'); - task.done(); - }; - }); + assert_equals( + await nodeCreationOnMessagePromise, + 'created', + 'The initial message from PortProcessor'); - // PortProcessor is supposed to echo the message back to the - // AudioWorkletNode. - audit.define( - 'Test postMessage from AudioWorkletNode to AudioWorkletProcessor', - (task, should) => { - let porterWorkletNode = - new AudioWorkletNode(context, 'port-processor'); - - porterWorkletNode.port.onmessage = (event) => { + const nodeOnMessagePromise = new Promise((resolve) => { + const node = new AudioWorkletNode(context, 'port-processor'); + node.port.onmessage = (event) => { + if (!event.data.state) { // Ignore if the delivered message has |state|. This is already // tested in the previous task. - if (event.data.state) - return; - - should(event.data.message, - 'The response from PortProcessor') - .beEqualTo('hello'); - task.done(); - }; - - porterWorkletNode.port.postMessage('hello'); - }); + resolve(event.data.message); + } + }; + node.port.postMessage('hello'); + }); - context.audioWorklet.addModule(filePath).then(() => { - audit.run(); - }); + assert_equals( + await nodeOnMessagePromise, + 'hello', + 'The response from PortProcessor'); + }, 'Test MessagePort in AudioWorkletNode and AudioWorkletProcessor'); </script> </body> </html>