diff --git a/Tests/LibWeb/Text/expected/WebAudio/OscillatorNode.txt b/Tests/LibWeb/Text/expected/WebAudio/OscillatorNode.txt
new file mode 100644
index 00000000000..a5005c94af9
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/WebAudio/OscillatorNode.txt
@@ -0,0 +1,5 @@
+OscillatorNode
+AudioScheduledSourceNode
+AudioNode
+EventTarget
+Object
diff --git a/Tests/LibWeb/Text/input/WebAudio/OscillatorNode.html b/Tests/LibWeb/Text/input/WebAudio/OscillatorNode.html
new file mode 100644
index 00000000000..493990015a0
--- /dev/null
+++ b/Tests/LibWeb/Text/input/WebAudio/OscillatorNode.html
@@ -0,0 +1,15 @@
+
+
diff --git a/Userland/Libraries/LibWeb/WebAudio/AudioNode.cpp b/Userland/Libraries/LibWeb/WebAudio/AudioNode.cpp
index 7b8e84fe484..2b38985f4f6 100644
--- a/Userland/Libraries/LibWeb/WebAudio/AudioNode.cpp
+++ b/Userland/Libraries/LibWeb/WebAudio/AudioNode.cpp
@@ -6,11 +6,19 @@
#include
#include
+#include
namespace Web::WebAudio {
JS_DEFINE_ALLOCATOR(AudioNode);
+AudioNode::AudioNode(JS::Realm& realm, JS::NonnullGCPtr context)
+ : DOM::EventTarget(realm)
+ , m_context(context)
+
+{
+}
+
AudioNode::~AudioNode() = default;
// https://webaudio.github.io/web-audio-api/#dom-audionode-connect
@@ -91,6 +99,7 @@ void AudioNode::initialize(JS::Realm& realm)
void AudioNode::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
+ visitor.visit(m_context);
}
}
diff --git a/Userland/Libraries/LibWeb/WebAudio/AudioNode.h b/Userland/Libraries/LibWeb/WebAudio/AudioNode.h
index 0f7572aa5d6..9bde71f4796 100644
--- a/Userland/Libraries/LibWeb/WebAudio/AudioNode.h
+++ b/Userland/Libraries/LibWeb/WebAudio/AudioNode.h
@@ -42,8 +42,13 @@ public:
void disconnect(JS::NonnullGCPtr destination_param, WebIDL::UnsignedLong output);
protected:
+ AudioNode(JS::Realm&, JS::NonnullGCPtr);
+
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
+
+private:
+ JS::NonnullGCPtr m_context;
};
}
diff --git a/Userland/Libraries/LibWeb/WebAudio/AudioScheduledSourceNode.cpp b/Userland/Libraries/LibWeb/WebAudio/AudioScheduledSourceNode.cpp
index 30c7677d69c..532814aee1c 100644
--- a/Userland/Libraries/LibWeb/WebAudio/AudioScheduledSourceNode.cpp
+++ b/Userland/Libraries/LibWeb/WebAudio/AudioScheduledSourceNode.cpp
@@ -13,6 +13,11 @@ namespace Web::WebAudio {
JS_DEFINE_ALLOCATOR(AudioScheduledSourceNode);
+AudioScheduledSourceNode::AudioScheduledSourceNode(JS::Realm& realm, JS::NonnullGCPtr context)
+ : AudioNode(realm, context)
+{
+}
+
AudioScheduledSourceNode::~AudioScheduledSourceNode() = default;
// https://webaudio.github.io/web-audio-api/#dom-audioscheduledsourcenode-onended
diff --git a/Userland/Libraries/LibWeb/WebAudio/AudioScheduledSourceNode.h b/Userland/Libraries/LibWeb/WebAudio/AudioScheduledSourceNode.h
index 8c375c7671c..545398a3dde 100644
--- a/Userland/Libraries/LibWeb/WebAudio/AudioScheduledSourceNode.h
+++ b/Userland/Libraries/LibWeb/WebAudio/AudioScheduledSourceNode.h
@@ -25,6 +25,8 @@ public:
WebIDL::ExceptionOr stop(double when = 0);
protected:
+ AudioScheduledSourceNode(JS::Realm&, JS::NonnullGCPtr);
+
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
};
diff --git a/Userland/Libraries/LibWeb/WebAudio/OscillatorNode.cpp b/Userland/Libraries/LibWeb/WebAudio/OscillatorNode.cpp
index bff58dbcacd..49d3e5e0f89 100644
--- a/Userland/Libraries/LibWeb/WebAudio/OscillatorNode.cpp
+++ b/Userland/Libraries/LibWeb/WebAudio/OscillatorNode.cpp
@@ -20,9 +20,15 @@ WebIDL::ExceptionOr> OscillatorNode::create(JS:
}
// https://webaudio.github.io/web-audio-api/#dom-oscillatornode-oscillatornode
-WebIDL::ExceptionOr> OscillatorNode::construct_impl(JS::Realm& realm, JS::NonnullGCPtr, OscillatorOptions const&)
+WebIDL::ExceptionOr> OscillatorNode::construct_impl(JS::Realm& realm, JS::NonnullGCPtr context, OscillatorOptions const& options)
+{
+ // FIXME: Invoke "Initialize the AudioNode" steps.
+ return realm.vm().heap().allocate(realm, realm, context, options);
+}
+
+OscillatorNode::OscillatorNode(JS::Realm& realm, JS::NonnullGCPtr context, OscillatorOptions const&)
+ : AudioScheduledSourceNode(realm, context)
{
- return WebIDL::NotSupportedError::create(realm, "FIXME: Implement OscillatorNode::construct_impl"_fly_string);
}
void OscillatorNode::initialize(JS::Realm& realm)
diff --git a/Userland/Libraries/LibWeb/WebAudio/OscillatorNode.h b/Userland/Libraries/LibWeb/WebAudio/OscillatorNode.h
index 9bfedcfd9fd..b254d567bbf 100644
--- a/Userland/Libraries/LibWeb/WebAudio/OscillatorNode.h
+++ b/Userland/Libraries/LibWeb/WebAudio/OscillatorNode.h
@@ -31,6 +31,8 @@ public:
static WebIDL::ExceptionOr> construct_impl(JS::Realm&, JS::NonnullGCPtr, OscillatorOptions const& = {});
protected:
+ OscillatorNode(JS::Realm&, JS::NonnullGCPtr, OscillatorOptions const& = {});
+
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
};