Skip to content

armgit / moli

Public Imported from GitHub
0

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

feat(audio): expose AudioListener and AudioParamMap interface shells

ldm0c57765060fb1
diff --git a/moli-renderer-v8/src/context_bootstrap/specs/registry.rs b/moli-renderer-v8/src/context_bootstrap/specs/registry.rs
index fb871e96b..21882caf3 100644
--- a/moli-renderer-v8/src/context_bootstrap/specs/registry.rs
+++ b/moli-renderer-v8/src/context_bootstrap/specs/registry.rs
@@ -1435,6 +1435,14 @@ const CONSTRUCTOR_SPECS_AFTER_STREAMS: &[ConstructorSpec] = &[
interface: web_api_interfaces::AnalyserNode::DESCRIPTOR,
kind: ConstructorKind::AnalyserNode,
},
+ ConstructorSpec {
+ interface: web_api_interfaces::AudioParamMap::DESCRIPTOR,
+ kind: ConstructorKind::Illegal,
+ },
+ ConstructorSpec {
+ interface: web_api_interfaces::AudioListener::DESCRIPTOR,
+ kind: ConstructorKind::Illegal,
+ },
ConstructorSpec {
interface: web_api_interfaces::AudioParam::DESCRIPTOR,
kind: ConstructorKind::AudioParam,
diff --git a/moli-renderer-v8/src/script_vm/tests/audio_value_owner_interface_exposure_interfaces.rs b/moli-renderer-v8/src/script_vm/tests/audio_value_owner_interface_exposure_interfaces.rs
new file mode 100644
index 000000000..5c793fe73
--- /dev/null
+++ b/moli-renderer-v8/src/script_vm/tests/audio_value_owner_interface_exposure_interfaces.rs
@@ -0,0 +1,39 @@
+use super::*;
+
+#[test]
+fn audio_value_owner_interface_exposure_interfaces_have_realm_local_constructors_and_exposure() {
+ for url in [
+ "https://interface-exposure.test/",
+ "http://interface-exposure.test/",
+ ] {
+ let mut vm = new_storage_test_vm(url);
+ assert_eq!(vm.eval(r#"
+(() => {
+ const assert = (ok, message) => { if (!ok) throw Error(message); };
+ const names = ["AudioListener", "AudioParamMap"];
+ const parents = {"AudioListener": null, "AudioParamMap": null};
+ if (!document.documentElement) document.appendChild(document.createElement('html'));
+ if (!document.body) document.documentElement.appendChild(document.createElement('body'));
+ const child = document.createElement('iframe');
+ document.body.appendChild(child);
+ const other = child.contentWindow;
+ for (const realm of [window, other]) {
+ for (const name of names) {
+ const C = realm[name];
+ assert(typeof C === 'function' && C.name === name && C.length === 0, name + ' constructor');
+ assert(C.prototype.constructor === C, name + ' prototype identity');
+ assert(Object.getPrototypeOf(C.prototype) === (parents[name] ? realm[parents[name]].prototype : realm.Object.prototype), name + ' prototype inheritance');
+ assert(realm[name] === C, name + ' stable lazy materialization');
+ for (const invoke of [() => C(), () => new C(), () => Reflect.construct(C, [], function Subclass() {})]) {
+ let error;
+ try { invoke(); } catch (caught) { error = caught; }
+ assert(error instanceof realm.TypeError, name + ' rejects construction in callee realm');
+ }
+ assert(C !== (realm === window ? other[name] : window[name]), name + ' distinct realm constructors');
+ }
+ }
+ return 'passed';
+})()
+"#).unwrap(), "passed", "{url}");
+ }
+}
diff --git a/moli-renderer-v8/src/script_vm/tests/mod.rs b/moli-renderer-v8/src/script_vm/tests/mod.rs
index 390296629..9509e9461 100644
--- a/moli-renderer-v8/src/script_vm/tests/mod.rs
+++ b/moli-renderer-v8/src/script_vm/tests/mod.rs
@@ -2168,6 +2168,7 @@ mod svg_detached_lengths;
mod svg_transform_sync_consolidation;
mod audio_event_interfaces;
+mod audio_value_owner_interface_exposure_interfaces;
mod hyperlink_null_url_protocol;
mod import_meta;
mod indexed_db;
diff --git a/moli-renderer-v8/src/web_api_interfaces.rs b/moli-renderer-v8/src/web_api_interfaces.rs
index 5689a26cc..c61c50268 100644
--- a/moli-renderer-v8/src/web_api_interfaces.rs
+++ b/moli-renderer-v8/src/web_api_interfaces.rs
@@ -40,6 +40,8 @@ interfaces! {
AudioBuffer;
AudioContext: BaseAudioContext;
AudioDestinationNode: AudioNode;
+ AudioListener;
+ AudioParamMap;
AudioNode: EventTarget;
AudioParam;
Worklet;