Skip to content

Truly independent web browser

LibWeb: Add AudioProcessingEvent

Jelle Raaijmakers90a899cd6ceb
diff --git a/Libraries/LibWeb/CMakeLists.txt b/Libraries/LibWeb/CMakeLists.txt
index 19d18495a60..f08f3e09058 100644
--- a/Libraries/LibWeb/CMakeLists.txt
+++ b/Libraries/LibWeb/CMakeLists.txt
@@ -1002,6 +1002,7 @@ set(SOURCES
WebAudio/AudioNode.cpp
WebAudio/AudioParam.cpp
WebAudio/AudioParamTimeline.cpp
+ WebAudio/AudioProcessingEvent.cpp
WebAudio/AudioScheduledSourceNode.cpp
WebAudio/BaseAudioContext.cpp
WebAudio/BiquadFilterNode.cpp
diff --git a/Libraries/LibWeb/WebAudio/AudioProcessingEvent.cpp b/Libraries/LibWeb/WebAudio/AudioProcessingEvent.cpp
new file mode 100644
index 00000000000..f0991f82df5
--- /dev/null
+++ b/Libraries/LibWeb/WebAudio/AudioProcessingEvent.cpp
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <LibGC/Heap.h>
+#include <LibWeb/WebAudio/AudioProcessingEvent.h>
+
+namespace Web::WebAudio {
+
+GC_DEFINE_ALLOCATOR(AudioProcessingEvent);
+
+GC::Ref<AudioProcessingEvent> AudioProcessingEvent::create(Utf16FlyString const& event_name, AudioProcessingEventInit const& event_init, HighResolutionTime::DOMHighResTimeStamp time_stamp)
+{
+ return GC::Heap::the().allocate<AudioProcessingEvent>(event_name, event_init, time_stamp);
+}
+
+AudioProcessingEvent::AudioProcessingEvent(Utf16FlyString const& event_name, AudioProcessingEventInit const& event_init, HighResolutionTime::DOMHighResTimeStamp time_stamp)
+ : DOM::Event(event_name, event_init, time_stamp)
+ , m_playback_time(event_init.playback_time)
+ , m_input_buffer(event_init.input_buffer)
+ , m_output_buffer(event_init.output_buffer)
+{
+}
+
+AudioProcessingEvent::~AudioProcessingEvent() = default;
+
+void AudioProcessingEvent::visit_edges(GC::Cell::Visitor& visitor)
+{
+ Base::visit_edges(visitor);
+ visitor.visit(m_input_buffer);
+ visitor.visit(m_output_buffer);
+}
+
+}
diff --git a/Libraries/LibWeb/WebAudio/AudioProcessingEvent.h b/Libraries/LibWeb/WebAudio/AudioProcessingEvent.h
new file mode 100644
index 00000000000..cd85661b337
--- /dev/null
+++ b/Libraries/LibWeb/WebAudio/AudioProcessingEvent.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2026, Jelle Raaijmakers <[email protected]>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <LibWeb/Bindings/AudioProcessingEvent.h>
+#include <LibWeb/DOM/Event.h>
+#include <LibWeb/WebAudio/AudioBuffer.h>
+#include <LibWebCommon/HighResolutionTime/DOMHighResTimeStamp.h>
+
+namespace Web::WebAudio {
+
+using AudioProcessingEventInit = Bindings::AudioProcessingEventInit;
+
+// https://webaudio.github.io/web-audio-api/#AudioProcessingEvent
+class AudioProcessingEvent final : public DOM::Event {
+ WEB_WRAPPABLE(AudioProcessingEvent, DOM::Event);
+ GC_DECLARE_ALLOCATOR(AudioProcessingEvent);
+
+public:
+ static GC::Ref<AudioProcessingEvent> create(Utf16FlyString const& event_name, AudioProcessingEventInit const&, HighResolutionTime::DOMHighResTimeStamp);
+
+ virtual ~AudioProcessingEvent() override;
+
+ double playback_time() const { return m_playback_time; }
+ GC::Ref<AudioBuffer> input_buffer() const { return m_input_buffer; }
+ GC::Ref<AudioBuffer> output_buffer() const { return m_output_buffer; }
+
+private:
+ AudioProcessingEvent(Utf16FlyString const& event_name, AudioProcessingEventInit const&, HighResolutionTime::DOMHighResTimeStamp);
+
+ virtual void visit_edges(GC::Cell::Visitor&) override;
+
+ double m_playback_time { 0 };
+ GC::Ref<AudioBuffer> m_input_buffer;
+ GC::Ref<AudioBuffer> m_output_buffer;
+};
+
+}
diff --git a/Libraries/LibWeb/WebAudio/AudioProcessingEvent.idl b/Libraries/LibWeb/WebAudio/AudioProcessingEvent.idl
new file mode 100644
index 00000000000..b149f00cfa6
--- /dev/null
+++ b/Libraries/LibWeb/WebAudio/AudioProcessingEvent.idl
@@ -0,0 +1,15 @@
+// https://webaudio.github.io/web-audio-api/#AudioProcessingEvent
+[Exposed=Window]
+interface AudioProcessingEvent : Event {
+ constructor(DOMString type, AudioProcessingEventInit eventInitDict);
+ readonly attribute double playbackTime;
+ readonly attribute AudioBuffer inputBuffer;
+ readonly attribute AudioBuffer outputBuffer;
+};
+
+// https://webaudio.github.io/web-audio-api/#AudioProcessingEventInit
+dictionary AudioProcessingEventInit : EventInit {
+ required double playbackTime;
+ required AudioBuffer inputBuffer;
+ required AudioBuffer outputBuffer;
+};
diff --git a/Libraries/LibWeb/idl_files.cmake b/Libraries/LibWeb/idl_files.cmake
index 99fec2dabbf..c76bf0c80c1 100644
--- a/Libraries/LibWeb/idl_files.cmake
+++ b/Libraries/LibWeb/idl_files.cmake
@@ -644,6 +644,7 @@ libweb_js_bindings(WebAudio/AudioDestinationNode)
libweb_js_bindings(WebAudio/AudioListener)
libweb_js_bindings(WebAudio/AudioNode)
libweb_js_bindings(WebAudio/AudioParam)
+libweb_js_bindings(WebAudio/AudioProcessingEvent)
libweb_js_bindings(WebAudio/AudioScheduledSourceNode)
libweb_js_bindings(WebAudio/BaseAudioContext)
libweb_js_bindings(WebAudio/BiquadFilterNode)
diff --git a/Tests/LibWeb/Text/expected/all-window-properties.txt b/Tests/LibWeb/Text/expected/all-window-properties.txt
index 7d145ffd4ff..38ee5a1549b 100644
--- a/Tests/LibWeb/Text/expected/all-window-properties.txt
+++ b/Tests/LibWeb/Text/expected/all-window-properties.txt
@@ -21,6 +21,7 @@ AudioListener
AudioNode
AudioParam
AudioParamMap
+AudioProcessingEvent
AudioScheduledSourceNode
AudioTrack
AudioTrackList
diff --git a/Tests/LibWeb/Text/expected/wpt-import/webaudio/idlharness.https.window.txt b/Tests/LibWeb/Text/expected/wpt-import/webaudio/idlharness.https.window.txt
index 72c4bdb81cd..94299fcc351 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/webaudio/idlharness.https.window.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/webaudio/idlharness.https.window.txt
@@ -2,8 +2,8 @@ Harness status: OK
Found 1163 tests
-1077 Pass
-86 Fail
+1091 Pass
+72 Fail
Fail idl_test setup
Pass idl_test validation
Pass Partial interface Element: member names are unique
@@ -459,28 +459,28 @@ Pass AudioListener interface: context.listener must inherit property "setPositio
Pass AudioListener interface: calling setPosition(float, float, float) on context.listener with too few arguments must throw TypeError
Pass AudioListener interface: context.listener must inherit property "setOrientation(float, float, float, float, float, float)" with the proper type
Pass AudioListener interface: calling setOrientation(float, float, float, float, float, float) on context.listener with too few arguments must throw TypeError
-Fail AudioProcessingEvent interface: existence and properties of interface object
-Fail AudioProcessingEvent interface object length
-Fail AudioProcessingEvent interface object name
-Fail AudioProcessingEvent interface: existence and properties of interface prototype object
-Fail AudioProcessingEvent interface: existence and properties of interface prototype object's "constructor" property
-Fail AudioProcessingEvent interface: existence and properties of interface prototype object's @@unscopables property
-Fail AudioProcessingEvent interface: attribute playbackTime
-Fail AudioProcessingEvent interface: attribute inputBuffer
-Fail AudioProcessingEvent interface: attribute outputBuffer
-Fail AudioProcessingEvent must be primary interface of new AudioProcessingEvent('', {
+Pass AudioProcessingEvent interface: existence and properties of interface object
+Pass AudioProcessingEvent interface object length
+Pass AudioProcessingEvent interface object name
+Pass AudioProcessingEvent interface: existence and properties of interface prototype object
+Pass AudioProcessingEvent interface: existence and properties of interface prototype object's "constructor" property
+Pass AudioProcessingEvent interface: existence and properties of interface prototype object's @@unscopables property
+Pass AudioProcessingEvent interface: attribute playbackTime
+Pass AudioProcessingEvent interface: attribute inputBuffer
+Pass AudioProcessingEvent interface: attribute outputBuffer
+Pass AudioProcessingEvent must be primary interface of new AudioProcessingEvent('', {
playbackTime: 0, inputBuffer: buffer, outputBuffer: buffer
})
-Fail Stringification of new AudioProcessingEvent('', {
+Pass Stringification of new AudioProcessingEvent('', {
playbackTime: 0, inputBuffer: buffer, outputBuffer: buffer
})
-Fail AudioProcessingEvent interface: new AudioProcessingEvent('', {
+Pass AudioProcessingEvent interface: new AudioProcessingEvent('', {
playbackTime: 0, inputBuffer: buffer, outputBuffer: buffer
}) must inherit property "playbackTime" with the proper type
-Fail AudioProcessingEvent interface: new AudioProcessingEvent('', {
+Pass AudioProcessingEvent interface: new AudioProcessingEvent('', {
playbackTime: 0, inputBuffer: buffer, outputBuffer: buffer
}) must inherit property "inputBuffer" with the proper type
-Fail AudioProcessingEvent interface: new AudioProcessingEvent('', {
+Pass AudioProcessingEvent interface: new AudioProcessingEvent('', {
playbackTime: 0, inputBuffer: buffer, outputBuffer: buffer
}) must inherit property "outputBuffer" with the proper type
Pass BiquadFilterNode interface: existence and properties of interface object