Skip to content

armgit / moli

Public Imported from GitHub
0

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

refactor(events): store simple target listeners under one private key

ldm0b2af27a5089c
diff --git a/moli-renderer-v8/src/context_bootstrap.rs b/moli-renderer-v8/src/context_bootstrap.rs
index 2258c7fbd..b5b590251 100644
--- a/moli-renderer-v8/src/context_bootstrap.rs
+++ b/moli-renderer-v8/src/context_bootstrap.rs
@@ -338,15 +338,15 @@ pub(crate) use self::media_queries::{
SimpleObjectEventListenerInspectorSnapshot, SimpleObjectEventListenerSnapshot,
dispatch_media_query_list_change_events, dispatch_simple_event_target_event,
dispatch_simple_event_target_event_collecting_errors,
- evaluate_match_media_query_list_with_viewport, install_simple_event_target_handlers,
- install_simple_event_target_methods, invoke_simple_event_listener,
- mark_simple_event_target_slot, simple_event_target_add_event_listener_callback,
- simple_event_target_dispatch_event_callback, simple_event_target_handler_getter_callback,
- simple_event_target_handler_setter_callback, simple_event_target_inspector_listener_snapshots,
- simple_event_target_remove_event_listener_callback, simple_event_target_slot_name,
- simple_object_event_listeners_snapshot, simple_object_event_set_handler,
- simple_object_event_target_add_listener, simple_object_event_target_remove_listener,
- simple_object_has_event_listeners,
+ evaluate_match_media_query_list_with_viewport, initialize_simple_event_target,
+ install_simple_event_target_handlers, install_simple_event_target_methods,
+ invoke_simple_event_listener, is_simple_event_target,
+ simple_event_target_add_event_listener_callback, simple_event_target_dispatch_event_callback,
+ simple_event_target_handler_getter_callback, simple_event_target_handler_setter_callback,
+ simple_event_target_inspector_listener_snapshots,
+ simple_event_target_remove_event_listener_callback, simple_object_event_listeners_snapshot,
+ simple_object_event_set_handler, simple_object_event_target_add_listener,
+ simple_object_event_target_remove_listener, simple_object_has_event_listeners,
};
pub(crate) use self::message_ports::{
MessagePortDeliveryRunResult, MessagePortRealmBinding, detach_message_port_owner_for_transfer,
@@ -409,7 +409,7 @@ pub(crate) use self::runtime_state::{
ORIGINAL_WEBASSEMBLY_GLOBAL_VALUE_GETTER_SLOT, ORIGINAL_WEBASSEMBLY_INSTANCE_CONSTRUCTOR_SLOT,
ORIGINAL_WEBASSEMBLY_LINK_ERROR_CONSTRUCTOR_SLOT,
};
-pub(crate) use self::shared::SIMPLE_EVENT_TARGET_SLOT;
+pub(crate) use self::shared::SIMPLE_EVENT_TARGET_LISTENERS_SLOT;
#[cfg(test)]
pub(crate) use self::shared::structured_deserialize_value;
#[cfg(test)]
diff --git a/moli-renderer-v8/src/context_bootstrap/abort_signal_events.rs b/moli-renderer-v8/src/context_bootstrap/abort_signal_events.rs
index 5b3556fc5..6590c5d55 100644
--- a/moli-renderer-v8/src/context_bootstrap/abort_signal_events.rs
+++ b/moli-renderer-v8/src/context_bootstrap/abort_signal_events.rs
@@ -1,16 +1,15 @@
use super::{
- construct_original_event, dispatch_simple_event_target_event, mark_simple_event_target_slot,
+ construct_original_event, dispatch_simple_event_target_event, initialize_simple_event_target,
simple_object_event_set_handler,
};
use crate::util::{get_private_value, set_private_value};
-const LISTENERS_SLOT: &str = "__moliAbortSignalListeners";
const ONABORT_SLOT: &str = "__moliAbortSignalOnabort";
// Abort state and algorithms remain in their Window/worker owner. The signal's
// EventTarget state uses the same registry for inherited methods and native abort.
pub(crate) fn initialize<'s>(scope: &mut v8::PinScope<'s, '_>, signal: v8::Local<'s, v8::Object>) {
- mark_simple_event_target_slot(scope, signal, LISTENERS_SLOT);
+ initialize_simple_event_target(scope, signal);
set_private_value(scope, signal, ONABORT_SLOT, v8::null(scope).into());
}
@@ -25,7 +24,7 @@ pub(crate) fn dispatch_abort<'s>(
let scope = &mut v8::ContextScope::new(scope, context);
if let Some(event) = construct_original_event(scope, "abort") {
super::mark_event_trusted(scope, event);
- dispatch_simple_event_target_event(scope, signal, LISTENERS_SLOT, "abort", event);
+ dispatch_simple_event_target_event(scope, signal, "abort", event);
}
}
@@ -46,12 +45,5 @@ pub(crate) fn onabort_setter<'s>(
_rv: v8::ReturnValue<'_, v8::Value>,
) {
let signal = args.this();
- simple_object_event_set_handler(
- scope,
- signal,
- LISTENERS_SLOT,
- "abort",
- ONABORT_SLOT,
- args.get(0),
- );
+ simple_object_event_set_handler(scope, signal, "abort", ONABORT_SLOT, args.get(0));
}
diff --git a/moli-renderer-v8/src/context_bootstrap/broadcast_channel.rs b/moli-renderer-v8/src/context_bootstrap/broadcast_channel.rs
index 270013584..1dd6f1787 100644
--- a/moli-renderer-v8/src/context_bootstrap/broadcast_channel.rs
+++ b/moli-renderer-v8/src/context_bootstrap/broadcast_channel.rs
@@ -22,7 +22,6 @@ use moli_webapi_declare::{WebApiFunctionTemplate, WebApiObject};
const BROADCAST_CHANNEL_ID_SLOT: &str = "__lmBroadcastChannelId";
const BROADCAST_CHANNEL_NAME_SLOT: &str = "__lmBroadcastChannelName";
const BROADCAST_CHANNEL_CLOSED_SLOT: &str = "__lmBroadcastChannelClosed";
-const BROADCAST_CHANNEL_LISTENERS_SLOT: &str = "__lmBroadcastChannelListeners";
const BROADCAST_CHANNEL_ONMESSAGE_SLOT: &str = "__lmBroadcastChannelOnmessage";
const BROADCAST_CHANNEL_ONMESSAGEERROR_SLOT: &str = "__lmBroadcastChannelOnmessageerror";
@@ -44,8 +43,8 @@ struct BroadcastChannelObjectDeclaration<'scope> {
#[webapi(slot = BROADCAST_CHANNEL_ONMESSAGEERROR_SLOT, init = "null")]
onmessageerror: (),
- #[webapi(slot = SIMPLE_EVENT_TARGET_SLOT, value = BROADCAST_CHANNEL_LISTENERS_SLOT)]
- event_target_slot: (),
+ #[webapi(slot = SIMPLE_EVENT_TARGET_LISTENERS_SLOT, init = "null_object")]
+ event_listeners: (),
#[webapi(
method,
@@ -519,7 +518,6 @@ fn broadcast_channel_event_handler_setter_callback<'s>(
simple_object_event_set_handler(
scope,
args.this(),
- BROADCAST_CHANNEL_LISTENERS_SLOT,
handler.event_type,
handler.slot_name,
args.get(0),
@@ -708,13 +706,7 @@ fn dispatch_broadcast_channel_event<'s>(
origin,
v8::Array::new(scope, 0),
) {
- dispatch_simple_event_target_event(
- scope,
- target,
- BROADCAST_CHANNEL_LISTENERS_SLOT,
- "messageerror",
- event,
- );
+ dispatch_simple_event_target_event(scope, target, "messageerror", event);
return true;
}
return false;
@@ -724,13 +716,7 @@ fn dispatch_broadcast_channel_event<'s>(
&& let Some(event) =
new_broadcast_channel_message_event(scope, "message", data, origin, ports)
{
- dispatch_simple_event_target_event(
- scope,
- target,
- BROADCAST_CHANNEL_LISTENERS_SLOT,
- "message",
- event,
- );
+ dispatch_simple_event_target_event(scope, target, "message", event);
return true;
}
if let Some(event) = new_broadcast_channel_message_event(
@@ -740,13 +726,7 @@ fn dispatch_broadcast_channel_event<'s>(
origin,
v8::Array::new(scope, 0),
) {
- dispatch_simple_event_target_event(
- scope,
- target,
- BROADCAST_CHANNEL_LISTENERS_SLOT,
- "messageerror",
- event,
- );
+ dispatch_simple_event_target_event(scope, target, "messageerror", event);
return true;
}
}
diff --git a/moli-renderer-v8/src/context_bootstrap/constructors/core.rs b/moli-renderer-v8/src/context_bootstrap/constructors/core.rs
index bb6d498cd..3131f0fdc 100644
--- a/moli-renderer-v8/src/context_bootstrap/constructors/core.rs
+++ b/moli-renderer-v8/src/context_bootstrap/constructors/core.rs
@@ -14,7 +14,7 @@ pub(in crate::context_bootstrap) fn event_target_constructor_callback<'s>(
return;
}
let target = args.this();
- install_simple_event_target_methods(scope, target, "__moliEventTargetListeners");
+ install_simple_event_target_methods(scope, target);
rv.set(target.into());
}
diff --git a/moli-renderer-v8/src/context_bootstrap/css_fontface_runtime.rs b/moli-renderer-v8/src/context_bootstrap/css_fontface_runtime.rs
index 870dcdffe..a97f39043 100644
--- a/moli-renderer-v8/src/context_bootstrap/css_fontface_runtime.rs
+++ b/moli-renderer-v8/src/context_bootstrap/css_fontface_runtime.rs
@@ -32,7 +32,6 @@ pub(super) const FONT_FACE_SET_CONNECTED_FACES_SLOT: &str = "__moliFontFaceSetCo
pub(super) const FONT_FACE_SET_STATUS_SLOT: &str = "__moliFontFaceSetStatus";
pub(super) const FONT_FACE_SET_SIZE_SLOT: &str = "__moliFontFaceSetSize";
const FONT_FACE_SET_READY_SLOT: &str = "__moliFontFaceSetReady";
-const FONT_FACE_SET_LISTENERS_SLOT: &str = "__moliFontFaceSetListeners";
mod events;
mod font_face;
diff --git a/moli-renderer-v8/src/context_bootstrap/css_fontface_runtime/events.rs b/moli-renderer-v8/src/context_bootstrap/css_fontface_runtime/events.rs
index 076cd51c2..cd539ddd7 100644
--- a/moli-renderer-v8/src/context_bootstrap/css_fontface_runtime/events.rs
+++ b/moli-renderer-v8/src/context_bootstrap/css_fontface_runtime/events.rs
@@ -102,7 +102,7 @@ pub(super) fn initialize_font_face_set_event_target<'s>(
scope: &mut v8::PinScope<'s, '_>,
object: v8::Local<'s, v8::Object>,
) {
- mark_simple_event_target_slot(scope, object, FONT_FACE_SET_LISTENERS_SLOT);
+ initialize_simple_event_target(scope, object);
for handler in FONT_FACE_SET_EVENT_HANDLERS {
set_private_value(scope, object, handler.slot_name, v8::null(scope).into());
}
@@ -144,7 +144,6 @@ fn font_face_set_event_handler_setter<'s>(
simple_object_event_set_handler(
scope,
args.this(),
- FONT_FACE_SET_LISTENERS_SLOT,
handler.event_type,
handler.slot_name,
args.get(0),
@@ -263,13 +262,7 @@ pub(super) fn dispatch_font_face_set_event<'s>(
fontfaces: Option<v8::Local<'s, v8::Array>>,
) -> bool {
let event = dispatched_font_face_set_load_event(scope, event_type, fontfaces);
- dispatch_simple_event_target_event(
- scope,
- object,
- FONT_FACE_SET_LISTENERS_SLOT,
- event_type,
- event,
- )
+ dispatch_simple_event_target_event(scope, object, event_type, event)
}
pub(super) fn notify_font_face_set_owners_of_load<'s>(
diff --git a/moli-renderer-v8/src/context_bootstrap/css_fontface_runtime/storage.rs b/moli-renderer-v8/src/context_bootstrap/css_fontface_runtime/storage.rs
index bc0014fe0..18667df6d 100644
--- a/moli-renderer-v8/src/context_bootstrap/css_fontface_runtime/storage.rs
+++ b/moli-renderer-v8/src/context_bootstrap/css_fontface_runtime/storage.rs
@@ -16,7 +16,7 @@ struct FontFaceSetObjectDeclaration {
manual_faces: (),
#[webapi(slot = FONT_FACE_SET_CONNECTED_FACES_SLOT, init = "array")]
connected_faces: (),
- #[webapi(slot = FONT_FACE_SET_LISTENERS_SLOT, init = "null_object")]
+ #[webapi(slot = crate::context_bootstrap::SIMPLE_EVENT_TARGET_LISTENERS_SLOT, init = "null_object")]
listeners: (),
#[webapi(slot = FONT_FACE_SET_STATUS_SLOT, init = string("loaded"))]
status: (),
diff --git a/moli-renderer-v8/src/context_bootstrap/exposed_interfaces/finalize.rs b/moli-renderer-v8/src/context_bootstrap/exposed_interfaces/finalize.rs
index c9677dd73..1b77b161c 100644
--- a/moli-renderer-v8/src/context_bootstrap/exposed_interfaces/finalize.rs
+++ b/moli-renderer-v8/src/context_bootstrap/exposed_interfaces/finalize.rs
@@ -8,7 +8,6 @@ use crate::context_bootstrap::{
performance_runtime::finalize_performance_observer_realm_bindings,
web_audio_runtime::finalize_base_audio_context_realm_bindings,
};
-use crate::network_host::finalize_xml_http_request_event_target_realm_bindings;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
enum RealmDependentFinalizer {
@@ -18,7 +17,6 @@ enum RealmDependentFinalizer {
NavigatorCredentialsSecureContextSurface,
CryptoSecureContextSurface,
BaseAudioContextSecureContextSurface,
- XmlHttpRequestEventTargetState,
NotificationPermission,
PointerEventSecureContextSurface,
PerformanceWindowAccessors,
@@ -56,10 +54,6 @@ const REALM_DEPENDENT_FINALIZER_ALLOWLIST: &[(&str, RealmDependentFinalizer)] =
"Crypto",
RealmDependentFinalizer::CryptoSecureContextSurface,
),
- (
- "XMLHttpRequestEventTarget",
- RealmDependentFinalizer::XmlHttpRequestEventTargetState,
- ),
(
"Notification",
RealmDependentFinalizer::NotificationPermission,
@@ -137,9 +131,6 @@ pub(super) fn finalize_materialized_interface<'s>(
RealmDependentFinalizer::CryptoSecureContextSurface => {
finalize_crypto_realm_bindings(scope, prototype)
}
- RealmDependentFinalizer::XmlHttpRequestEventTargetState => {
- finalize_xml_http_request_event_target_realm_bindings(scope, prototype)
- }
RealmDependentFinalizer::NotificationPermission => {
finalize_notification_realm_bindings(scope, constructor.into())
}
@@ -204,7 +195,6 @@ mod tests {
"Navigator",
"BaseAudioContext",
"Crypto",
- "XMLHttpRequestEventTarget",
"Notification",
"PointerEvent",
"HTMLElement",
@@ -222,6 +212,7 @@ mod tests {
"ElementInternals",
"NavigationTransition",
"XMLHttpRequest",
+ "XMLHttpRequestEventTarget",
] {
assert_eq!(realm_dependent_finalizer(static_owner), None);
}
diff --git a/moli-renderer-v8/src/context_bootstrap/exposed_interfaces/tests/finalization.rs b/moli-renderer-v8/src/context_bootstrap/exposed_interfaces/tests/finalization.rs
index 8120e8e0f..8bc3817a9 100644
--- a/moli-renderer-v8/src/context_bootstrap/exposed_interfaces/tests/finalization.rs
+++ b/moli-renderer-v8/src/context_bootstrap/exposed_interfaces/tests/finalization.rs
@@ -258,23 +258,55 @@ fn shared_binding_helpers_preserve_intrinsics_after_author_overrides() {
}
#[test]
-fn materialized_xhr_event_target_initializes_its_private_state() {
- with_unpublished_interface("XMLHttpRequestEventTarget", |scope, interface| {
+fn materialized_xhr_initializes_separate_listener_registries_on_its_instances() {
+ with_unpublished_interface("XMLHttpRequest", |scope, interface| {
assert!(
ensure_intrinsic_interface_prototype(scope, interface.name)
.expect("event target materialization")
.strict_equals(interface.prototype.into())
);
- let listener_slot = get_private_value(
- scope,
- interface.prototype,
- crate::context_bootstrap::SIMPLE_EVENT_TARGET_SLOT,
- )
- .expect("listener slot name")
- .to_string(scope)
- .expect("listener slot string")
- .to_rust_string_lossy(scope);
- assert_eq!(listener_slot, "__moliXhrEventTargetListeners");
+ let mut registries: Vec<v8::Local<v8::Object>> = Vec::new();
+ for _ in 0..2 {
+ let xhr = interface
+ .constructor
+ .new_instance(scope, &[])
+ .expect("XHR instance");
+ let upload = xhr
+ .get(scope, v8str(scope, "upload").into())
+ .and_then(|value| v8::Local::<v8::Object>::try_from(value).ok())
+ .expect("XHR upload");
+ for target in [xhr, upload] {
+ let registry = get_private_value(
+ scope,
+ target,
+ crate::context_bootstrap::SIMPLE_EVENT_TARGET_LISTENERS_SLOT,
+ )
+ .and_then(|value| v8::Local::<v8::Object>::try_from(value).ok())
+ .expect("instance listener registry");
+ assert!(registry.get_prototype(scope).unwrap().is_null());
+ assert!(
+ registries
+ .iter()
+ .all(|other| !registry.strict_equals((*other).into()))
+ );
+ registries.push(registry);
+ }
+ }
+ for name in [
+ "XMLHttpRequest",
+ "XMLHttpRequestUpload",
+ "XMLHttpRequestEventTarget",
+ ] {
+ let prototype = ensure_intrinsic_interface_prototype(scope, name).unwrap();
+ assert!(
+ get_private_value(
+ scope,
+ prototype,
+ crate::context_bootstrap::SIMPLE_EVENT_TARGET_LISTENERS_SLOT,
+ )
+ .is_none()
+ );
+ }
assert!(matches!(
&*interface.realm.entry(interface.id).unwrap(),
RealmInterfaceEntry::Ready
diff --git a/moli-renderer-v8/src/context_bootstrap/file_api/file_reader/events.rs b/moli-renderer-v8/src/context_bootstrap/file_api/file_reader/events.rs
index 2a9f73501..ab830fb4b 100644
--- a/moli-renderer-v8/src/context_bootstrap/file_api/file_reader/events.rs
+++ b/moli-renderer-v8/src/context_bootstrap/file_api/file_reader/events.rs
@@ -24,7 +24,7 @@ pub(in crate::context_bootstrap) fn file_reader_add_event_listener_callback<'s>(
args: v8::FunctionCallbackArguments<'s>,
mut rv: v8::ReturnValue<'_, v8::Value>,
) {
- simple_object_event_target_add_listener(scope, &args, FILE_READER_LISTENERS_SLOT);
+ simple_object_event_target_add_listener(scope, &args);
rv.set_undefined();
}
@@ -33,7 +33,7 @@ pub(in crate::context_bootstrap) fn file_reader_remove_event_listener_callback<'
args: v8::FunctionCallbackArguments<'s>,
mut rv: v8::ReturnValue<'_, v8::Value>,
) {
- simple_object_event_target_remove_listener(scope, &args, FILE_READER_LISTENERS_SLOT);
+ simple_object_event_target_remove_listener(scope, &args);
rv.set_undefined();
}
@@ -55,11 +55,5 @@ pub(in crate::context_bootstrap::file_api::file_reader) fn dispatch_file_reader_
}
.bind(scope)
.expect("FileReader event fallback declaration should bind");
- let _ = dispatch_simple_event_target_event(
- scope,
- reader,
- FILE_READER_LISTENERS_SLOT,
- event_type,
- event,
- );
+ let _ = dispatch_simple_event_target_event(scope, reader, event_type, event);
}
diff --git a/moli-renderer-v8/src/context_bootstrap/file_api/file_reader/state.rs b/moli-renderer-v8/src/context_bootstrap/file_api/file_reader/state.rs
index d7c3463f0..7ef8b550c 100644
--- a/moli-renderer-v8/src/context_bootstrap/file_api/file_reader/state.rs
+++ b/moli-renderer-v8/src/context_bootstrap/file_api/file_reader/state.rs
@@ -10,8 +10,8 @@ const FILE_READER_ERROR_SLOT: &str = "__lmFileReaderError";
#[derive(Default, WebApiObject)]
#[webapi(interface = web_api_interfaces::FileReader)]
struct FileReaderObjectDeclaration {
- #[webapi(slot = SIMPLE_EVENT_TARGET_SLOT, value = FILE_READER_LISTENERS_SLOT)]
- event_target_slot: (),
+ #[webapi(slot = SIMPLE_EVENT_TARGET_LISTENERS_SLOT, init = "null_object")]
+ event_listeners: (),
#[webapi(slot = FILE_READER_READY_STATE_SLOT, init = 0)]
ready_state: (),
@@ -22,9 +22,6 @@ struct FileReaderObjectDeclaration {
#[webapi(slot = FILE_READER_ERROR_SLOT, init = "null")]
error: (),
- #[webapi(slot = FILE_READER_LISTENERS_SLOT, init = "null_object")]
- listeners: (),
-
#[webapi(slot = FILE_READER_SCHEDULED_SLOT, init = false)]
scheduled: (),
diff --git a/moli-renderer-v8/src/context_bootstrap/idle_detection.rs b/moli-renderer-v8/src/context_bootstrap/idle_detection.rs
index e4ed782ea..5d82941fb 100644
--- a/moli-renderer-v8/src/context_bootstrap/idle_detection.rs
+++ b/moli-renderer-v8/src/context_bootstrap/idle_detection.rs
@@ -1,6 +1,7 @@
use super::{
- SIMPLE_EVENT_TARGET_SLOT, dispatch_simple_event_target_event, global_constructor_object,
- simple_event_target_handler_getter_callback, simple_event_target_handler_setter_callback,
+ SIMPLE_EVENT_TARGET_LISTENERS_SLOT, dispatch_simple_event_target_event,
+ global_constructor_object, simple_event_target_handler_getter_callback,
+ simple_event_target_handler_setter_callback,
};
use crate::web_api_interfaces;
use crate::{
@@ -16,7 +17,6 @@ use moli_webapi_declare::{WebApiFunctionTemplate, WebApiObject};
const IDLE_DETECTOR_STARTED_SLOT: &str = "__lmIdleDetectorStarted";
const IDLE_DETECTOR_USER_ACTIVE_SLOT: &str = "__lmIdleDetectorUserActive";
const IDLE_DETECTOR_SCREEN_UNLOCKED_SLOT: &str = "__lmIdleDetectorScreenUnlocked";
-const IDLE_DETECTOR_LISTENERS_SLOT: &str = "__lmIdleDetectorListeners";
const IDLE_DETECTOR_REGISTRY_SLOT: &str = "__lmIdleDetectorRegistry";
const MINIMUM_IDLE_THRESHOLD_MS: u32 = 60_000;
const ACTUAL_IDLE_STATE: crate::protocol_types::EmulatedIdleOverride =
@@ -37,8 +37,8 @@ struct IdleDetectorObjectDeclaration {
#[webapi(slot = IDLE_DETECTOR_SCREEN_UNLOCKED_SLOT)]
is_screen_unlocked: bool,
- #[webapi(slot = SIMPLE_EVENT_TARGET_SLOT, value = IDLE_DETECTOR_LISTENERS_SLOT)]
- event_target_slot: (),
+ #[webapi(slot = SIMPLE_EVENT_TARGET_LISTENERS_SLOT, init = "null_object")]
+ event_listeners: (),
}
#[derive(WebApiFunctionTemplate)]
@@ -381,13 +381,7 @@ fn dispatch_idle_detector_change_event<'s>(
return;
};
mark_event_trusted(scope, event);
- let _ = dispatch_simple_event_target_event(
- scope,
- detector,
- IDLE_DETECTOR_LISTENERS_SLOT,
- "change",
- event,
- );
+ let _ = dispatch_simple_event_target_event(scope, detector, "change", event);
}
fn reject_type_error<'s>(
diff --git a/moli-renderer-v8/src/context_bootstrap/indexed_db/core.rs b/moli-renderer-v8/src/context_bootstrap/indexed_db/core.rs
index 400d11aff..460774c74 100644
--- a/moli-renderer-v8/src/context_bootstrap/indexed_db/core.rs
+++ b/moli-renderer-v8/src/context_bootstrap/indexed_db/core.rs
@@ -2,13 +2,13 @@ use super::{
CursorDirection, CursorSnapshotEntry, DatabaseHandle, DatabaseInfo,
INDEXED_DB_CURSOR_ENTRIES_SLOT, INDEXED_DB_CURSOR_KEY_ONLY_SLOT,
INDEXED_DB_CURSOR_POSITION_SLOT, INDEXED_DB_DATABASE_CLOSED_SLOT,
- INDEXED_DB_DATABASE_HANDLE_SLOT, INDEXED_DB_DATABASE_KEY_SLOT, INDEXED_DB_EVENT_LISTENERS_SLOT,
- INDEXED_DB_REQUEST_ERROR_SLOT, INDEXED_DB_REQUEST_READY_STATE_SLOT,
- INDEXED_DB_REQUEST_RESULT_SLOT, INDEXED_DB_TRANSACTION_DB_KEY_SLOT,
- INDEXED_DB_TRANSACTION_FINISHED_SLOT, INDEXED_DB_TRANSACTION_HANDLE_SLOT, IdbKeyRangeQuery,
- IndexEntry, IndexInfo, IndexedDbError, IndexedDbExecutionOwner, IndexedDbExternalObject,
- IndexedDbManager, IndexedDbObjectStoreMetadata, IndexedDbRuntimeArray, IndexedDbStorageScope,
- IndexedDbValue, IndexedDbWrapperKind, Key, KeyPath, ObjectStoreInfo, PreparedObjectStoreWrite,
+ INDEXED_DB_DATABASE_HANDLE_SLOT, INDEXED_DB_DATABASE_KEY_SLOT, INDEXED_DB_REQUEST_ERROR_SLOT,
+ INDEXED_DB_REQUEST_READY_STATE_SLOT, INDEXED_DB_REQUEST_RESULT_SLOT,
+ INDEXED_DB_TRANSACTION_DB_KEY_SLOT, INDEXED_DB_TRANSACTION_FINISHED_SLOT,
+ INDEXED_DB_TRANSACTION_HANDLE_SLOT, IdbKeyRangeQuery, IndexEntry, IndexInfo, IndexedDbError,
+ IndexedDbExecutionOwner, IndexedDbExternalObject, IndexedDbManager,
+ IndexedDbObjectStoreMetadata, IndexedDbRuntimeArray, IndexedDbStorageScope, IndexedDbValue,
+ IndexedDbWrapperKind, Key, KeyPath, ObjectStoreInfo, PreparedObjectStoreWrite,
PreparedObjectStoreWriteError, TransactionHandle, TransactionMode,
context_host_ptr_from_global_bridge, global_constructor_prototype,
indexed_db_database_store_metadata, indexed_db_object_store_metadata, indexed_db_runtime_array,
diff --git a/moli-renderer-v8/src/context_bootstrap/indexed_db/core/objects/creation/database.rs b/moli-renderer-v8/src/context_bootstrap/indexed_db/core/objects/creation/database.rs
index 9badb625f..d343b43b0 100644
--- a/moli-renderer-v8/src/context_bootstrap/indexed_db/core/objects/creation/database.rs
+++ b/moli-renderer-v8/src/context_bootstrap/indexed_db/core/objects/creation/database.rs
@@ -1,6 +1,6 @@
use super::*;
use crate::context_bootstrap::{
- SIMPLE_EVENT_TARGET_SLOT, simple_event_target_handler_getter_callback,
+ SIMPLE_EVENT_TARGET_LISTENERS_SLOT, simple_event_target_handler_getter_callback,
simple_event_target_handler_setter_callback,
};
use crate::web_api_interfaces;
@@ -15,9 +15,7 @@ use moli_webapi_declare::WebApiObject;
enumerable
)]
struct IdbDatabaseObjectDeclaration<'scope, 'value> {
- #[webapi(slot = SIMPLE_EVENT_TARGET_SLOT, value = INDEXED_DB_EVENT_LISTENERS_SLOT)]
- event_target_slot: (),
- #[webapi(slot = INDEXED_DB_EVENT_LISTENERS_SLOT, init = "null_object")]
+ #[webapi(slot = SIMPLE_EVENT_TARGET_LISTENERS_SLOT, init = "null_object")]
event_listeners: (),
name: &'value str,
diff --git a/moli-renderer-v8/src/context_bootstrap/indexed_db/core/objects/creation/request.rs b/moli-renderer-v8/src/context_bootstrap/indexed_db/core/objects/creation/request.rs
index 480bb78de..4689e1961 100644
--- a/moli-renderer-v8/src/context_bootstrap/indexed_db/core/objects/creation/request.rs
+++ b/moli-renderer-v8/src/context_bootstrap/indexed_db/core/objects/creation/request.rs
@@ -1,6 +1,6 @@
use super::*;
use crate::context_bootstrap::{
- SIMPLE_EVENT_TARGET_SLOT, simple_event_target_handler_getter_callback,
+ SIMPLE_EVENT_TARGET_LISTENERS_SLOT, simple_event_target_handler_getter_callback,
simple_event_target_handler_setter_callback,
};
use crate::web_api_interfaces;
@@ -9,9 +9,7 @@ use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
#[webapi(prototype = "Object", interface = web_api_interfaces::IDBRequest)]
struct IdbRequestObjectDeclaration<'scope> {
- #[webapi(slot = SIMPLE_EVENT_TARGET_SLOT, value = INDEXED_DB_EVENT_LISTENERS_SLOT)]
- event_target_slot: (),
- #[webapi(slot = INDEXED_DB_EVENT_LISTENERS_SLOT, init = "null_object")]
+ #[webapi(slot = SIMPLE_EVENT_TARGET_LISTENERS_SLOT, init = "null_object")]
event_listeners: (),
#[webapi(data_property, enumerable)]
diff --git a/moli-renderer-v8/src/context_bootstrap/indexed_db/core/objects/creation/transaction.rs b/moli-renderer-v8/src/context_bootstrap/indexed_db/core/objects/creation/transaction.rs
index 5e2d3c7db..8688e827c 100644
--- a/moli-renderer-v8/src/context_bootstrap/indexed_db/core/objects/creation/transaction.rs
+++ b/moli-renderer-v8/src/context_bootstrap/indexed_db/core/objects/creation/transaction.rs
@@ -1,6 +1,6 @@
use super::*;
use crate::context_bootstrap::{
- SIMPLE_EVENT_TARGET_SLOT, simple_event_target_handler_getter_callback,
+ SIMPLE_EVENT_TARGET_LISTENERS_SLOT, simple_event_target_handler_getter_callback,
simple_event_target_handler_setter_callback,
};
use crate::web_api_interfaces;
@@ -14,9 +14,7 @@ use moli_webapi_declare::WebApiObject;
enumerable
)]
struct IdbTransactionObjectDeclaration<'scope> {
- #[webapi(slot = SIMPLE_EVENT_TARGET_SLOT, value = INDEXED_DB_EVENT_LISTENERS_SLOT)]
- event_target_slot: (),
- #[webapi(slot = INDEXED_DB_EVENT_LISTENERS_SLOT, init = "null_object")]
+ #[webapi(slot = SIMPLE_EVENT_TARGET_LISTENERS_SLOT, init = "null_object")]
event_listeners: (),
db: v8::Local<'scope, v8::Object>,
diff --git a/moli-renderer-v8/src/context_bootstrap/indexed_db/event_target/dispatch.rs b/moli-renderer-v8/src/context_bootstrap/indexed_db/event_target/dispatch.rs
index 862e1c349..d99192e15 100644
--- a/moli-renderer-v8/src/context_bootstrap/indexed_db/event_target/dispatch.rs
+++ b/moli-renderer-v8/src/context_bootstrap/indexed_db/event_target/dispatch.rs
@@ -37,13 +37,7 @@ pub(in crate::context_bootstrap::indexed_db) fn dispatch_idb_event_object<'s>(
};
let owner_scope = idb_event_target_owner_scope(scope, target);
let previous_owner = owner_scope.enter(scope);
- let uncanceled = dispatch_simple_event_target_event(
- scope,
- target,
- INDEXED_DB_EVENT_LISTENERS_SLOT,
- &event_type,
- event,
- );
+ let uncanceled = dispatch_simple_event_target_event(scope, target, &event_type, event);
owner_scope.defer_restore(scope, previous_owner);
uncanceled
diff --git a/moli-renderer-v8/src/context_bootstrap/indexed_db/event_target/target.rs b/moli-renderer-v8/src/context_bootstrap/indexed_db/event_target/target.rs
index 90ad87189..c7909bda5 100644
--- a/moli-renderer-v8/src/context_bootstrap/indexed_db/event_target/target.rs
+++ b/moli-renderer-v8/src/context_bootstrap/indexed_db/event_target/target.rs
@@ -11,7 +11,7 @@ pub(in crate::context_bootstrap::indexed_db) fn idb_event_target_add_event_liste
if !require_idb_event_target(scope, args.this()) {
return;
}
- simple_object_event_target_add_listener(scope, &args, INDEXED_DB_EVENT_LISTENERS_SLOT);
+ simple_object_event_target_add_listener(scope, &args);
}
pub(in crate::context_bootstrap::indexed_db) fn idb_event_target_remove_event_listener_callback<
@@ -24,7 +24,7 @@ pub(in crate::context_bootstrap::indexed_db) fn idb_event_target_remove_event_li
if !require_idb_event_target(scope, args.this()) {
return;
}
- simple_object_event_target_remove_listener(scope, &args, INDEXED_DB_EVENT_LISTENERS_SLOT);
+ simple_object_event_target_remove_listener(scope, &args);
}
pub(in crate::context_bootstrap::indexed_db) fn idb_event_target_dispatch_event_callback<'s>(
diff --git a/moli-renderer-v8/src/context_bootstrap/indexed_db/mod.rs b/moli-renderer-v8/src/context_bootstrap/indexed_db/mod.rs
index 0c1c6b5b2..0a4fbb154 100644
--- a/moli-renderer-v8/src/context_bootstrap/indexed_db/mod.rs
+++ b/moli-renderer-v8/src/context_bootstrap/indexed_db/mod.rs
@@ -92,9 +92,7 @@ fn indexed_db_private_slot_fallback_allowed(slot: &str) -> bool {
}
matches!(
slot,
- INDEXED_DB_TYPED_STATE_ID_SLOT
- | INDEXED_DB_TYPED_TASK_ID_SLOT
- | INDEXED_DB_EVENT_LISTENERS_SLOT
+ INDEXED_DB_TYPED_STATE_ID_SLOT | INDEXED_DB_TYPED_TASK_ID_SLOT
)
}
diff --git a/moli-renderer-v8/src/context_bootstrap/indexed_db/runtime.rs b/moli-renderer-v8/src/context_bootstrap/indexed_db/runtime.rs
index 667040a7b..ba6835653 100644
--- a/moli-renderer-v8/src/context_bootstrap/indexed_db/runtime.rs
+++ b/moli-renderer-v8/src/context_bootstrap/indexed_db/runtime.rs
@@ -2,7 +2,6 @@ use super::*;
use crate::context_bootstrap::exposed_interfaces::build_intrinsic_interface_instance;
use crate::util::{get_private_object, get_private_value, set_private_value};
use crate::web_api_interfaces;
-use moli_webapi_declare::WebApiObject;
use std::rc::Rc;
const INDEXED_DB_RUNTIME_STATE_SLOT: &str = "moli.IndexedDb.runtimeState";
@@ -14,13 +13,6 @@ const INDEXED_DB_BLOCKED_OPEN_QUEUE_FIELD: &str = "moli.IndexedDb.runtime.blocke
const INDEXED_DB_READWRITE_TRANSACTION_QUEUE_FIELD: &str =
"moli.IndexedDb.runtime.readwriteTransactionQueue";
-#[derive(Default, WebApiObject)]
-#[webapi(interface = web_api_interfaces::IDBFactory)]
-struct IndexedDbFactoryRuntimeDeclaration {
- #[webapi(slot = INDEXED_DB_EVENT_LISTENERS_SLOT, init = "null_object")]
- event_listeners: (),
-}
-
struct IndexedDbWorkerTaskWake {
tx: tokio::sync::mpsc::UnboundedSender<()>,
}
@@ -240,17 +232,6 @@ fn ensure_runtime_factory_field<'s>(
return Some(factory);
}
let _ = factory.set_prototype(scope, factory_proto.into());
- if object_property_as_object(scope, factory, INDEXED_DB_EVENT_LISTENERS_SLOT).is_none() {
- // Listener maps use event type strings as dictionary keys, so they must
- // not inherit attacker-controlled Object.prototype properties.
- let listeners = new_null_prototype_object(scope);
- set_indexed_db_slot_value(
- scope,
- factory,
- INDEXED_DB_EVENT_LISTENERS_SLOT,
- listeners.into(),
- );
- }
define_non_enumerable_bool_property(scope, state, INDEXED_DB_FACTORY_INITIALIZED_FIELD, true);
Some(factory)
}
@@ -310,16 +291,9 @@ fn build_indexed_db_factory_object<'s>(
// Materialize the realm's intrinsic before constructing the factory, without
// reading an author-replaced public IDBFactory binding on first use.
let factory = build_intrinsic_interface_instance(scope, "IDBFactory").ok()?;
- IndexedDbFactoryRuntimeDeclaration::default()
+ web_api_interfaces::IDBFactory::DESCRIPTOR
.initialize(scope, factory)
.ok()?;
- let listeners = new_null_prototype_object(scope);
- set_indexed_db_slot_value(
- scope,
- factory,
- INDEXED_DB_EVENT_LISTENERS_SLOT,
- listeners.into(),
- );
let owner = indexed_db_execution_owner_for_object(scope, factory);
let storage_scope = owner
.execution_context()
diff --git a/moli-renderer-v8/src/context_bootstrap/indexed_db/slots.rs b/moli-renderer-v8/src/context_bootstrap/indexed_db/slots.rs
index d52e50a73..855c62d3a 100644
--- a/moli-renderer-v8/src/context_bootstrap/indexed_db/slots.rs
+++ b/moli-renderer-v8/src/context_bootstrap/indexed_db/slots.rs
@@ -1,6 +1,5 @@
pub(super) const INDEXED_DB_TYPED_STATE_ID_SLOT: &str = "moli.IndexedDb.typedStateId";
pub(super) const INDEXED_DB_TYPED_TASK_ID_SLOT: &str = "moli.IndexedDb.typedTaskId";
-pub(super) const INDEXED_DB_EVENT_LISTENERS_SLOT: &str = "moli.IndexedDb.eventListeners";
pub(super) const INDEXED_DB_PENDING_RESULT_SLOT: &str = "moli.IndexedDb.pendingResult";
pub(super) const INDEXED_DB_PENDING_ERROR_SLOT: &str = "moli.IndexedDb.pendingError";
pub(super) const INDEXED_DB_PENDING_CURSOR_SLOT: &str = "moli.IndexedDb.pendingCursor";
diff --git a/moli-renderer-v8/src/context_bootstrap/location_history_storage.rs b/moli-renderer-v8/src/context_bootstrap/location_history_storage.rs
index 22aa13647..5021e88dc 100644
--- a/moli-renderer-v8/src/context_bootstrap/location_history_storage.rs
+++ b/moli-renderer-v8/src/context_bootstrap/location_history_storage.rs
@@ -1,5 +1,3 @@
-pub(super) const NAVIGATION_ENTRY_EVENT_LISTENERS_SLOT: &str = "__lmNavigationEntryEventListeners";
-pub(super) const NAVIGATION_EVENT_LISTENERS_SLOT: &str = "__lmNavigationEventListeners";
pub(super) const NAVIGATION_CURRENT_ENTRY_SLOT: &str = "__lmNavigationCurrentEntry";
pub(super) const NAVIGATION_ACTIVATION_SLOT: &str = "__lmNavigationActivation";
pub(super) const NAVIGATION_TRANSITION_SLOT: &str = "__lmNavigationTransition";
diff --git a/moli-renderer-v8/src/context_bootstrap/media_cues.rs b/moli-renderer-v8/src/context_bootstrap/media_cues.rs
index ef6321ebf..cbe798a94 100644
--- a/moli-renderer-v8/src/context_bootstrap/media_cues.rs
+++ b/moli-renderer-v8/src/context_bootstrap/media_cues.rs
@@ -1,6 +1,6 @@
use super::super::util::{throw_type_error, v8_string};
use super::context_host_ptr_from_global_bridge;
-use super::{mark_simple_event_target_slot, simple_object_event_set_handler};
+use super::{initialize_simple_event_target, simple_object_event_set_handler};
use crate::document_runtime::DomHandle;
use crate::native_bridge::JsContextHost;
use crate::native_bridge::throw_dom_exception;
@@ -22,7 +22,6 @@ const TEXT_TRACK_CUE_SIZE_SLOT: &str = "__moliTextTrackCueSize";
const TEXT_TRACK_CUE_ALIGN_SLOT: &str = "__moliTextTrackCueAlign";
const TEXT_TRACK_CUE_ONENTER_SLOT: &str = "__moliTextTrackCueOnEnter";
const TEXT_TRACK_CUE_ONEXIT_SLOT: &str = "__moliTextTrackCueOnExit";
-const TEXT_TRACK_CUE_LISTENERS_SLOT: &str = "__moliTextTrackCueListeners";
const TEXT_TRACK_CUE_TEXT_SLOT: &str = "__moliTextTrackCueText";
const MEDIA_ERROR_CODE_SLOT: &str = "__moliMediaErrorCode";
const MEDIA_ERROR_MESSAGE_SLOT: &str = "__moliMediaErrorMessage";
@@ -304,7 +303,7 @@ pub(super) fn vtt_cue_constructor_callback<'s>(
return;
};
- mark_simple_event_target_slot(scope, args.this(), TEXT_TRACK_CUE_LISTENERS_SLOT);
+ initialize_simple_event_target(scope, args.this());
VttCuePrivateStateDeclaration::new(parsed.start_time, parsed.end_time, parsed.text)
.initialize(scope, args.this())
.expect("VTTCue private state declaration should initialize");
@@ -1061,14 +1060,7 @@ fn event_handler_setter<'s>(
let Some(receiver) = text_track_cue_receiver(scope, &args) else {
return;
};
- simple_object_event_set_handler(
- scope,
- receiver,
- TEXT_TRACK_CUE_LISTENERS_SLOT,
- event_type,
- slot,
- args.get(0),
- );
+ simple_object_event_set_handler(scope, receiver, event_type, slot, args.get(0));
}
fn finite_double_property<'s>(
diff --git a/moli-renderer-v8/src/context_bootstrap/media_queries.rs b/moli-renderer-v8/src/context_bootstrap/media_queries.rs
index b20da491f..73ac3159f 100644
--- a/moli-renderer-v8/src/context_bootstrap/media_queries.rs
+++ b/moli-renderer-v8/src/context_bootstrap/media_queries.rs
@@ -12,21 +12,20 @@ pub(in crate::context_bootstrap) use self::events::dispatch_media_query_list_eve
pub(crate) use self::events::{
SimpleObjectEventListenerInspectorSnapshot, SimpleObjectEventListenerSnapshot,
dispatch_simple_event_target_event, dispatch_simple_event_target_event_collecting_errors,
- install_simple_event_target_handlers, install_simple_event_target_methods,
- invoke_simple_event_listener, mark_simple_event_target_slot,
+ initialize_simple_event_target, install_simple_event_target_handlers,
+ install_simple_event_target_methods, invoke_simple_event_listener, is_simple_event_target,
simple_event_target_add_event_listener_callback, simple_event_target_dispatch_event_callback,
simple_event_target_handler_getter_callback, simple_event_target_handler_setter_callback,
simple_event_target_inspector_listener_snapshots,
- simple_event_target_remove_event_listener_callback, simple_event_target_slot_name,
- simple_object_event_listeners_snapshot, simple_object_event_set_handler,
- simple_object_event_target_add_listener, simple_object_event_target_remove_listener,
- simple_object_has_event_listeners,
+ simple_event_target_remove_event_listener_callback, simple_object_event_listeners_snapshot,
+ simple_object_event_set_handler, simple_object_event_target_add_listener,
+ simple_object_event_target_remove_listener, simple_object_has_event_listeners,
};
pub(super) use self::events::{
media_query_list_add_listener_callback, media_query_list_remove_listener_callback,
};
use super::{
- MEDIA_QUERY_LIST_LISTENERS_SLOT, SIMPLE_EVENT_TARGET_SLOT, object_property_as_array,
- object_string_property_defined, v8str,
+ SIMPLE_EVENT_TARGET_LISTENERS_SLOT, object_property_as_array, object_string_property_defined,
+ v8str,
};
diff --git a/moli-renderer-v8/src/context_bootstrap/media_queries/evaluation.rs b/moli-renderer-v8/src/context_bootstrap/media_queries/evaluation.rs
index 53f496ef0..919513470 100644
--- a/moli-renderer-v8/src/context_bootstrap/media_queries/evaluation.rs
+++ b/moli-renderer-v8/src/context_bootstrap/media_queries/evaluation.rs
@@ -1,12 +1,13 @@
use super::event::create_media_query_list_event;
use super::{
- dispatch_media_query_list_event, mark_simple_event_target_slot, simple_object_event_set_handler,
+ dispatch_media_query_list_event, initialize_simple_event_target,
+ simple_object_event_set_handler,
};
use crate::context_bootstrap::DEFAULT_WINDOW_SURFACE_PROFILE;
use crate::context_bootstrap::current_window_style_viewport;
use crate::context_bootstrap::{
- MEDIA_QUERY_LIST_LISTENERS_SLOT, MEDIA_QUERY_LIST_MATCHES_SLOT, MEDIA_QUERY_LIST_MEDIA_SLOT,
- MEDIA_QUERY_LIST_ONCHANGE_SLOT, MEDIA_QUERY_LIST_REGISTRY_SLOT,
+ MEDIA_QUERY_LIST_MATCHES_SLOT, MEDIA_QUERY_LIST_MEDIA_SLOT, MEDIA_QUERY_LIST_ONCHANGE_SLOT,
+ MEDIA_QUERY_LIST_REGISTRY_SLOT,
};
use crate::context_bootstrap::{global_queue_array, push_object_to_global_registry};
use crate::style_engine::{
@@ -139,7 +140,6 @@ fn media_query_list_onchange_setter_callback<'s>(
simple_object_event_set_handler(
scope,
target,
- MEDIA_QUERY_LIST_LISTENERS_SLOT,
"change",
MEDIA_QUERY_LIST_ONCHANGE_SLOT,
args.get(0),
@@ -174,7 +174,7 @@ pub(crate) fn window_match_media_callback<'s>(
let mql = MediaQueryListObjectDeclaration::new(serialized_query, matches)
.bind(scope)
.expect("MediaQueryList declaration should bind");
- mark_simple_event_target_slot(scope, mql, MEDIA_QUERY_LIST_LISTENERS_SLOT);
+ initialize_simple_event_target(scope, mql);
if global_queue_array(scope, MEDIA_QUERY_LIST_REGISTRY_SLOT).is_none() {
let global = scope.get_current_context().global(scope);
diff --git a/moli-renderer-v8/src/context_bootstrap/media_queries/events.rs b/moli-renderer-v8/src/context_bootstrap/media_queries/events.rs
index bb7043bee..d128e1130 100644
--- a/moli-renderer-v8/src/context_bootstrap/media_queries/events.rs
+++ b/moli-renderer-v8/src/context_bootstrap/media_queries/events.rs
@@ -1,6 +1,6 @@
use super::{
- MEDIA_QUERY_LIST_LISTENERS_SLOT, SIMPLE_EVENT_TARGET_SLOT, object_property_as_array,
- object_string_property_defined, v8str,
+ SIMPLE_EVENT_TARGET_LISTENERS_SLOT, object_property_as_array, object_string_property_defined,
+ v8str,
};
const SIMPLE_EVENT_TARGET_HANDLER_SLOT_FIELD: &str = "handlerSlot";
@@ -14,14 +14,13 @@ pub(in crate::context_bootstrap) use media_query_list::{
pub(crate) use simple_event_target::{
SimpleObjectEventListenerInspectorSnapshot, SimpleObjectEventListenerSnapshot,
dispatch_simple_event_target_event, dispatch_simple_event_target_event_collecting_errors,
- install_simple_event_target_handlers, install_simple_event_target_methods,
- invoke_simple_event_listener, mark_simple_event_target_slot,
+ initialize_simple_event_target, install_simple_event_target_handlers,
+ install_simple_event_target_methods, invoke_simple_event_listener, is_simple_event_target,
simple_event_target_add_event_listener_callback, simple_event_target_dispatch_event_callback,
simple_event_target_handler_getter_callback, simple_event_target_handler_setter_callback,
simple_event_target_inspector_listener_snapshots,
- simple_event_target_remove_event_listener_callback, simple_event_target_slot_name,
- simple_object_event_listeners_snapshot, simple_object_event_remove_listener_value_for_type,
- simple_object_event_set_handler, simple_object_event_target_add_listener,
- simple_object_event_target_register_webidl_listener,
+ simple_event_target_remove_event_listener_callback, simple_object_event_listeners_snapshot,
+ simple_object_event_remove_listener_value_for_type, simple_object_event_set_handler,
+ simple_object_event_target_add_listener, simple_object_event_target_register_webidl_listener,
simple_object_event_target_remove_listener, simple_object_has_event_listeners,
};
diff --git a/moli-renderer-v8/src/context_bootstrap/media_queries/events/media_query_list/callbacks.rs b/moli-renderer-v8/src/context_bootstrap/media_queries/events/media_query_list/callbacks.rs
index ff20104ef..5d96f1be9 100644
--- a/moli-renderer-v8/src/context_bootstrap/media_queries/events/media_query_list/callbacks.rs
+++ b/moli-renderer-v8/src/context_bootstrap/media_queries/events/media_query_list/callbacks.rs
@@ -22,7 +22,6 @@ pub(in crate::context_bootstrap) fn media_query_list_add_listener_callback<'s>(
simple_object_event_target_register_webidl_listener(
scope,
args.this(),
- MEDIA_QUERY_LIST_LISTENERS_SLOT,
"change".to_owned(),
listener,
webidl::EventListenerOptions::default(),
@@ -51,7 +50,6 @@ pub(in crate::context_bootstrap) fn media_query_list_remove_listener_callback<'s
simple_object_event_remove_listener_value_for_type(
scope,
args.this(),
- MEDIA_QUERY_LIST_LISTENERS_SLOT,
"change",
listener_value,
false,
diff --git a/moli-renderer-v8/src/context_bootstrap/media_queries/events/media_query_list/dispatch.rs b/moli-renderer-v8/src/context_bootstrap/media_queries/events/media_query_list/dispatch.rs
index ce9928336..3da9fe7b0 100644
--- a/moli-renderer-v8/src/context_bootstrap/media_queries/events/media_query_list/dispatch.rs
+++ b/moli-renderer-v8/src/context_bootstrap/media_queries/events/media_query_list/dispatch.rs
@@ -8,11 +8,5 @@ pub(in crate::context_bootstrap) fn dispatch_media_query_list_event<'s>(
let Some(event_type) = object_string_property_defined(scope, event, "type") else {
return false;
};
- dispatch_simple_event_target_event(
- scope,
- target,
- MEDIA_QUERY_LIST_LISTENERS_SLOT,
- &event_type,
- event,
- )
+ dispatch_simple_event_target_event(scope, target, &event_type, event)
}
diff --git a/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target.rs b/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target.rs
index 7c02b4b28..f3d491fc3 100644
--- a/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target.rs
+++ b/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target.rs
@@ -20,7 +20,7 @@ pub(crate) use handlers::{
install_simple_event_target_handlers, simple_event_target_handler_getter_callback,
simple_event_target_handler_setter_callback,
};
-pub(crate) use install::{install_simple_event_target_methods, mark_simple_event_target_slot};
+pub(crate) use install::install_simple_event_target_methods;
pub(crate) use listeners::{
SimpleObjectEventListenerInspectorSnapshot, SimpleObjectEventListenerSnapshot,
simple_event_target_inspector_listener_snapshots, simple_object_event_listeners_snapshot,
@@ -31,4 +31,5 @@ pub(crate) use listeners::{
simple_object_event_target_add_listener, simple_object_event_target_register_webidl_listener,
simple_object_event_target_remove_listener,
};
-pub(crate) use state::simple_event_target_slot_name;
+use state::simple_object_event_listener_registry;
+pub(crate) use state::{initialize_simple_event_target, is_simple_event_target};
diff --git a/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target/callbacks.rs b/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target/callbacks.rs
index 1facc61bc..eda501058 100644
--- a/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target/callbacks.rs
+++ b/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target/callbacks.rs
@@ -6,11 +6,10 @@ pub(crate) fn simple_event_target_add_event_listener_callback<'s>(
_rv: v8::ReturnValue<'s, v8::Value>,
) {
let target = args.this();
- let slot_name = simple_event_target_slot_name(scope, target);
- let Some(slot_name) = slot_name.as_deref() else {
+ if !is_simple_event_target(scope, target) {
return;
- };
- simple_object_event_target_add_listener(scope, &args, slot_name);
+ }
+ simple_object_event_target_add_listener(scope, &args);
}
pub(crate) fn simple_event_target_remove_event_listener_callback<'s>(
@@ -19,11 +18,10 @@ pub(crate) fn simple_event_target_remove_event_listener_callback<'s>(
_rv: v8::ReturnValue<'s, v8::Value>,
) {
let target = args.this();
- let slot_name = simple_event_target_slot_name(scope, target);
- let Some(slot_name) = slot_name.as_deref() else {
+ if !is_simple_event_target(scope, target) {
return;
- };
- simple_object_event_target_remove_listener(scope, &args, slot_name);
+ }
+ simple_object_event_target_remove_listener(scope, &args);
}
pub(crate) fn simple_event_target_dispatch_event_callback<'s>(
@@ -32,10 +30,9 @@ pub(crate) fn simple_event_target_dispatch_event_callback<'s>(
mut rv: v8::ReturnValue<'s, v8::Value>,
) {
let target = args.this();
- let slot_name = simple_event_target_slot_name(scope, target);
- let Some(slot_name) = slot_name.as_deref() else {
+ if !is_simple_event_target(scope, target) {
rv.set(v8::Boolean::new(scope, true).into());
return;
- };
- simple_object_event_target_dispatch(scope, &args, slot_name, &mut rv);
+ }
+ simple_object_event_target_dispatch(scope, &args, &mut rv);
}
diff --git a/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target/dispatch.rs b/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target/dispatch.rs
index ef3107cf9..fb6593fb2 100644
--- a/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target/dispatch.rs
+++ b/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target/dispatch.rs
@@ -22,7 +22,6 @@ pub(in crate::context_bootstrap::media_queries::events::simple_event_target) fn
>(
scope: &mut v8::PinScope<'s, '_>,
args: &v8::FunctionCallbackArguments<'s>,
- slot_name: &str,
rv: &mut v8::ReturnValue<'s, v8::Value>,
) {
let Some((event, event_type)) =
@@ -36,22 +35,18 @@ pub(in crate::context_bootstrap::media_queries::events::simple_event_target) fn
};
let target = args.this();
- let dispatch_result =
- dispatch_simple_event_target_event(scope, target, slot_name, &event_type, event);
+ let dispatch_result = dispatch_simple_event_target_event(scope, target, &event_type, event);
rv.set(v8::Boolean::new(scope, dispatch_result).into());
}
pub(crate) fn dispatch_simple_event_target_event<'s>(
scope: &mut v8::PinScope<'s, '_>,
target: v8::Local<'s, v8::Object>,
- slot_name: &str,
event_type: &str,
event: v8::Local<'s, v8::Object>,
) -> bool {
- dispatch_simple_event_target_event_collecting_errors(
- scope, target, slot_name, event_type, event, None,
- )
- .uncanceled
+ dispatch_simple_event_target_event_collecting_errors(scope, target, event_type, event, None)
+ .uncanceled
}
pub(crate) struct SimpleEventDispatchResult {
@@ -62,7 +57,6 @@ pub(crate) struct SimpleEventDispatchResult {
pub(crate) fn dispatch_simple_event_target_event_collecting_errors<'s>(
scope: &mut v8::PinScope<'s, '_>,
target: v8::Local<'s, v8::Object>,
- slot_name: &str,
event_type: &str,
event: v8::Local<'s, v8::Object>,
mut callback_errors: Option<&mut Vec<crate::exception_reporting::V8ExceptionReport>>,
@@ -83,14 +77,12 @@ pub(crate) fn dispatch_simple_event_target_event_collecting_errors<'s>(
'phases: for capture_phase in [true, false] {
// DOM clones the listener list for each invocation phase. A listener
// added during capture can participate in the subsequent bubble phase.
- let listeners =
- simple_object_event_listeners_snapshot(scope, target, slot_name, event_type);
+ let listeners = simple_object_event_listeners_snapshot(scope, target, event_type);
for listener in listeners
.iter()
.filter(|listener| listener.capture == capture_phase)
{
- let Some(listener) =
- listener.prepare_for_invocation(scope, target, slot_name, event_type)
+ let Some(listener) = listener.prepare_for_invocation(scope, target, event_type)
else {
continue;
};
diff --git a/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target/handlers.rs b/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target/handlers.rs
index 5c2d8c7cf..bf7404ce4 100644
--- a/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target/handlers.rs
+++ b/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target/handlers.rs
@@ -9,7 +9,7 @@ pub(crate) fn simple_event_target_handler_getter_callback<'s>(
args: v8::FunctionCallbackArguments<'s>,
mut rv: v8::ReturnValue<'_, v8::Value>,
) {
- let Some((property, _)) = handler_callback_data(scope, &args) else {
+ let Some(property) = handler_callback_data(scope, &args) else {
return;
};
rv.set(
@@ -22,13 +22,12 @@ pub(crate) fn simple_event_target_handler_setter_callback<'s>(
args: v8::FunctionCallbackArguments<'s>,
_rv: v8::ReturnValue<'_, v8::Value>,
) {
- let Some((property, slot)) = handler_callback_data(scope, &args) else {
+ let Some(property) = handler_callback_data(scope, &args) else {
return;
};
simple_object_event_set_handler(
scope,
args.this(),
- &slot,
property.strip_prefix("on").expect("event handler property"),
&property,
args.get(0),
@@ -38,14 +37,14 @@ pub(crate) fn simple_event_target_handler_setter_callback<'s>(
fn handler_callback_data<'s>(
scope: &mut v8::PinScope<'s, '_>,
args: &v8::FunctionCallbackArguments<'s>,
-) -> Option<(String, String)> {
- let Some(slot) = simple_event_target_slot_name(scope, args.this()) else {
+) -> Option<String> {
+ if !is_simple_event_target(scope, args.this()) {
throw_type_error(scope, "Illegal invocation");
return None;
- };
+ }
v8::Local::<v8::String>::try_from(args.data())
.ok()
- .map(|property| (property.to_rust_string_lossy(scope), slot))
+ .map(|property| property.to_rust_string_lossy(scope))
}
/// Install explicit EventHandler accessors on object-backed Window surfaces.
diff --git a/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target/install.rs b/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target/install.rs
index 6a90306f9..784fc688b 100644
--- a/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target/install.rs
+++ b/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target/install.rs
@@ -1,5 +1,4 @@
use super::*;
-use crate::util::set_private_value;
use crate::web_api_interfaces;
use moli_webapi_declare::WebApiObject;
@@ -26,23 +25,9 @@ struct SimpleEventTargetMethodsDeclaration {
pub(crate) fn install_simple_event_target_methods<'s>(
scope: &mut v8::PinScope<'s, '_>,
target: v8::Local<'s, v8::Object>,
- slot_name: &'static str,
) {
- mark_simple_event_target_slot(scope, target, slot_name);
+ initialize_simple_event_target(scope, target);
SimpleEventTargetMethodsDeclaration::new()
.initialize(scope, target)
.expect("simple event target declaration should initialize");
}
-
-pub(crate) fn mark_simple_event_target_slot<'s>(
- scope: &mut v8::PinScope<'s, '_>,
- target: v8::Local<'s, v8::Object>,
- slot_name: &'static str,
-) {
- set_private_value(
- scope,
- target,
- SIMPLE_EVENT_TARGET_SLOT,
- v8str(scope, slot_name).into(),
- );
-}
diff --git a/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target/listeners.rs b/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target/listeners.rs
index 0699d9821..6a3193e1a 100644
--- a/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target/listeners.rs
+++ b/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target/listeners.rs
@@ -4,9 +4,7 @@ use crate::callback_invocation::CallbackInvocation;
use crate::event_listener_args::{
AddEventListenerArgs, RemoveEventListenerArgs, parse_listener_args,
};
-use crate::util::{
- get_private_object, get_private_value, new_null_prototype_object, set_private_value, v8_string,
-};
+use crate::util::{get_private_value, set_private_value, v8_string};
use crate::webidl;
use moli_webapi_declare::WebApiObject;
@@ -36,8 +34,6 @@ struct SimpleObjectAbortListenerDataDeclaration<'scope> {
#[webapi(data_property, enumerable)]
entry: v8::Local<'scope, v8::Object>,
#[webapi(data_property, enumerable)]
- slot: v8::Local<'scope, v8::String>,
- #[webapi(data_property, enumerable)]
r#type: v8::Local<'scope, v8::String>,
#[webapi(data_property, enumerable)]
listener: v8::Local<'scope, v8::Value>,
@@ -121,14 +117,11 @@ impl<'s> SimpleObjectEventListenerSnapshot<'s> {
&self,
scope: &mut v8::PinScope<'s, '_>,
target: v8::Local<'s, v8::Object>,
- slot_name: &str,
event_type: &str,
) -> Option<Self> {
// Removing and re-adding the same callback creates a different entry.
// The removed entry must stay inactive in an existing dispatch snapshot.
- if !simple_object_event_listener_entry_registered(
- scope, target, slot_name, event_type, self.entry,
- ) {
+ if !simple_object_event_listener_entry_registered(scope, target, event_type, self.entry) {
return None;
}
let listener = if self.handler_slot.is_some() {
@@ -142,7 +135,6 @@ impl<'s> SimpleObjectEventListenerSnapshot<'s> {
simple_object_event_remove_listener_value_for_type(
scope,
target,
- slot_name,
event_type,
listener.original,
listener.capture,
@@ -187,7 +179,6 @@ impl<'s> SimpleObjectEventListenerSnapshot<'s> {
pub(crate) fn simple_object_event_target_add_listener<'s>(
scope: &mut v8::PinScope<'s, '_>,
args: &v8::FunctionCallbackArguments<'s>,
- slot_name: &str,
) {
let Some(call) = parse_listener_args::<AddEventListenerArgs>(scope, args, "addEventListener")
else {
@@ -201,7 +192,6 @@ pub(crate) fn simple_object_event_target_add_listener<'s>(
simple_object_event_target_register_resolved_listener(
scope,
target,
- slot_name,
call.event_type,
listener,
call.options.options,
@@ -220,22 +210,19 @@ pub(crate) fn simple_object_event_target_add_listener<'s>(
pub(crate) fn simple_object_event_target_register_webidl_listener<'s>(
scope: &mut v8::PinScope<'s, '_>,
target: v8::Local<'s, v8::Object>,
- slot_name: &str,
event_type: String,
listener: webidl::WebIdlCallbackInterface,
options: webidl::EventListenerOptions,
) {
let listener = simple_object_event_listener_parts(scope, listener);
simple_object_event_target_register_resolved_listener(
- scope, target, slot_name, event_type, listener, options, None,
+ scope, target, event_type, listener, options, None,
);
}
-#[allow(clippy::too_many_arguments)]
fn simple_object_event_target_register_resolved_listener<'s>(
scope: &mut v8::PinScope<'s, '_>,
target: v8::Local<'s, v8::Object>,
- slot_name: &str,
event_type: String,
listener: SimpleObjectResolvedEventListener<'s>,
options: webidl::EventListenerOptions,
@@ -244,8 +231,7 @@ fn simple_object_event_target_register_resolved_listener<'s>(
if signal.is_some_and(|signal| signal.is_aborted(scope)) {
return;
}
- let Some(listeners) =
- simple_object_event_listener_array(scope, target, slot_name, &event_type, true)
+ let Some(listeners) = simple_object_event_listener_array(scope, target, &event_type, true)
else {
return;
};
@@ -273,7 +259,7 @@ fn simple_object_event_target_register_resolved_listener<'s>(
None
};
if added_entry.is_some() {
- ensure_simple_object_event_type_order(scope, target, slot_name, &event_type);
+ ensure_simple_object_event_type_order(scope, target, &event_type);
}
if let (Some(entry), Some(signal)) = (added_entry, signal)
&& !register_simple_object_abort_listener(
@@ -281,7 +267,6 @@ fn simple_object_event_target_register_resolved_listener<'s>(
signal,
target,
entry,
- slot_name,
&event_type,
listener.original,
options.capture,
@@ -290,7 +275,6 @@ fn simple_object_event_target_register_resolved_listener<'s>(
simple_object_event_remove_listener_value_for_type(
scope,
target,
- slot_name,
&event_type,
listener.original,
options.capture,
@@ -304,7 +288,6 @@ fn simple_object_event_target_register_resolved_listener<'s>(
pub(crate) fn simple_object_event_target_remove_listener<'s>(
scope: &mut v8::PinScope<'s, '_>,
args: &v8::FunctionCallbackArguments<'s>,
- slot_name: &str,
) {
let Some(call) =
parse_listener_args::<RemoveEventListenerArgs>(scope, args, "removeEventListener")
@@ -319,7 +302,6 @@ pub(crate) fn simple_object_event_target_remove_listener<'s>(
simple_object_event_remove_listener_value_for_type(
scope,
target,
- slot_name,
&call.event_type,
listener,
call.options.capture,
@@ -340,13 +322,6 @@ fn simple_object_abort_remove_listener_callback<'s>(
else {
return;
};
- let Some(slot_name) = data
- .get(scope, v8str(scope, "slot").into())
- .and_then(|value| value.to_string(scope))
- .map(|value| value.to_rust_string_lossy(scope))
- else {
- return;
- };
let Some(event_type) = data
.get(scope, v8str(scope, "type").into())
.and_then(|value| value.to_string(scope))
@@ -366,14 +341,12 @@ fn simple_object_abort_remove_listener_callback<'s>(
let capture = data
.get(scope, v8str(scope, "capture").into())
.is_some_and(|value| value.boolean_value(scope));
- if !simple_object_event_listener_entry_registered(scope, target, &slot_name, &event_type, entry)
- {
+ if !simple_object_event_listener_entry_registered(scope, target, &event_type, entry) {
return;
}
simple_object_event_remove_listener_value_for_type(
scope,
target,
- &slot_name,
&event_type,
listener,
capture,
@@ -385,21 +358,16 @@ fn register_simple_object_abort_listener<'s>(
signal: ResolvedAbortSignal<'s>,
target: v8::Local<'s, v8::Object>,
entry: v8::Local<'s, v8::Object>,
- slot_name: &str,
event_type: &str,
listener: v8::Local<'s, v8::Value>,
capture: bool,
) -> bool {
- let Some(slot_value) = v8_string(scope, slot_name) else {
- return false;
- };
let Some(event_type_value) = v8_string(scope, event_type) else {
return false;
};
let data = SimpleObjectAbortListenerDataDeclaration::new(
target,
entry,
- slot_value,
event_type_value,
listener,
capture,
@@ -430,36 +398,15 @@ fn register_simple_object_abort_listener<'s>(
true
}
-fn simple_object_event_listener_registry<'s>(
- scope: &mut v8::PinScope<'s, '_>,
- target: v8::Local<'s, v8::Object>,
- slot_name: &str,
- create: bool,
-) -> Option<v8::Local<'s, v8::Object>> {
- let target = crate::context_bootstrap::shared_event_targets::shared_target_owner(scope, target);
- if let Some(registry) = get_private_object(scope, target, slot_name) {
- return Some(registry);
- }
- if !create {
- return None;
- }
- // Internal listener registry keyed by page-provided event type strings.
- // It is not a Web API instance, so null-prototype is intentional.
- let registry = new_null_prototype_object(scope);
- set_private_value(scope, target, slot_name, registry.into());
- Some(registry)
-}
-
pub(in crate::context_bootstrap::media_queries::events::simple_event_target) fn simple_object_event_listener_array<
's,
>(
scope: &mut v8::PinScope<'s, '_>,
target: v8::Local<'s, v8::Object>,
- slot_name: &str,
event_type: &str,
create: bool,
) -> Option<v8::Local<'s, v8::Array>> {
- let registry = simple_object_event_listener_registry(scope, target, slot_name, create)?;
+ let registry = simple_object_event_listener_registry(scope, target)?;
if let Some(listeners) = object_property_as_array(scope, registry, event_type) {
return Some(listeners);
}
@@ -478,11 +425,9 @@ pub(in crate::context_bootstrap::media_queries::events::simple_event_target) fn
pub(crate) fn simple_object_event_listeners_snapshot<'s>(
scope: &mut v8::PinScope<'s, '_>,
target: v8::Local<'s, v8::Object>,
- slot_name: &str,
event_type: &str,
) -> Vec<SimpleObjectEventListenerSnapshot<'s>> {
- let Some(listeners) =
- simple_object_event_listener_array(scope, target, slot_name, event_type, false)
+ let Some(listeners) = simple_object_event_listener_array(scope, target, event_type, false)
else {
return Vec::new();
};
@@ -502,10 +447,8 @@ pub(crate) fn simple_object_event_listeners_snapshot<'s>(
pub(crate) fn simple_object_has_event_listeners<'s>(
scope: &mut v8::PinScope<'s, '_>,
target: v8::Local<'s, v8::Object>,
- slot_name: &str,
) -> bool {
- let Some(registry) = simple_object_event_listener_registry(scope, target, slot_name, false)
- else {
+ let Some(registry) = simple_object_event_listener_registry(scope, target) else {
return false;
};
let Some(event_types) = simple_object_event_type_order(scope, registry, false) else {
@@ -519,8 +462,7 @@ pub(crate) fn simple_object_has_event_listeners<'s>(
else {
continue;
};
- if !simple_object_event_listeners_snapshot(scope, target, slot_name, &event_type).is_empty()
- {
+ if !simple_object_event_listeners_snapshot(scope, target, &event_type).is_empty() {
return true;
}
}
@@ -531,11 +473,7 @@ pub(crate) fn simple_event_target_inspector_listener_snapshots<'s>(
scope: &mut v8::PinScope<'s, '_>,
target: v8::Local<'s, v8::Object>,
) -> Vec<SimpleObjectEventListenerInspectorSnapshot<'s>> {
- let Some(slot_name) = super::state::simple_event_target_slot_name(scope, target) else {
- return Vec::new();
- };
- let Some(registry) = simple_object_event_listener_registry(scope, target, &slot_name, false)
- else {
+ let Some(registry) = simple_object_event_listener_registry(scope, target) else {
return Vec::new();
};
let Some(event_types) = simple_object_event_type_order(scope, registry, false) else {
@@ -550,9 +488,7 @@ pub(crate) fn simple_event_target_inspector_listener_snapshots<'s>(
else {
continue;
};
- for listener in
- simple_object_event_listeners_snapshot(scope, target, &slot_name, &event_type)
- {
+ for listener in simple_object_event_listeners_snapshot(scope, target, &event_type) {
let original = if listener.handler_slot.is_some() {
listener.callback.into()
} else {
@@ -578,7 +514,6 @@ pub(crate) fn simple_event_target_inspector_listener_snapshots<'s>(
pub(crate) fn simple_object_event_set_handler<'s>(
scope: &mut v8::PinScope<'s, '_>,
target: v8::Local<'s, v8::Object>,
- slot_name: &str,
event_type: &str,
handler_slot_name: &str,
value: v8::Local<'s, v8::Value>,
@@ -593,8 +528,7 @@ pub(crate) fn simple_object_event_set_handler<'s>(
handler_slot_name,
callback.map_or_else(|| v8::null(scope).into(), |callback| callback.into()),
);
- let Some(listeners) =
- simple_object_event_listener_array(scope, target, slot_name, event_type, active)
+ let Some(listeners) = simple_object_event_listener_array(scope, target, event_type, active)
else {
return;
};
@@ -636,7 +570,7 @@ pub(crate) fn simple_object_event_set_handler<'s>(
incumbent_context_anchor.into(),
);
}
- ensure_simple_object_event_type_order(scope, target, slot_name, event_type);
+ ensure_simple_object_event_type_order(scope, target, event_type);
return;
}
}
@@ -649,7 +583,7 @@ pub(crate) fn simple_object_event_set_handler<'s>(
);
set_private_value(scope, entry, HANDLER_TARGET_SLOT, target.into());
let _ = listeners.set_index(scope, listeners.length(), entry.into());
- ensure_simple_object_event_type_order(scope, target, slot_name, event_type);
+ ensure_simple_object_event_type_order(scope, target, event_type);
return;
}
@@ -666,7 +600,7 @@ pub(crate) fn simple_object_event_set_handler<'s>(
}
let _ = next.set_index(scope, next.length(), candidate);
}
- if let Some(registry) = simple_object_event_listener_registry(scope, target, slot_name, false)
+ if let Some(registry) = simple_object_event_listener_registry(scope, target)
&& let Some(key) = v8_string(scope, event_type)
{
let _ = registry.set(scope, key.into(), next.into());
@@ -690,13 +624,11 @@ fn handler_belongs_to_target<'s>(
pub(crate) fn simple_object_event_remove_listener_value_for_type<'s>(
scope: &mut v8::PinScope<'s, '_>,
target: v8::Local<'s, v8::Object>,
- slot_name: &str,
event_type: &str,
listener: v8::Local<'s, v8::Value>,
capture: bool,
) {
- let Some(registry) = simple_object_event_listener_registry(scope, target, slot_name, false)
- else {
+ let Some(registry) = simple_object_event_listener_registry(scope, target) else {
return;
};
let Some(current) = object_property_as_array(scope, registry, event_type) else {
@@ -789,11 +721,9 @@ fn simple_object_event_type_order<'s>(
fn ensure_simple_object_event_type_order<'s>(
scope: &mut v8::PinScope<'s, '_>,
target: v8::Local<'s, v8::Object>,
- slot_name: &str,
event_type: &str,
) {
- let Some(registry) = simple_object_event_listener_registry(scope, target, slot_name, false)
- else {
+ let Some(registry) = simple_object_event_listener_registry(scope, target) else {
return;
};
let Some(order) = simple_object_event_type_order(scope, registry, true) else {
@@ -976,12 +906,10 @@ fn simple_object_event_listener_array_contains_entry(
fn simple_object_event_listener_entry_registered<'s>(
scope: &mut v8::PinScope<'s, '_>,
target: v8::Local<'s, v8::Object>,
- slot_name: &str,
event_type: &str,
entry: v8::Local<'s, v8::Object>,
) -> bool {
- let Some(listeners) =
- simple_object_event_listener_array(scope, target, slot_name, event_type, false)
+ let Some(listeners) = simple_object_event_listener_array(scope, target, event_type, false)
else {
return false;
};
diff --git a/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target/state.rs b/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target/state.rs
index f60dd2b2d..f1d44d42c 100644
--- a/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target/state.rs
+++ b/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target/state.rs
@@ -1,37 +1,36 @@
use super::*;
-use crate::util::get_private_value;
+use crate::context_bootstrap::shared_event_targets::shared_target_owner;
+use crate::util::{get_private_object, new_null_prototype_object, set_private_value};
-pub(crate) fn simple_event_target_slot_name<'s>(
+pub(crate) fn initialize_simple_event_target<'s>(
scope: &mut v8::PinScope<'s, '_>,
target: v8::Local<'s, v8::Object>,
-) -> Option<String> {
- let value = simple_event_target_private_value(scope, target, SIMPLE_EVENT_TARGET_SLOT)?;
- if value.is_null_or_undefined() {
- return None;
+) {
+ let target = shared_target_owner(scope, target);
+ if get_private_object(scope, target, SIMPLE_EVENT_TARGET_LISTENERS_SLOT).is_none() {
+ let registry = new_null_prototype_object(scope);
+ set_private_value(
+ scope,
+ target,
+ SIMPLE_EVENT_TARGET_LISTENERS_SLOT,
+ registry.into(),
+ );
}
- value
- .to_string(scope)
- .map(|value| value.to_rust_string_lossy(scope))
}
-pub(in crate::context_bootstrap::media_queries::events::simple_event_target) fn simple_event_target_private_value<
- 's,
->(
+pub(crate) fn is_simple_event_target<'s>(
scope: &mut v8::PinScope<'s, '_>,
target: v8::Local<'s, v8::Object>,
- slot: &str,
-) -> Option<v8::Local<'s, v8::Value>> {
- let mut current = Some(target);
- for _ in 0..64 {
- let object = current?;
- if let Some(value) = get_private_value(scope, object, slot) {
- return Some(value);
- }
- let prototype = object.get_prototype(scope)?;
- if prototype.is_null_or_undefined() {
- return None;
- }
- current = v8::Local::<v8::Object>::try_from(prototype).ok();
- }
- None
+) -> bool {
+ simple_object_event_listener_registry(scope, target).is_some()
+}
+
+pub(super) fn simple_object_event_listener_registry<'s>(
+ scope: &mut v8::PinScope<'s, '_>,
+ target: v8::Local<'s, v8::Object>,
+) -> Option<v8::Local<'s, v8::Object>> {
+ let target = shared_target_owner(scope, target);
+ // Read only the target's own private state. Looking through prototypes would
+ // let instances inherit another target's listener list and receiver identity.
+ get_private_object(scope, target, SIMPLE_EVENT_TARGET_LISTENERS_SLOT)
}
diff --git a/moli-renderer-v8/src/context_bootstrap/message_ports.rs b/moli-renderer-v8/src/context_bootstrap/message_ports.rs
index 9ca00a295..7310b41d4 100644
--- a/moli-renderer-v8/src/context_bootstrap/message_ports.rs
+++ b/moli-renderer-v8/src/context_bootstrap/message_ports.rs
@@ -34,5 +34,3 @@ pub(in crate::context_bootstrap::message_ports) use state::{
new_detached_message_port_object, new_message_port_object,
retire_message_port_if_owner_is_stale, set_message_port_peer, set_message_port_started,
};
-
-const MESSAGE_PORT_EVENT_LISTENERS_SLOT: &str = "__moliMessagePortEventListeners";
diff --git a/moli-renderer-v8/src/context_bootstrap/message_ports/delivery.rs b/moli-renderer-v8/src/context_bootstrap/message_ports/delivery.rs
index 92dfb3626..6b6f8d78f 100644
--- a/moli-renderer-v8/src/context_bootstrap/message_ports/delivery.rs
+++ b/moli-renderer-v8/src/context_bootstrap/message_ports/delivery.rs
@@ -345,7 +345,6 @@ fn dispatch_message_port_event<'s>(
let dispatched = dispatch_simple_event_target_event_collecting_errors(
scope,
target,
- MESSAGE_PORT_EVENT_LISTENERS_SLOT,
event_type,
event,
callback_errors,
@@ -368,7 +367,6 @@ fn dispatch_message_port_close_event<'s>(
dispatch_simple_event_target_event_collecting_errors(
scope,
target,
- MESSAGE_PORT_EVENT_LISTENERS_SLOT,
"close",
event,
callback_errors,
diff --git a/moli-renderer-v8/src/context_bootstrap/message_ports/state.rs b/moli-renderer-v8/src/context_bootstrap/message_ports/state.rs
index 6fabcd999..fd2093321 100644
--- a/moli-renderer-v8/src/context_bootstrap/message_ports/state.rs
+++ b/moli-renderer-v8/src/context_bootstrap/message_ports/state.rs
@@ -262,7 +262,7 @@ fn new_message_port_wrapper<'s>(
.ok()?;
// Event listeners belong to the JS EventTarget, independently of the
// transferable communication endpoint and its queue attachment.
- mark_simple_event_target_slot(scope, port, MESSAGE_PORT_EVENT_LISTENERS_SLOT);
+ initialize_simple_event_target(scope, port);
Some(port)
}
@@ -520,14 +520,7 @@ fn set_message_port_event_handler<'s>(
handler_slot: &'static str,
event_type: &str,
) {
- simple_object_event_set_handler(
- scope,
- port,
- MESSAGE_PORT_EVENT_LISTENERS_SLOT,
- event_type,
- handler_slot,
- value,
- );
+ simple_object_event_set_handler(scope, port, event_type, handler_slot, value);
// Setting onmessage enables the queue permanently, including assigning
// null or a non-callable value. Listener registration alone does not.
if handler_slot == MESSAGE_PORT_ONMESSAGE_HANDLER_SLOT {
diff --git a/moli-renderer-v8/src/context_bootstrap/navigation_entry/wrappers.rs b/moli-renderer-v8/src/context_bootstrap/navigation_entry/wrappers.rs
index 4d57d1a27..dae508572 100644
--- a/moli-renderer-v8/src/context_bootstrap/navigation_entry/wrappers.rs
+++ b/moli-renderer-v8/src/context_bootstrap/navigation_entry/wrappers.rs
@@ -8,7 +8,6 @@ use moli_history::HistoryEntryRef;
use super::NavigationHistoryEntryObjectDeclaration;
use crate::context_bootstrap::history_runtime::native;
-use crate::context_bootstrap::location_history_storage::NAVIGATION_ENTRY_EVENT_LISTENERS_SLOT;
use crate::context_bootstrap::navigation_window::{runtime_window_owner, set_runtime_window_owner};
use crate::context_bootstrap::{media_queries, shared_event_targets};
use crate::util::{get_private_value, set_private_value, v8_string};
@@ -120,11 +119,7 @@ fn allocate_in_current_realm<'s>(
.bind(scope)
.expect("NavigationHistoryEntry declaration should bind");
native::bind_entry(scope, wrapper, record);
- media_queries::install_simple_event_target_methods(
- scope,
- wrapper,
- NAVIGATION_ENTRY_EVENT_LISTENERS_SLOT,
- );
+ media_queries::install_simple_event_target_methods(scope, wrapper);
shared_event_targets::install_handlers(scope, wrapper, true);
set_runtime_window_owner(scope, wrapper, owner);
wrapper
diff --git a/moli-renderer-v8/src/context_bootstrap/navigation_events.rs b/moli-renderer-v8/src/context_bootstrap/navigation_events.rs
index ca2b9e65a..1744e33f3 100644
--- a/moli-renderer-v8/src/context_bootstrap/navigation_events.rs
+++ b/moli-renderer-v8/src/context_bootstrap/navigation_events.rs
@@ -1,7 +1,4 @@
use super::events::{construct_original_event, run_navigate_event_precommit_handlers};
-use super::location_history_storage::{
- NAVIGATION_ENTRY_EVENT_LISTENERS_SLOT, NAVIGATION_EVENT_LISTENERS_SLOT,
-};
use super::location_runtime::{is_same_document_fragment_navigation, location_href_slot};
use super::media_queries::dispatch_simple_event_target_event;
use super::navigation_callbacks::cancel_active_intercepted_same_document_navigation;
@@ -766,13 +763,7 @@ pub(super) fn dispatch_navigation_currententrychange<'s>(
return;
};
mark_event_trusted(scope, event);
- let _ = dispatch_simple_event_target_event(
- scope,
- navigation,
- NAVIGATION_EVENT_LISTENERS_SLOT,
- "currententrychange",
- event,
- );
+ let _ = dispatch_simple_event_target_event(scope, navigation, "currententrychange", event);
}
pub(super) fn dispatch_navigation_entry_dispose<'s>(
@@ -786,13 +777,7 @@ pub(super) fn dispatch_navigation_entry_dispose<'s>(
let Some(event) = construct_original_event(scope, "dispose") else {
return;
};
- let _ = dispatch_simple_event_target_event(
- scope,
- entry,
- NAVIGATION_ENTRY_EVENT_LISTENERS_SLOT,
- "dispose",
- event,
- );
+ let _ = dispatch_simple_event_target_event(scope, entry, "dispose", event);
}
pub(super) fn dispatch_navigation_success<'s>(
@@ -810,13 +795,7 @@ pub(super) fn dispatch_navigation_success<'s>(
let Some(event) = construct_original_event(scope, "navigatesuccess") else {
return;
};
- let _ = dispatch_simple_event_target_event(
- scope,
- navigation,
- NAVIGATION_EVENT_LISTENERS_SLOT,
- "navigatesuccess",
- event,
- );
+ let _ = dispatch_simple_event_target_event(scope, navigation, "navigatesuccess", event);
}
pub(super) fn dispatch_navigation_error<'s>(
@@ -854,13 +833,7 @@ pub(super) fn dispatch_navigation_error<'s>(
};
mark_event_trusted(scope, event);
set_navigation_error_event_active(scope, navigation, true);
- let _ = dispatch_simple_event_target_event(
- scope,
- navigation,
- NAVIGATION_EVENT_LISTENERS_SLOT,
- "navigateerror",
- event,
- );
+ let _ = dispatch_simple_event_target_event(scope, navigation, "navigateerror", event);
set_navigation_error_event_active(scope, navigation, false);
}
@@ -970,13 +943,7 @@ pub(super) fn dispatch_navigation_navigate_event_with_form_data_and_outcome<'s>(
set_navigation_active_navigate_event(scope, navigation, active_data);
let owner = runtime_window_owner(scope, navigation);
save_current_navigation_entry_scroll_position(scope, owner);
- let proceed = dispatch_simple_event_target_event(
- scope,
- navigation,
- NAVIGATION_EVENT_LISTENERS_SLOT,
- "navigate",
- event,
- );
+ let proceed = dispatch_simple_event_target_event(scope, navigation, "navigate", event);
let (precommit_error, precommit_result) = if proceed {
run_navigate_event_precommit_handlers(scope, event)
} else {
@@ -1208,13 +1175,7 @@ fn dispatch_cross_document_navigation_navigate_event_for_window_with_type_form_d
NAVIGATE_EVENT_SCROLL_AFTER_TRANSITION_SLOT,
true,
);
- dispatch_simple_event_target_event(
- scope,
- navigation,
- NAVIGATION_EVENT_LISTENERS_SLOT,
- "navigate",
- event,
- )
+ dispatch_simple_event_target_event(scope, navigation, "navigate", event)
}
pub(crate) fn dispatch_srcdoc_navigation_navigate_event_for_window<'s>(
@@ -1315,13 +1276,7 @@ pub(super) fn dispatch_navigation_traverse_event_with_outcome<'s>(
set_navigation_active_navigate_event(scope, navigation, active_data);
let owner = runtime_window_owner(scope, navigation);
save_current_navigation_entry_scroll_position(scope, owner);
- let proceed = dispatch_simple_event_target_event(
- scope,
- navigation,
- NAVIGATION_EVENT_LISTENERS_SLOT,
- "navigate",
- event,
- );
+ let proceed = dispatch_simple_event_target_event(scope, navigation, "navigate", event);
let (precommit_error, precommit_result) = if proceed {
run_navigate_event_precommit_handlers(scope, event)
} else {
diff --git a/moli-renderer-v8/src/context_bootstrap/navigation_surface.rs b/moli-renderer-v8/src/context_bootstrap/navigation_surface.rs
index d50675f29..748d2a1ff 100644
--- a/moli-renderer-v8/src/context_bootstrap/navigation_surface.rs
+++ b/moli-renderer-v8/src/context_bootstrap/navigation_surface.rs
@@ -1,7 +1,5 @@
use super::history_mutation::{history_push_state_callback, history_replace_state_callback};
-use super::location_history_storage::{
- NAVIGATION_CURRENT_ENTRY_SLOT, NAVIGATION_EVENT_LISTENERS_SLOT,
-};
+use super::location_history_storage::NAVIGATION_CURRENT_ENTRY_SLOT;
use super::navigation_activation::install_navigation_activation_runtime_state;
use super::navigation_callbacks::{
navigation_entries_callback, navigation_navigate_callback,
diff --git a/moli-renderer-v8/src/context_bootstrap/navigation_surface/runtime.rs b/moli-renderer-v8/src/context_bootstrap/navigation_surface/runtime.rs
index 329509731..692749c4a 100644
--- a/moli-renderer-v8/src/context_bootstrap/navigation_surface/runtime.rs
+++ b/moli-renderer-v8/src/context_bootstrap/navigation_surface/runtime.rs
@@ -84,11 +84,7 @@ pub(in crate::context_bootstrap) fn build_navigation_runtime_state<'s>(
let navigation = NavigationRuntimeObjectDeclaration::new(current_entry)
.bind(scope)
.map_err(anyhow::Error::from)?;
- super::media_queries::install_simple_event_target_methods(
- scope,
- navigation,
- NAVIGATION_EVENT_LISTENERS_SLOT,
- );
+ super::media_queries::install_simple_event_target_methods(scope, navigation);
super::super::shared_event_targets::install_handlers(scope, navigation, false);
let owner = history_window_owner(scope, window);
if window_has_shared_history(scope, window)
diff --git a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/clipboard.rs b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/clipboard.rs
index 38196355a..931242f81 100644
--- a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/clipboard.rs
+++ b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/clipboard.rs
@@ -1,4 +1,4 @@
-use super::super::SIMPLE_EVENT_TARGET_SLOT;
+use super::super::SIMPLE_EVENT_TARGET_LISTENERS_SLOT;
use crate::web_api_interfaces;
use crate::{
blob,
@@ -9,8 +9,6 @@ use crate::{
use anyhow::{Result, anyhow};
use moli_webapi_declare::{WebApiFunctionTemplate, WebApiObject};
-const CLIPBOARD_EVENT_LISTENERS_SLOT: &str = "__moliClipboardEventListeners";
-
const CLIPBOARD_ITEM_DATA_SLOT: &str = "__moliClipboardItemData";
const CLIPBOARD_ITEM_RAW_DATA_SLOT: &str = "__moliClipboardItemRawData";
const CLIPBOARD_ITEM_TYPES_SLOT: &str = "__moliClipboardItemTypes";
@@ -19,8 +17,8 @@ const CLIPBOARD_ITEM_PRESENTATION_STYLE_SLOT: &str = "__moliClipboardItemPresent
#[derive(Default, WebApiObject)]
#[webapi(interface = web_api_interfaces::Clipboard)]
struct ClipboardObjectDeclaration {
- #[webapi(slot = SIMPLE_EVENT_TARGET_SLOT, value = CLIPBOARD_EVENT_LISTENERS_SLOT)]
- event_target_slot: (),
+ #[webapi(slot = SIMPLE_EVENT_TARGET_LISTENERS_SLOT, init = "null_object")]
+ event_listeners: (),
}
#[derive(Default, WebApiFunctionTemplate)]
diff --git a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/media_devices.rs b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/media_devices.rs
index 5301cb6a7..a1dd24fcc 100644
--- a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/media_devices.rs
+++ b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/media_devices.rs
@@ -6,14 +6,13 @@ use moli_webapi_declare::{WebApiFunctionTemplate, WebApiObject};
mod info;
-const MEDIA_DEVICES_LISTENERS_SLOT: &str = "__moliMediaDevicesListeners";
const MEDIA_DEVICES_ONDEVICECHANGE_SLOT: &str = "__moliMediaDevicesOndevicechange";
#[derive(Default, WebApiObject)]
#[webapi(interface = web_api_interfaces::MediaDevices)]
struct MediaDevicesObjectDeclaration {
- #[webapi(slot = SIMPLE_EVENT_TARGET_SLOT, value = MEDIA_DEVICES_LISTENERS_SLOT)]
- event_target_slot: (),
+ #[webapi(slot = SIMPLE_EVENT_TARGET_LISTENERS_SLOT, init = "null_object")]
+ event_listeners: (),
#[webapi(slot = MEDIA_DEVICES_ONDEVICECHANGE_SLOT, init = "null")]
ondevicechange: (),
@@ -126,7 +125,6 @@ fn ondevicechange_setter<'s>(
simple_object_event_set_handler(
scope,
args.this(),
- MEDIA_DEVICES_LISTENERS_SLOT,
"devicechange",
MEDIA_DEVICES_ONDEVICECHANGE_SLOT,
args.get(0),
diff --git a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/navigator.rs b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/navigator.rs
index 6242f2382..c300746ee 100644
--- a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/navigator.rs
+++ b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/navigator.rs
@@ -97,7 +97,6 @@ pub(in crate::context_bootstrap) const STORAGE_BUCKET_MANAGER_CHILD_HANDLE_SLOT:
"__moliStorageBucketManagerChildHandle";
pub(in crate::context_bootstrap) const STORAGE_BUCKET_MANAGER_POPUP_ID_SLOT: &str =
"__moliStorageBucketManagerPopupId";
-const SERVICE_WORKER_CONTAINER_LISTENERS_SLOT: &str = "__moliServiceWorkerContainerEvents";
const SERVICE_WORKER_CONTAINER_ONMESSAGE_SLOT: &str = "__moliServiceWorkerContainerOnmessage";
const SERVICE_WORKER_CONTAINER_ONMESSAGEERROR_SLOT: &str =
"__moliServiceWorkerContainerOnmessageerror";
@@ -403,8 +402,8 @@ struct NavigatorUaDataPrototypeMethodsDeclaration {
#[derive(Default, WebApiObject)]
#[webapi(interface = web_api_interfaces::ServiceWorkerContainer, prototype = "Object")]
struct ServiceWorkerContainerDeclaration {
- #[webapi(slot = SIMPLE_EVENT_TARGET_SLOT, value = SERVICE_WORKER_CONTAINER_LISTENERS_SLOT)]
- event_target_slot: (),
+ #[webapi(slot = SIMPLE_EVENT_TARGET_LISTENERS_SLOT, init = "null_object")]
+ event_listeners: (),
#[webapi(slot = SERVICE_WORKER_CONTAINER_ONMESSAGE_SLOT, init = "null")]
_onmessage: (),
diff --git a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/screen.rs b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/screen.rs
index f4f94dd86..76c6c380e 100644
--- a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/screen.rs
+++ b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/screen.rs
@@ -1,5 +1,5 @@
use super::super::media_queries::{
- dispatch_simple_event_target_event, mark_simple_event_target_slot,
+ dispatch_simple_event_target_event, initialize_simple_event_target,
simple_event_target_add_event_listener_callback, simple_event_target_dispatch_event_callback,
simple_event_target_remove_event_listener_callback,
};
@@ -341,7 +341,7 @@ pub(in crate::context_bootstrap) fn build_window_screen<'s>(
pixel_depth: profile.pixel_depth,
}
.bind(scope)?;
- mark_simple_event_target_slot(scope, screen, SCREEN_EVENT_LISTENERS_SLOT);
+ initialize_simple_event_target(scope, screen);
Ok(screen)
}
@@ -452,7 +452,7 @@ fn build_screen_orientation_in_current_realm<'s>(
profile.orientation_angle,
)
.bind(scope)?;
- mark_simple_event_target_slot(scope, orientation, SCREEN_ORIENTATION_EVENT_LISTENERS_SLOT);
+ initialize_simple_event_target(scope, orientation);
set_private_value(scope, screen, SCREEN_ORIENTATION_SLOT, orientation.into());
Ok(orientation)
}
@@ -481,13 +481,7 @@ pub(crate) fn dispatch_screen_orientation_change<'s>(
) else {
return false;
};
- dispatch_simple_event_target_event(
- scope,
- orientation,
- SCREEN_ORIENTATION_EVENT_LISTENERS_SLOT,
- "change",
- event,
- )
+ dispatch_simple_event_target_event(scope, orientation, "change", event)
}
fn screen_orientation_attribute_getter_callback<'s>(
@@ -569,7 +563,6 @@ fn screen_orientation_onchange_setter_callback<'s>(
super::super::simple_object_event_set_handler(
scope,
args.this(),
- SCREEN_ORIENTATION_EVENT_LISTENERS_SLOT,
"change",
SCREEN_ORIENTATION_ONCHANGE_SLOT,
args.get(0),
diff --git a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/visual_viewport.rs b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/visual_viewport.rs
index af08f205a..adfa2d8df 100644
--- a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/visual_viewport.rs
+++ b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/visual_viewport.rs
@@ -1,4 +1,4 @@
-use super::super::media_queries::mark_simple_event_target_slot;
+use super::super::media_queries::initialize_simple_event_target;
use super::super::*;
use crate::util::{
callback_data_index_value, callback_data_item, get_private_value, throw_type_error,
@@ -13,7 +13,6 @@ const VISUAL_VIEWPORT_PAGE_TOP_SLOT: &str = "__moliVisualViewportPageTop";
const VISUAL_VIEWPORT_WIDTH_SLOT: &str = "__moliVisualViewportWidth";
const VISUAL_VIEWPORT_HEIGHT_SLOT: &str = "__moliVisualViewportHeight";
const VISUAL_VIEWPORT_SCALE_SLOT: &str = "__moliVisualViewportScale";
-const VISUAL_VIEWPORT_EVENT_LISTENERS_SLOT: &str = "__moliVisualViewportListeners";
#[derive(WebApiObject)]
#[webapi(interface = web_api_interfaces::VisualViewport)]
@@ -112,7 +111,7 @@ pub(in crate::context_bootstrap) fn build_window_visual_viewport<'s>(
scale: profile.visual_viewport_scale,
}
.bind(scope)?;
- mark_simple_event_target_slot(scope, viewport, VISUAL_VIEWPORT_EVENT_LISTENERS_SLOT);
+ initialize_simple_event_target(scope, viewport);
Ok(viewport)
}
@@ -135,13 +134,7 @@ pub(crate) fn dispatch_window_visual_viewport_resize<'s>(
) else {
return false;
};
- dispatch_simple_event_target_event(
- scope,
- viewport,
- VISUAL_VIEWPORT_EVENT_LISTENERS_SLOT,
- "resize",
- event,
- )
+ dispatch_simple_event_target_event(scope, viewport, "resize", event)
}
fn visual_viewport_attribute_getter_callback<'s>(
diff --git a/moli-renderer-v8/src/context_bootstrap/notification_runtime.rs b/moli-renderer-v8/src/context_bootstrap/notification_runtime.rs
index 2c1876e6e..0b6878f9f 100644
--- a/moli-renderer-v8/src/context_bootstrap/notification_runtime.rs
+++ b/moli-renderer-v8/src/context_bootstrap/notification_runtime.rs
@@ -1,5 +1,5 @@
use super::{
- SIMPLE_EVENT_TARGET_SLOT, global_constructor_object,
+ SIMPLE_EVENT_TARGET_LISTENERS_SLOT, global_constructor_object,
simple_event_target_add_event_listener_callback, simple_event_target_dispatch_event_callback,
simple_event_target_handler_getter_callback, simple_event_target_handler_setter_callback,
simple_event_target_remove_event_listener_callback, structured_clone_value_for_storage,
@@ -38,7 +38,6 @@ const NOTIFICATION_REQUIRE_INTERACTION_SLOT: &str = "__lmNotificationRequireInte
const NOTIFICATION_ACTIONS_SLOT: &str = "__lmNotificationActions";
const NOTIFICATION_RECORD_ID_SLOT: &str = "__lmNotificationRecordId";
const NOTIFICATION_RECORD_REGISTRATION_ID_SLOT: &str = "__lmNotificationRecordRegistrationId";
-const NOTIFICATION_LISTENERS_SLOT: &str = "__lmNotificationListeners";
const NOTIFICATION_MAX_ACTIONS: usize = 2;
pub(crate) struct NotificationOptionsPayload {
@@ -96,8 +95,8 @@ struct NotificationObjectDeclaration<'scope> {
#[webapi(slot = NOTIFICATION_ACTIONS_SLOT)]
actions: v8::Local<'scope, v8::Value>,
- #[webapi(slot = SIMPLE_EVENT_TARGET_SLOT, value = NOTIFICATION_LISTENERS_SLOT)]
- event_target_slot: (),
+ #[webapi(slot = SIMPLE_EVENT_TARGET_LISTENERS_SLOT, init = "null_object")]
+ event_listeners: (),
#[webapi(
method,
@@ -953,7 +952,7 @@ fn initialize_notification_object<'s>(
silent,
require_interaction: metadata.require_interaction,
actions: action_array,
- event_target_slot: (),
+ event_listeners: (),
add_event_listener: (),
remove_event_listener: (),
diff --git a/moli-renderer-v8/src/context_bootstrap/performance_runtime.rs b/moli-renderer-v8/src/context_bootstrap/performance_runtime.rs
index 90c589eb8..145389b0d 100644
--- a/moli-renderer-v8/src/context_bootstrap/performance_runtime.rs
+++ b/moli-renderer-v8/src/context_bootstrap/performance_runtime.rs
@@ -10,7 +10,6 @@ mod resource_buffer;
mod window_state;
const DEFAULT_RESOURCE_TIMING_BUFFER_SIZE: u32 = 250;
-const PERFORMANCE_EVENT_LISTENERS_SLOT: &str = "__moliPerformanceEventListeners";
const PERFORMANCE_RESOURCE_TIMING_BUFFER_ID_SLOT: &str = "__moliPerformanceResourceTimingBufferId";
const PERFORMANCE_ON_RESOURCE_TIMING_BUFFER_FULL_SLOT: &str =
"__moliPerformanceOnResourceTimingBufferFull";
diff --git a/moli-renderer-v8/src/context_bootstrap/performance_runtime/install.rs b/moli-renderer-v8/src/context_bootstrap/performance_runtime/install.rs
index 0ec226ec2..f165f3a48 100644
--- a/moli-renderer-v8/src/context_bootstrap/performance_runtime/install.rs
+++ b/moli-renderer-v8/src/context_bootstrap/performance_runtime/install.rs
@@ -376,7 +376,7 @@ pub(in crate::context_bootstrap) fn install_worker_performance_runtime_state<'s>
)
.bind(scope)
.map_err(|error| anyhow!("failed to create worker performance: {error}"))?;
- install_simple_event_target_methods(scope, performance, PERFORMANCE_EVENT_LISTENERS_SLOT);
+ install_simple_event_target_methods(scope, performance);
define_global_value(scope, global, WINDOW_PERFORMANCE_SLOT, performance.into())
}
@@ -430,7 +430,7 @@ pub(super) fn create_performance_object<'s>(
PERFORMANCE_NAVIGATION_NAME_SEED_SLOT,
navigation_entry_name.into(),
);
- install_simple_event_target_methods(scope, performance, PERFORMANCE_EVENT_LISTENERS_SLOT);
+ install_simple_event_target_methods(scope, performance);
performance
}
diff --git a/moli-renderer-v8/src/context_bootstrap/performance_runtime/resource_buffer.rs b/moli-renderer-v8/src/context_bootstrap/performance_runtime/resource_buffer.rs
index 1dc226309..9415f3570 100644
--- a/moli-renderer-v8/src/context_bootstrap/performance_runtime/resource_buffer.rs
+++ b/moli-renderer-v8/src/context_bootstrap/performance_runtime/resource_buffer.rs
@@ -143,7 +143,6 @@ fn on_resource_timing_buffer_full_setter<'s>(
simple_object_event_set_handler(
scope,
performance,
- PERFORMANCE_EVENT_LISTENERS_SLOT,
RESOURCE_TIMING_BUFFER_FULL_EVENT,
PERFORMANCE_ON_RESOURCE_TIMING_BUFFER_FULL_SLOT,
args.get(0),
@@ -274,7 +273,6 @@ fn dispatch_resource_timing_buffer_full_event<'s>(
let _ = dispatch_simple_event_target_event(
scope,
performance,
- PERFORMANCE_EVENT_LISTENERS_SLOT,
RESOURCE_TIMING_BUFFER_FULL_EVENT,
event,
);
diff --git a/moli-renderer-v8/src/context_bootstrap/picture_in_picture.rs b/moli-renderer-v8/src/context_bootstrap/picture_in_picture.rs
index b11038857..175b10086 100644
--- a/moli-renderer-v8/src/context_bootstrap/picture_in_picture.rs
+++ b/moli-renderer-v8/src/context_bootstrap/picture_in_picture.rs
@@ -11,7 +11,6 @@ use moli_webapi_declare::WebApiFunctionTemplate;
const WIDTH: &str = "__moliPictureInPictureWindowWidth";
const HEIGHT: &str = "__moliPictureInPictureWindowHeight";
const ON_RESIZE: &str = "__moliPictureInPictureWindowOnresize";
-const LISTENERS: &str = "__moliPictureInPictureWindowListeners";
#[derive(WebApiFunctionTemplate)]
#[webapi(interface = web_api_interfaces::PictureInPictureWindow, enumerable, receiver)]
@@ -75,14 +74,7 @@ fn resize_handler_setter<'s>(
_rv: v8::ReturnValue<'_, v8::Value>,
) {
let window = target(scope, args.this());
- media_queries::simple_object_event_set_handler(
- scope,
- window,
- LISTENERS,
- "resize",
- ON_RESIZE,
- args.get(0),
- );
+ media_queries::simple_object_event_set_handler(scope, window, "resize", ON_RESIZE, args.get(0));
}
/// A closed native window for binding tests, never a production PiP request.
@@ -93,8 +85,8 @@ pub(crate) fn closed_window_for_test<'s>(
#[derive(Default, moli_webapi_declare::WebApiObject)]
#[webapi(interface = web_api_interfaces::PictureInPictureWindow)]
struct ClosedWindow {
- #[webapi(slot = super::shared::SIMPLE_EVENT_TARGET_SLOT, value = LISTENERS)]
- event_target: (),
+ #[webapi(slot = super::shared::SIMPLE_EVENT_TARGET_LISTENERS_SLOT, init = "null_object")]
+ event_listeners: (),
}
ClosedWindow::default()
.bind(scope)
diff --git a/moli-renderer-v8/src/context_bootstrap/shared/slots.rs b/moli-renderer-v8/src/context_bootstrap/shared/slots.rs
index 89178629b..c01c9aeac 100644
--- a/moli-renderer-v8/src/context_bootstrap/shared/slots.rs
+++ b/moli-renderer-v8/src/context_bootstrap/shared/slots.rs
@@ -36,14 +36,9 @@ pub(in crate::context_bootstrap) const WINDOW_SELF_SLOT: &str = "__moliWindowSel
pub(in crate::context_bootstrap) const WINDOW_PARENT_SLOT: &str = "__moliWindowParent";
pub(in crate::context_bootstrap) const WINDOW_TOP_SLOT: &str = "__moliWindowTop";
pub(in crate::context_bootstrap) const WINDOW_FRAMES_SLOT: &str = "__moliWindowFrames";
-pub(crate) const SIMPLE_EVENT_TARGET_SLOT: &str = "__moliEventTargetSlot";
-pub(in crate::context_bootstrap) const OFFLINE_AUDIO_LISTENERS_SLOT: &str =
- "__moliOfflineAudioListeners";
+// Each SimpleEventTarget stores its own listener registry directly under this key.
+pub(crate) const SIMPLE_EVENT_TARGET_LISTENERS_SLOT: &str = "__moliEventTargetListeners";
pub(in crate::context_bootstrap) const OFFLINE_AUDIO_BUFFER_SLOT: &str = "__moliOfflineAudioBuffer";
-pub(in crate::context_bootstrap) const SCREEN_EVENT_LISTENERS_SLOT: &str =
- "__moliScreenEventListeners";
-pub(in crate::context_bootstrap) const SCREEN_ORIENTATION_EVENT_LISTENERS_SLOT: &str =
- "__moliScreenOrientationEventListeners";
pub(in crate::context_bootstrap) const DOM_IMPLEMENTATION_SINGLETON_SLOT: &str =
"__moliDOMImplementationSingleton";
pub(in crate::context_bootstrap) const URL_HREF_SLOT: &str = "__moliUrlHref";
@@ -77,8 +72,6 @@ pub(in crate::context_bootstrap) const MESSAGE_PORT_ONCLOSE_HANDLER_SLOT: &str =
"__lmMessagePortOncloseHandler";
pub(in crate::context_bootstrap) const MESSAGE_PORT_STARTED_SLOT: &str = "__moliMessagePortStarted";
pub(in crate::context_bootstrap) const MESSAGE_PORT_CLOSED_SLOT: &str = "__moliMessagePortClosed";
-pub(in crate::context_bootstrap) const FILE_READER_LISTENERS_SLOT: &str =
- "__moliFileReaderListeners";
pub(in crate::context_bootstrap) const FILE_READER_QUEUE_SLOT: &str = "__moliFileReaderQueue";
pub(in crate::context_bootstrap) const FILE_READER_SCHEDULED_SLOT: &str =
"__moliFileReaderScheduled";
@@ -140,8 +133,6 @@ pub(in crate::context_bootstrap) const MEDIA_QUERY_LIST_MATCHES_SLOT: &str =
"__moliMediaQueryListMatches";
pub(in crate::context_bootstrap) const MEDIA_QUERY_LIST_ONCHANGE_SLOT: &str =
"__moliMediaQueryListOnchange";
-pub(in crate::context_bootstrap) const MEDIA_QUERY_LIST_LISTENERS_SLOT: &str =
- "__moliMediaQueryListListeners";
pub(in crate::context_bootstrap) const MEDIA_QUERY_LIST_REGISTRY_SLOT: &str =
"__moliMediaQueryLists";
pub(in crate::context_bootstrap) const CRYPTO_KEY_KIND_SLOT: &str = "__moliCryptoKeyKind";
diff --git a/moli-renderer-v8/src/context_bootstrap/shared_event_targets.rs b/moli-renderer-v8/src/context_bootstrap/shared_event_targets.rs
index e59e7e08a..b048e80e3 100644
--- a/moli-renderer-v8/src/context_bootstrap/shared_event_targets.rs
+++ b/moli-renderer-v8/src/context_bootstrap/shared_event_targets.rs
@@ -140,15 +140,5 @@ fn handler_setter<'s>(
return;
};
let target = args.this();
- let Some(listeners) = media_queries::simple_event_target_slot_name(scope, target) else {
- return;
- };
- media_queries::simple_object_event_set_handler(
- scope,
- target,
- &listeners,
- event_type,
- slot,
- args.get(0),
- );
+ media_queries::simple_object_event_set_handler(scope, target, event_type, slot, args.get(0));
}
diff --git a/moli-renderer-v8/src/context_bootstrap/shared_worker_host.rs b/moli-renderer-v8/src/context_bootstrap/shared_worker_host.rs
index 5b5de1119..601be528f 100644
--- a/moli-renderer-v8/src/context_bootstrap/shared_worker_host.rs
+++ b/moli-renderer-v8/src/context_bootstrap/shared_worker_host.rs
@@ -7,7 +7,7 @@ use super::{
current_document_content_security_policies, current_document_referrer_policy,
document_referrer_policy_for_native_document,
},
- shared::SIMPLE_EVENT_TARGET_SLOT,
+ shared::SIMPLE_EVENT_TARGET_LISTENERS_SLOT,
simple_event_target_add_event_listener_callback, simple_event_target_dispatch_event_callback,
simple_event_target_remove_event_listener_callback, simple_object_event_listeners_snapshot,
simple_object_event_set_handler,
@@ -46,15 +46,14 @@ use moli_storage_key::MoliStorageKey;
use moli_webapi_declare::WebApiObject;
use url::Url;
-const SHARED_WORKER_LISTENERS_SLOT: &str = "__moliSharedWorkerListeners";
const SHARED_WORKER_CLIENT_ID_SLOT: &str = "__moliSharedWorkerClientId";
const SHARED_WORKER_ONERROR_SLOT: &str = "__moliSharedWorkerOnError";
#[derive(WebApiObject)]
#[webapi(interface = web_api_interfaces::SharedWorker)]
struct SharedWorkerObjectDeclaration<'scope> {
- #[webapi(slot = SIMPLE_EVENT_TARGET_SLOT, value = SHARED_WORKER_LISTENERS_SLOT)]
- event_target_slot: (),
+ #[webapi(slot = SIMPLE_EVENT_TARGET_LISTENERS_SLOT, init = "null_object")]
+ event_listeners: (),
#[webapi(slot = SHARED_WORKER_ONERROR_SLOT, init = "null")]
onerror_slot: (),
@@ -176,7 +175,6 @@ fn shared_worker_onerror_setter<'s>(
simple_object_event_set_handler(
scope,
args.this(),
- SHARED_WORKER_LISTENERS_SLOT,
"error",
SHARED_WORKER_ONERROR_SLOT,
args.get(0),
@@ -758,17 +756,10 @@ fn dispatch_shared_worker_error_event<'s>(
crate::context_bootstrap::mark_event_trusted(scope, event);
set_event_dispatch_fields(scope, worker, event);
- let listeners = simple_object_event_listeners_snapshot(
- scope,
- worker,
- SHARED_WORKER_LISTENERS_SLOT,
- "error",
- );
+ let listeners = simple_object_event_listeners_snapshot(scope, worker, "error");
let mut dispatched = false;
for listener in listeners {
- let Some(listener) =
- listener.prepare_for_invocation(scope, worker, SHARED_WORKER_LISTENERS_SLOT, "error")
- else {
+ let Some(listener) = listener.prepare_for_invocation(scope, worker, "error") else {
continue;
};
dispatched = true;
diff --git a/moli-renderer-v8/src/context_bootstrap/speech_synthesis.rs b/moli-renderer-v8/src/context_bootstrap/speech_synthesis.rs
index 579263803..02aac27ad 100644
--- a/moli-renderer-v8/src/context_bootstrap/speech_synthesis.rs
+++ b/moli-renderer-v8/src/context_bootstrap/speech_synthesis.rs
@@ -1,4 +1,4 @@
-use super::{SIMPLE_EVENT_TARGET_SLOT, simple_object_event_set_handler};
+use super::{SIMPLE_EVENT_TARGET_LISTENERS_SLOT, simple_object_event_set_handler};
use crate::util::{
callback_data_index_value, callback_data_item, get_private_value, set_private_value,
throw_type_error,
@@ -10,7 +10,6 @@ use moli_webapi_declare::{WebApiFunctionTemplate, WebApiObject, v8};
const SPEECH_SYNTHESIS_PENDING_SLOT: &str = "__lmSpeechSynthesisPending";
const SPEECH_SYNTHESIS_SPEAKING_SLOT: &str = "__lmSpeechSynthesisSpeaking";
const SPEECH_SYNTHESIS_PAUSED_SLOT: &str = "__lmSpeechSynthesisPaused";
-const SPEECH_SYNTHESIS_LISTENERS_SLOT: &str = "__lmSpeechSynthesisListeners";
const SPEECH_SYNTHESIS_ONVOICESCHANGED_SLOT: &str = "__lmSpeechSynthesisOnvoiceschanged";
const SPEECH_UTTERANCE_TEXT_SLOT: &str = "__lmSpeechSynthesisUtteranceText";
@@ -19,7 +18,6 @@ const SPEECH_UTTERANCE_VOICE_SLOT: &str = "__lmSpeechSynthesisUtteranceVoice";
const SPEECH_UTTERANCE_VOLUME_SLOT: &str = "__lmSpeechSynthesisUtteranceVolume";
const SPEECH_UTTERANCE_RATE_SLOT: &str = "__lmSpeechSynthesisUtteranceRate";
const SPEECH_UTTERANCE_PITCH_SLOT: &str = "__lmSpeechSynthesisUtterancePitch";
-const SPEECH_UTTERANCE_LISTENERS_SLOT: &str = "__lmSpeechSynthesisUtteranceListeners";
const SPEECH_UTTERANCE_ONSTART_SLOT: &str = "__lmSpeechSynthesisUtteranceOnstart";
const SPEECH_UTTERANCE_ONEND_SLOT: &str = "__lmSpeechSynthesisUtteranceOnend";
const SPEECH_UTTERANCE_ONERROR_SLOT: &str = "__lmSpeechSynthesisUtteranceOnerror";
@@ -49,8 +47,8 @@ struct SpeechSynthesisObjectDeclaration {
#[webapi(slot = SPEECH_SYNTHESIS_ONVOICESCHANGED_SLOT, init = "null")]
onvoiceschanged: (),
- #[webapi(slot = SIMPLE_EVENT_TARGET_SLOT, value = SPEECH_SYNTHESIS_LISTENERS_SLOT)]
- event_target_slot: (),
+ #[webapi(slot = SIMPLE_EVENT_TARGET_LISTENERS_SLOT, init = "null_object")]
+ event_listeners: (),
}
#[derive(Default, WebApiFunctionTemplate)]
@@ -142,8 +140,8 @@ struct SpeechSynthesisUtteranceObjectDeclaration<'scope> {
#[webapi(slot = SPEECH_UTTERANCE_ONBOUNDARY_SLOT, init = "null")]
onboundary: (),
- #[webapi(slot = SIMPLE_EVENT_TARGET_SLOT, value = SPEECH_UTTERANCE_LISTENERS_SLOT)]
- event_target_slot: (),
+ #[webapi(slot = SIMPLE_EVENT_TARGET_LISTENERS_SLOT, init = "null_object")]
+ event_listeners: (),
}
#[derive(Default, WebApiFunctionTemplate)]
@@ -388,7 +386,7 @@ pub(in crate::context_bootstrap) fn speech_synthesis_utterance_constructor_callb
onresume: (),
onmark: (),
onboundary: (),
- event_target_slot: (),
+ event_listeners: (),
};
if declaration.initialize(scope, utterance).is_err() {
rv.set_undefined();
@@ -524,7 +522,6 @@ fn speech_synthesis_onvoiceschanged_setter<'s>(
simple_object_event_set_handler(
scope,
args.this(),
- SPEECH_SYNTHESIS_LISTENERS_SLOT,
"voiceschanged",
SPEECH_SYNTHESIS_ONVOICESCHANGED_SLOT,
args.get(0),
@@ -721,7 +718,6 @@ fn speech_utterance_event_handler_setter<'s>(
simple_object_event_set_handler(
scope,
args.this(),
- SPEECH_UTTERANCE_LISTENERS_SLOT,
handler.event_type,
handler.slot,
args.get(0),
diff --git a/moli-renderer-v8/src/context_bootstrap/web_audio_runtime.rs b/moli-renderer-v8/src/context_bootstrap/web_audio_runtime.rs
index 1c8aad0eb..c523b1e63 100644
--- a/moli-renderer-v8/src/context_bootstrap/web_audio_runtime.rs
+++ b/moli-renderer-v8/src/context_bootstrap/web_audio_runtime.rs
@@ -19,7 +19,6 @@ mod node;
use audio_param::{audio_param, detune_param};
-const AUDIO_CONTEXT_LISTENERS_SLOT: &str = "__moliAudioContextListeners";
const AUDIO_CONTEXT_MODULES_SLOT: &str = "__moliAudioContextModules";
const AUDIO_CONTEXT_MODULE_LIST_SLOT: &str = "__moliAudioContextModuleList";
const AUDIO_CONTEXT_PROCESSORS_SLOT: &str = "__moliAudioContextProcessors";
@@ -52,8 +51,8 @@ struct AudioContextObjectDeclaration<'scope> {
state: &'static str,
#[webapi(data_property)]
destination: v8::Local<'scope, v8::Object>,
- #[webapi(slot = SIMPLE_EVENT_TARGET_SLOT, value = AUDIO_CONTEXT_LISTENERS_SLOT)]
- event_target_slot: (),
+ #[webapi(slot = SIMPLE_EVENT_TARGET_LISTENERS_SLOT, init = "null_object")]
+ event_listeners: (),
#[webapi(slot = AUDIO_CONTEXT_MODULES_SLOT)]
modules: v8::Local<'scope, v8::Object>,
#[webapi(slot = AUDIO_CONTEXT_MODULE_LIST_SLOT)]
@@ -140,8 +139,8 @@ struct OfflineAudioContextObjectDeclaration<'scope> {
channel_count: f64,
#[webapi(slot = OFFLINE_AUDIO_COMPRESSORS_SLOT)]
compressors: v8::Local<'scope, v8::Array>,
- #[webapi(slot = SIMPLE_EVENT_TARGET_SLOT)]
- event_target_slot: &'static str,
+ #[webapi(slot = SIMPLE_EVENT_TARGET_LISTENERS_SLOT, init = "null_object")]
+ event_listeners: (),
#[webapi(data_property)]
state: &'static str,
#[webapi(data_property)]
@@ -1330,7 +1329,6 @@ pub(in crate::context_bootstrap) fn offline_audio_context_constructor_callback<'
sample_rate,
channel_count,
compressors,
- OFFLINE_AUDIO_LISTENERS_SLOT,
"suspended",
destination,
)
@@ -1491,13 +1489,7 @@ fn offline_audio_context_complete_microtask_callback<'s>(
else {
return;
};
- let _ = dispatch_simple_event_target_event(
- scope,
- context,
- OFFLINE_AUDIO_LISTENERS_SLOT,
- "complete",
- event,
- );
+ let _ = dispatch_simple_event_target_event(scope, context, "complete", event);
}
fn remember_context_compressor<'s>(
diff --git a/moli-renderer-v8/src/context_bootstrap/web_audio_runtime/node.rs b/moli-renderer-v8/src/context_bootstrap/web_audio_runtime/node.rs
index 81891a825..a413f866c 100644
--- a/moli-renderer-v8/src/context_bootstrap/web_audio_runtime/node.rs
+++ b/moli-renderer-v8/src/context_bootstrap/web_audio_runtime/node.rs
@@ -7,7 +7,6 @@ const OUTPUT_COUNT: &str = "__moliAudioNodeOutputCount";
const CHANNEL_COUNT: &str = "__moliAudioNodeChannelCount";
const CHANNEL_MODE: &str = "__moliAudioNodeChannelMode";
const INTERPRETATION: &str = "__moliAudioNodeChannelInterpretation";
-const LISTENERS: &str = "__moliAudioNodeListeners";
#[derive(WebApiFunctionTemplate)]
#[webapi(interface = web_api_interfaces::AudioNode, enumerable, receiver)]
@@ -77,7 +76,7 @@ pub(super) fn initialize<'s>(scope: &mut v8::PinScope<'s, '_>, node: v8::Local<'
};
set_private_value(scope, node, CHANNEL_MODE, v8str(scope, mode).into());
set_private_value(scope, node, INTERPRETATION, v8str(scope, "speakers").into());
- super::super::media_queries::mark_simple_event_target_slot(scope, node, LISTENERS);
+ super::super::media_queries::initialize_simple_event_target(scope, node);
}
fn context_getter<'s>(
diff --git a/moli-renderer-v8/src/context_bootstrap/web_mcp/bindings.rs b/moli-renderer-v8/src/context_bootstrap/web_mcp/bindings.rs
index dd9399051..d8683aede 100644
--- a/moli-renderer-v8/src/context_bootstrap/web_mcp/bindings.rs
+++ b/moli-renderer-v8/src/context_bootstrap/web_mcp/bindings.rs
@@ -20,8 +20,8 @@ struct ModelContextObject<'s> {
prototype: v8::Local<'s, v8::Object>,
#[webapi(slot = DOCUMENT_SLOT)]
document: v8::Local<'s, v8::Object>,
- #[webapi(slot = crate::context_bootstrap::SIMPLE_EVENT_TARGET_SLOT, value = events::LISTENERS_SLOT)]
- event_target: (),
+ #[webapi(slot = crate::context_bootstrap::SIMPLE_EVENT_TARGET_LISTENERS_SLOT, init = "null_object")]
+ event_listeners: (),
}
#[derive(WebApiFunctionTemplate)]
@@ -106,7 +106,7 @@ pub(super) fn model_context_for_document<'s>(
let Ok(target) = ModelContextObject {
prototype,
document,
- event_target: (),
+ event_listeners: (),
}
.bind(scope) else {
return None;
diff --git a/moli-renderer-v8/src/context_bootstrap/web_mcp/events.rs b/moli-renderer-v8/src/context_bootstrap/web_mcp/events.rs
index 4e8ecbaf2..5cc59ef8c 100644
--- a/moli-renderer-v8/src/context_bootstrap/web_mcp/events.rs
+++ b/moli-renderer-v8/src/context_bootstrap/web_mcp/events.rs
@@ -7,7 +7,6 @@ use crate::native_bridge::JsContextHost;
use crate::util::get_private_value;
use crate::web_api_interfaces;
-pub(super) const LISTENERS_SLOT: &str = "__moliModelContextListeners";
const HANDLERS: &[(&str, &str)] = &[
("ontoolchange", "toolchange"),
("ontoolactivated", "toolactivated"),
@@ -54,11 +53,7 @@ pub(super) fn dispatch_event<'s>(
crate::context_bootstrap::events::mark_event_trusted(scope, event);
let owner = crate::context_bootstrap::shared_event_targets::shared_target_owner(scope, target);
crate::context_bootstrap::media_queries::dispatch_simple_event_target_event(
- scope,
- owner,
- LISTENERS_SLOT,
- event_type,
- event,
+ scope, owner, event_type, event,
);
}
@@ -100,7 +95,6 @@ pub(super) fn handler_setter<'s>(
crate::context_bootstrap::media_queries::simple_object_event_set_handler(
scope,
target,
- LISTENERS_SLOT,
event_type,
property,
args.get(0),
diff --git a/moli-renderer-v8/src/context_bootstrap/webrtc.rs b/moli-renderer-v8/src/context_bootstrap/webrtc.rs
index ccfab11d0..4c6635cb0 100644
--- a/moli-renderer-v8/src/context_bootstrap/webrtc.rs
+++ b/moli-renderer-v8/src/context_bootstrap/webrtc.rs
@@ -32,7 +32,6 @@ const RTC_PEER_CONNECTION_CURRENT_LOCAL_DESCRIPTION_SLOT: &str =
const RTC_PEER_CONNECTION_PENDING_LOCAL_DESCRIPTION_SLOT: &str =
"__moliRtcPeerConnectionPendingLocalDescription";
const RTC_PEER_CONNECTION_HAS_DATA_CHANNEL_SLOT: &str = "__moliRtcPeerConnectionHasDataChannel";
-const RTC_PEER_CONNECTION_LISTENERS_SLOT: &str = "__moliRtcPeerConnectionListeners";
const RTC_DATA_CHANNEL_LABEL_SLOT: &str = "__moliRtcDataChannelLabel";
const RTC_DATA_CHANNEL_ORDERED_SLOT: &str = "__moliRtcDataChannelOrdered";
@@ -44,7 +43,6 @@ const RTC_DATA_CHANNEL_ID_SLOT: &str = "__moliRtcDataChannelId";
const RTC_DATA_CHANNEL_READY_STATE_SLOT: &str = "__moliRtcDataChannelReadyState";
const RTC_DATA_CHANNEL_BUFFERED_AMOUNT_SLOT: &str = "__moliRtcDataChannelBufferedAmount";
const RTC_DATA_CHANNEL_BINARY_TYPE_SLOT: &str = "__moliRtcDataChannelBinaryType";
-const RTC_DATA_CHANNEL_LISTENERS_SLOT: &str = "__moliRtcDataChannelListeners";
const RTC_PEER_CONNECTION_STATE_SLOTS: &[&str] = &[
RTC_PEER_CONNECTION_SIGNALING_STATE_SLOT,
@@ -93,8 +91,8 @@ struct RtcPeerConnectionObjectDeclaration<'scope> {
pending_local_description: (),
#[webapi(slot = RTC_PEER_CONNECTION_HAS_DATA_CHANNEL_SLOT, init = false)]
has_data_channel: (),
- #[webapi(slot = SIMPLE_EVENT_TARGET_SLOT, value = RTC_PEER_CONNECTION_LISTENERS_SLOT)]
- event_target_slot: (),
+ #[webapi(slot = SIMPLE_EVENT_TARGET_LISTENERS_SLOT, init = "null_object")]
+ event_listeners: (),
}
#[derive(WebApiObject)]
@@ -120,8 +118,8 @@ struct RtcDataChannelObjectDeclaration<'scope> {
buffered_amount: (),
#[webapi(slot = RTC_DATA_CHANNEL_BINARY_TYPE_SLOT, init = string("arraybuffer"))]
binary_type: (),
- #[webapi(slot = SIMPLE_EVENT_TARGET_SLOT, value = RTC_DATA_CHANNEL_LISTENERS_SLOT)]
- event_target_slot: (),
+ #[webapi(slot = SIMPLE_EVENT_TARGET_LISTENERS_SLOT, init = "null_object")]
+ event_listeners: (),
}
#[derive(WebApiObject)]
@@ -255,7 +253,7 @@ pub(in crate::context_bootstrap) fn rtc_peer_connection_constructor_callback<'s>
current_local_description: (),
pending_local_description: (),
has_data_channel: (),
- event_target_slot: (),
+ event_listeners: (),
};
if declaration.initialize(scope, args.this()).is_err() {
rv.set_undefined();
diff --git a/moli-renderer-v8/src/context_bootstrap/websocket.rs b/moli-renderer-v8/src/context_bootstrap/websocket.rs
index fa04eab2e..2c5e04194 100644
--- a/moli-renderer-v8/src/context_bootstrap/websocket.rs
+++ b/moli-renderer-v8/src/context_bootstrap/websocket.rs
@@ -4,8 +4,9 @@ use super::media_queries::{
simple_event_target_remove_event_listener_callback, simple_object_event_set_handler,
};
use super::shared::{
- READABLE_STREAM_HWM_SLOT, READABLE_STREAM_PENDING_READS_SLOT, SIMPLE_EVENT_TARGET_SLOT,
- WRITABLE_STREAM_SINK_SLOT, define_non_enumerable_string_property, global_constructor_prototype,
+ READABLE_STREAM_HWM_SLOT, READABLE_STREAM_PENDING_READS_SLOT,
+ SIMPLE_EVENT_TARGET_LISTENERS_SLOT, WRITABLE_STREAM_SINK_SLOT,
+ define_non_enumerable_string_property, global_constructor_prototype,
new_uint8_array_from_bytes,
};
use super::stream_adapter::{
@@ -21,7 +22,6 @@ use crate::{
};
use moli_websocket::Event as WebSocketEvent;
-const WEBSOCKET_LISTENERS_SLOT: &str = "__moliWebSocketListeners";
const WEBSOCKET_ID_SLOT: &str = "__moliWebSocketId";
const WEBSOCKET_URL_SLOT: &str = "__moliWebSocketUrl";
const WEBSOCKET_READY_STATE_SLOT: &str = "__moliWebSocketReadyState";
diff --git a/moli-renderer-v8/src/context_bootstrap/websocket/accessors.rs b/moli-renderer-v8/src/context_bootstrap/websocket/accessors.rs
index e29bbf4b2..dc200b1a7 100644
--- a/moli-renderer-v8/src/context_bootstrap/websocket/accessors.rs
+++ b/moli-renderer-v8/src/context_bootstrap/websocket/accessors.rs
@@ -275,7 +275,6 @@ fn websocket_event_handler_setter_function<'s>(
simple_object_event_set_handler(
scope,
args.this(),
- WEBSOCKET_LISTENERS_SLOT,
handler.event_type,
handler.slot_name,
args.get(0),
diff --git a/moli-renderer-v8/src/context_bootstrap/websocket/constructor.rs b/moli-renderer-v8/src/context_bootstrap/websocket/constructor.rs
index da1fdefdc..789813107 100644
--- a/moli-renderer-v8/src/context_bootstrap/websocket/constructor.rs
+++ b/moli-renderer-v8/src/context_bootstrap/websocket/constructor.rs
@@ -48,8 +48,8 @@ struct WebSocketObjectDeclaration {
#[webapi(slot = WEBSOCKET_ONCLOSE_SLOT, init = "null")]
onclose: (),
- #[webapi(slot = SIMPLE_EVENT_TARGET_SLOT, value = WEBSOCKET_LISTENERS_SLOT)]
- event_target_slot: (),
+ #[webapi(slot = SIMPLE_EVENT_TARGET_LISTENERS_SLOT, init = "null_object")]
+ event_listeners: (),
#[webapi(method, enumerable, callback = simple_event_target_add_event_listener_callback)]
add_event_listener: (),
diff --git a/moli-renderer-v8/src/context_bootstrap/websocket/dispatch.rs b/moli-renderer-v8/src/context_bootstrap/websocket/dispatch.rs
index 268fcc3d9..359b2133a 100644
--- a/moli-renderer-v8/src/context_bootstrap/websocket/dispatch.rs
+++ b/moli-renderer-v8/src/context_bootstrap/websocket/dispatch.rs
@@ -47,14 +47,7 @@ pub(crate) fn dispatch_websocket_event<'s>(
let Some(event) = new_message_event(scope, data, &origin) else {
return WebSocketDispatchResult::Noop;
};
- dispatch_simple_event_target_event(
- scope,
- socket,
- WEBSOCKET_LISTENERS_SLOT,
- "message",
- event,
- )
- .into()
+ dispatch_simple_event_target_event(scope, socket, "message", event).into()
}
WebSocketEvent::BinaryMessage { data, .. } => {
let Some(data) = websocket_binary_message_data(scope, socket, data.clone()) else {
@@ -64,14 +57,7 @@ pub(crate) fn dispatch_websocket_event<'s>(
let Some(event) = new_message_event(scope, data, &origin) else {
return WebSocketDispatchResult::Noop;
};
- dispatch_simple_event_target_event(
- scope,
- socket,
- WEBSOCKET_LISTENERS_SLOT,
- "message",
- event,
- )
- .into()
+ dispatch_simple_event_target_event(scope, socket, "message", event).into()
}
WebSocketEvent::SendCompleted { payload_length, .. } => {
add_buffered_amount(scope, socket, -(*payload_length as f64));
@@ -97,14 +83,7 @@ pub(crate) fn dispatch_websocket_event<'s>(
set_websocket_ready_state(scope, socket, CLOSED);
let event = new_close_event(scope, *code, reason, *was_clean)
.unwrap_or_else(|| simple_event_object(scope, "close"));
- dispatch_simple_event_target_event(
- scope,
- socket,
- WEBSOCKET_LISTENERS_SLOT,
- "close",
- event,
- )
- .into()
+ dispatch_simple_event_target_event(scope, socket, "close", event).into()
}
}
}
diff --git a/moli-renderer-v8/src/context_bootstrap/websocket/events.rs b/moli-renderer-v8/src/context_bootstrap/websocket/events.rs
index e073b5ecb..6fa6f2dc6 100644
--- a/moli-renderer-v8/src/context_bootstrap/websocket/events.rs
+++ b/moli-renderer-v8/src/context_bootstrap/websocket/events.rs
@@ -23,7 +23,7 @@ pub(super) fn dispatch_named_event<'s>(
event_type: &str,
) -> bool {
let event = simple_event_object(scope, event_type);
- dispatch_simple_event_target_event(scope, socket, WEBSOCKET_LISTENERS_SLOT, event_type, event)
+ dispatch_simple_event_target_event(scope, socket, event_type, event)
}
pub(super) fn simple_event_object<'s>(
diff --git a/moli-renderer-v8/src/context_bootstrap/window_runtime/service_worker.rs b/moli-renderer-v8/src/context_bootstrap/window_runtime/service_worker.rs
index 876b1c6b7..b54349bd7 100644
--- a/moli-renderer-v8/src/context_bootstrap/window_runtime/service_worker.rs
+++ b/moli-renderer-v8/src/context_bootstrap/window_runtime/service_worker.rs
@@ -15,7 +15,6 @@ use crate::worker::WorkerScriptKind;
use moli_webapi_declare::{ObjectLiteralDeclaration, WebApiObject, WebApiObjectDeclaration};
const SERVICE_WORKER_REGISTRATION_SCOPE_SLOT: &str = "__moliServiceWorkerRegistrationScope";
-const SERVICE_WORKER_REGISTRATION_EVENTS_SLOT: &str = "__moliServiceWorkerRegistrationEvents";
const SERVICE_WORKER_REGISTRATION_WORKER_SLOT: &str = "__moliServiceWorkerRegistrationWorker";
const SERVICE_WORKER_REGISTRATION_WORKERS_SLOT: &str = "__moliServiceWorkerRegistrationWorkers";
const SERVICE_WORKER_SYNC_MANAGER_SCOPE_SLOT: &str = "__moliServiceWorkerSyncManagerScope";
@@ -26,7 +25,6 @@ const SERVICE_WORKER_PUSH_SUBSCRIPTION_SCOPE_SLOT: &str =
"__moliServiceWorkerPushSubscriptionScope";
const SERVICE_WORKER_NAVIGATION_PRELOAD_MANAGER_SCOPE_SLOT: &str =
"__moliServiceWorkerNavigationPreloadManagerScope";
-const SERVICE_WORKER_WORKER_EVENTS_SLOT: &str = "__moliServiceWorkerEvents";
const SERVICE_WORKER_WORKER_REGISTRATION_SLOT: &str = "__moliServiceWorkerWorkerRegistration";
const SERVICE_WORKER_WORKER_VERSION_ID_SLOT: &str = "__moliServiceWorkerVersionId";
const SERVICE_WORKER_CONTAINER_ONMESSAGE_SLOT: &str = "__moliServiceWorkerContainerOnmessage";
@@ -34,7 +32,6 @@ const SERVICE_WORKER_CONTAINER_ONMESSAGEERROR_SLOT: &str =
"__moliServiceWorkerContainerOnmessageerror";
const SERVICE_WORKER_CONTAINER_ONCONTROLLERCHANGE_SLOT: &str =
"__moliServiceWorkerContainerOncontrollerchange";
-const SERVICE_WORKER_CONTAINER_LISTENERS_SLOT: &str = "__moliServiceWorkerContainerEvents";
const SERVICE_WORKER_CONTAINER_REGISTRATIONS_SLOT: &str =
"__moliServiceWorkerContainerRegistrations";
const SERVICE_WORKER_CONTAINER_CONTROLLER_SLOT: &str = "__moliServiceWorkerContainerController";
@@ -653,7 +650,6 @@ pub(crate) fn dispatch_service_worker_lifecycle_notification(
callback_effect = callback_effect.merge(dispatch_service_worker_simple_event(
scope,
registration,
- SERVICE_WORKER_REGISTRATION_EVENTS_SLOT,
"updatefound",
));
}
@@ -667,13 +663,9 @@ pub(crate) fn dispatch_service_worker_lifecycle_notification(
*version_id,
) {
service_worker_worker_set_state(scope, worker, state);
- callback_effect =
- callback_effect.merge(dispatch_service_worker_simple_event(
- scope,
- worker,
- SERVICE_WORKER_WORKER_EVENTS_SLOT,
- "statechange",
- ));
+ callback_effect = callback_effect.merge(
+ dispatch_service_worker_simple_event(scope, worker, "statechange"),
+ );
}
}
}
@@ -799,13 +791,7 @@ fn dispatch_service_worker_client_message_in_owner_scope<'s>(
if let Some(event) = event {
let callback_effect =
service_worker_client_message_callback_dispatch_effect(scope, container, "message");
- let _ = dispatch_simple_event_target_event(
- scope,
- container,
- SERVICE_WORKER_CONTAINER_LISTENERS_SLOT,
- "message",
- event,
- );
+ let _ = dispatch_simple_event_target_event(scope, container, "message", event);
return ServiceWorkerClientMessageDispatchEffect::MessageDispatched { callback_effect };
}
ServiceWorkerClientMessageDispatchEffect::CurrentTargetProducedNoDispatchableEvent
@@ -832,13 +818,7 @@ fn dispatch_service_worker_client_messageerror<'s>(
container,
"messageerror",
);
- let _ = dispatch_simple_event_target_event(
- scope,
- container,
- SERVICE_WORKER_CONTAINER_LISTENERS_SLOT,
- "messageerror",
- event,
- );
+ let _ = dispatch_simple_event_target_event(scope, container, "messageerror", event);
return Some(callback_effect);
}
None
@@ -850,10 +830,7 @@ fn service_worker_client_message_callback_dispatch_effect<'s>(
event_type: &str,
) -> ServiceWorkerClientMessageCallbackDispatchEffect {
if crate::context_bootstrap::simple_object_event_listeners_snapshot(
- scope,
- container,
- SERVICE_WORKER_CONTAINER_LISTENERS_SLOT,
- event_type,
+ scope, container, event_type,
)
.is_empty()
{
@@ -872,12 +849,8 @@ pub(crate) fn dispatch_service_worker_controller_change(
owner.restore(scope, previous_owner_context);
return ServiceWorkerInternalEventCallbackDispatchEffect::NoCallbackBodyDispatched;
};
- let callback_effect = dispatch_service_worker_simple_event(
- scope,
- container,
- SERVICE_WORKER_CONTAINER_LISTENERS_SLOT,
- "controllerchange",
- );
+ let callback_effect =
+ dispatch_service_worker_simple_event(scope, container, "controllerchange");
owner.defer_restore(scope, previous_owner_context);
callback_effect
}
@@ -1026,7 +999,6 @@ pub(in crate::context_bootstrap) fn navigator_service_worker_message_handler_set
simple_object_event_set_handler(
scope,
args.this(),
- SERVICE_WORKER_CONTAINER_LISTENERS_SLOT,
"message",
SERVICE_WORKER_CONTAINER_ONMESSAGE_SLOT,
args.get(0),
@@ -1059,7 +1031,6 @@ pub(in crate::context_bootstrap) fn navigator_service_worker_messageerror_handle
simple_object_event_set_handler(
scope,
args.this(),
- SERVICE_WORKER_CONTAINER_LISTENERS_SLOT,
"messageerror",
SERVICE_WORKER_CONTAINER_ONMESSAGEERROR_SLOT,
args.get(0),
@@ -1092,7 +1063,6 @@ pub(in crate::context_bootstrap) fn navigator_service_worker_controllerchange_ha
simple_object_event_set_handler(
scope,
args.this(),
- SERVICE_WORKER_CONTAINER_LISTENERS_SLOT,
"controllerchange",
SERVICE_WORKER_CONTAINER_ONCONTROLLERCHANGE_SLOT,
args.get(0),
@@ -2056,12 +2026,7 @@ pub(crate) fn settle_service_worker_unregister_completion<'s>(
}
if let Some(active_worker) = active_worker {
service_worker_worker_set_state(scope, active_worker, "redundant");
- dispatch_service_worker_simple_event(
- scope,
- active_worker,
- SERVICE_WORKER_WORKER_EVENTS_SLOT,
- "statechange",
- );
+ dispatch_service_worker_simple_event(scope, active_worker, "statechange");
}
}
let _ = resolver.resolve(scope, v8::Boolean::new(scope, removed).into());
@@ -2876,14 +2841,14 @@ fn mark_service_worker_registration_event_target<'s>(
scope: &mut v8::PinScope<'s, '_>,
registration: v8::Local<'s, v8::Object>,
) {
- mark_simple_event_target_slot(scope, registration, SERVICE_WORKER_REGISTRATION_EVENTS_SLOT);
+ initialize_simple_event_target(scope, registration);
}
fn mark_service_worker_worker_event_target<'s>(
scope: &mut v8::PinScope<'s, '_>,
worker: v8::Local<'s, v8::Object>,
) {
- mark_simple_event_target_slot(scope, worker, SERVICE_WORKER_WORKER_EVENTS_SLOT);
+ initialize_simple_event_target(scope, worker);
}
fn service_worker_registration_add_event_listener_callback<'s>(
@@ -3148,11 +3113,10 @@ fn set_service_worker_registration_worker_values<'s>(
fn dispatch_service_worker_simple_event<'s>(
scope: &mut v8::PinScope<'s, '_>,
target: v8::Local<'s, v8::Object>,
- slot_name: &str,
event_type: &'static str,
) -> ServiceWorkerInternalEventCallbackDispatchEffect {
let callback_effect = if crate::context_bootstrap::simple_object_event_listeners_snapshot(
- scope, target, slot_name, event_type,
+ scope, target, event_type,
)
.is_empty()
{
@@ -3163,7 +3127,7 @@ fn dispatch_service_worker_simple_event<'s>(
let event = v8::Object::new(scope);
let _ =
ServiceWorkerSimpleEventDeclaration::new(v8str(scope, event_type)).initialize(scope, event);
- dispatch_simple_event_target_event(scope, target, slot_name, event_type, event);
+ dispatch_simple_event_target_event(scope, target, event_type, event);
callback_effect
}
diff --git a/moli-renderer-v8/src/context_bootstrap/worker_host/constructor.rs b/moli-renderer-v8/src/context_bootstrap/worker_host/constructor.rs
index 8599413d6..9f14bf9ef 100644
--- a/moli-renderer-v8/src/context_bootstrap/worker_host/constructor.rs
+++ b/moli-renderer-v8/src/context_bootstrap/worker_host/constructor.rs
@@ -49,8 +49,8 @@ const WORKER_EVENT_HANDLERS: &[WorkerEventHandler] = &[
#[derive(WebApiObject)]
#[webapi(interface = web_api_interfaces::Worker)]
struct WorkerObjectDeclaration {
- #[webapi(slot = SIMPLE_EVENT_TARGET_SLOT, value = WORKER_LISTENERS_SLOT)]
- event_target_slot: (),
+ #[webapi(slot = SIMPLE_EVENT_TARGET_LISTENERS_SLOT, init = "null_object")]
+ event_listeners: (),
#[webapi(slot = WORKER_ONMESSAGE_SLOT, init = "null")]
onmessage_slot: (),
@@ -695,7 +695,6 @@ fn worker_event_handler_setter<'s>(
simple_object_event_set_handler(
scope,
args.this(),
- WORKER_LISTENERS_SLOT,
handler.event_type,
handler.slot_name,
args.get(0),
diff --git a/moli-renderer-v8/src/context_bootstrap/worker_host/dispatch.rs b/moli-renderer-v8/src/context_bootstrap/worker_host/dispatch.rs
index 016e086b3..08051c782 100644
--- a/moli-renderer-v8/src/context_bootstrap/worker_host/dispatch.rs
+++ b/moli-renderer-v8/src/context_bootstrap/worker_host/dispatch.rs
@@ -3,7 +3,7 @@ use std::pin::pin;
use moli_webapi_declare::WebApiObject;
-use super::{WORKER_LISTENERS_SLOT, WORKER_ONERROR_SLOT};
+use super::WORKER_ONERROR_SLOT;
use crate::context_bootstrap::{
dispatch_simple_event_target_event,
events::{clear_event_dispatch_fields, construct_original_event, set_event_dispatch_fields},
@@ -175,16 +175,14 @@ fn dispatch_worker_message_event<'s>(
ports: v8::Local<'s, v8::Array>,
) {
let event = new_message_event(scope, event_type, data, ports);
- let _ =
- dispatch_simple_event_target_event(scope, worker, WORKER_LISTENERS_SLOT, event_type, event);
+ let _ = dispatch_simple_event_target_event(scope, worker, event_type, event);
}
pub(crate) fn worker_has_message_listener<'s>(
scope: &mut v8::PinScope<'s, '_>,
worker: v8::Local<'s, v8::Object>,
) -> bool {
- !simple_object_event_listeners_snapshot(scope, worker, WORKER_LISTENERS_SLOT, "message")
- .is_empty()
+ !simple_object_event_listeners_snapshot(scope, worker, "message").is_empty()
}
pub(crate) fn worker_has_message_delivery_listener<'s>(
@@ -192,13 +190,7 @@ pub(crate) fn worker_has_message_delivery_listener<'s>(
worker: v8::Local<'s, v8::Object>,
) -> bool {
worker_has_message_listener(scope, worker)
- || !simple_object_event_listeners_snapshot(
- scope,
- worker,
- WORKER_LISTENERS_SLOT,
- "messageerror",
- )
- .is_empty()
+ || !simple_object_event_listeners_snapshot(scope, worker, "messageerror").is_empty()
}
pub(crate) fn flush_pending_worker_messages_for_listener<'s>(
@@ -229,12 +221,9 @@ pub(crate) fn dispatch_worker_error_event_with_kind<'s>(
crate::context_bootstrap::mark_event_trusted(scope, event);
set_event_dispatch_fields(scope, worker, event);
- let listeners =
- simple_object_event_listeners_snapshot(scope, worker, WORKER_LISTENERS_SLOT, "error");
+ let listeners = simple_object_event_listeners_snapshot(scope, worker, "error");
for listener in listeners {
- let Some(listener) =
- listener.prepare_for_invocation(scope, worker, WORKER_LISTENERS_SLOT, "error")
- else {
+ let Some(listener) = listener.prepare_for_invocation(scope, worker, "error") else {
continue;
};
let callback_result = invoke_simple_event_listener(
diff --git a/moli-renderer-v8/src/context_bootstrap/worker_host/mod.rs b/moli-renderer-v8/src/context_bootstrap/worker_host/mod.rs
index f782221a7..e6c82e56a 100644
--- a/moli-renderer-v8/src/context_bootstrap/worker_host/mod.rs
+++ b/moli-renderer-v8/src/context_bootstrap/worker_host/mod.rs
@@ -2,7 +2,7 @@ use super::media_queries::{
simple_event_target_add_event_listener_callback, simple_event_target_dispatch_event_callback,
simple_event_target_remove_event_listener_callback, simple_object_event_set_handler,
};
-use super::shared::SIMPLE_EVENT_TARGET_SLOT;
+use super::shared::SIMPLE_EVENT_TARGET_LISTENERS_SLOT;
use crate::{
util::context_host_ptr_from_global_bridge,
util::{
@@ -17,7 +17,6 @@ use crate::{
const WORKER_HANDLE_SLOT: &str = "__moliWorkerHandle";
const WORKER_ID_SLOT: &str = "__moliWorkerId";
-const WORKER_LISTENERS_SLOT: &str = "__moliWorkerListeners";
const WORKER_ONMESSAGE_SLOT: &str = "__moliWorkerOnMessage";
const WORKER_ONMESSAGEERROR_SLOT: &str = "__moliWorkerOnMessageError";
const WORKER_ONERROR_SLOT: &str = "__moliWorkerOnError";
diff --git a/moli-renderer-v8/src/native_bridge/context_host/popups.rs b/moli-renderer-v8/src/native_bridge/context_host/popups.rs
index cc4f96f77..072b4dbb7 100644
--- a/moli-renderer-v8/src/native_bridge/context_host/popups.rs
+++ b/moli-renderer-v8/src/native_bridge/context_host/popups.rs
@@ -5,11 +5,11 @@ use crate::web_api_interfaces;
use crate::{
content_security_policy::content_security_policy_forces_opaque_origin,
context_bootstrap::{
- SharedWebStorageStore, WINDOW_NAME_SLOT, apply_local_window_location_navigation,
- clear_simple_window_event_handler_values, deep_clone_shared_web_storage_store,
- dispatch_simple_event_target_event, install_navigation_bootstrap_entry_for_holder,
- install_simple_event_target_methods, install_simple_window_event_handlers,
- install_storage_aliases_for_window,
+ SIMPLE_EVENT_TARGET_LISTENERS_SLOT, SharedWebStorageStore, WINDOW_NAME_SLOT,
+ apply_local_window_location_navigation, clear_simple_window_event_handler_values,
+ deep_clone_shared_web_storage_store, dispatch_simple_event_target_event,
+ install_navigation_bootstrap_entry_for_holder, install_simple_event_target_methods,
+ install_simple_window_event_handlers, install_storage_aliases_for_window,
install_window_location_history_navigation_runtime_state, new_shared_web_storage_store,
scoped_indexed_db_factory, sync_document_location_runtime_state_from_window,
sync_window_location_history_navigation_runtime_surface,
@@ -41,8 +41,8 @@ use crate::{
},
util::{
context_host_ptr_from_global_bridge, define_non_enumerable_static_property,
- get_private_value, global_constructor_object, set_private_value, throw_type_error,
- v8_string, v8str,
+ get_private_value, global_constructor_object, new_null_prototype_object, set_private_value,
+ throw_type_error, v8_string, v8str,
},
window_document_identity::{
LightweightPopupDocumentId, LightweightPopupDocumentOwner, LightweightPopupLocalWindowId,
@@ -58,7 +58,6 @@ use moli_webapi_declare::{ObjectLiteralDeclaration, WebApiObject};
use std::collections::{HashMap, HashSet};
use url::Url;
-const LIGHTWEIGHT_POPUP_EVENT_LISTENERS_SLOT: &str = "__lmLightweightPopupEventListeners";
const LIGHTWEIGHT_POPUP_ID_SLOT: &str = "__lmLightweightPopupId";
const LIGHTWEIGHT_POPUP_OPENER_SLOT: &str = "__lmLightweightPopupOpener";
const ACTIVE_LIGHTWEIGHT_POPUP_ID_SLOT: &str = "__lmActiveLightweightPopupId";
@@ -866,7 +865,7 @@ impl JsContextHost {
}
}
let _ = install_storage_aliases_for_window(scope, window);
- install_simple_event_target_methods(scope, window, LIGHTWEIGHT_POPUP_EVENT_LISTENERS_SLOT);
+ install_simple_event_target_methods(scope, window);
install_simple_window_event_handlers(scope, window);
let _ = LightweightPopupWindowMethodsDeclaration::default().initialize(scope, window);
let initial_document_owner = self.allocate_lightweight_popup_document_owner(popup_id);
@@ -2913,13 +2912,8 @@ impl JsContextHost {
let previous_message_source = self.enter_window_message_source_scope(
super::PendingWindowMessageEndpoint::LightweightPopup(popup_id),
);
- let allows_default = dispatch_simple_event_target_event(
- popup_scope,
- window,
- LIGHTWEIGHT_POPUP_EVENT_LISTENERS_SLOT,
- event_type,
- event,
- );
+ let allows_default =
+ dispatch_simple_event_target_event(popup_scope, window, event_type, event);
self.restore_window_message_source_scope(previous_message_source);
restore_lightweight_popup_event_dispatch(popup_scope, previous);
allows_default
@@ -4934,12 +4928,12 @@ fn clear_lightweight_popup_window_document_event_state<'s>(
scope: &mut v8::PinScope<'s, '_>,
window: v8::Local<'s, v8::Object>,
) {
- let undefined = v8::undefined(scope);
+ let registry = new_null_prototype_object(scope);
set_private_value(
scope,
window,
- LIGHTWEIGHT_POPUP_EVENT_LISTENERS_SLOT,
- undefined.into(),
+ SIMPLE_EVENT_TARGET_LISTENERS_SLOT,
+ registry.into(),
);
clear_simple_window_event_handler_values(scope, window);
}
diff --git a/moli-renderer-v8/src/native_bridge/document/detached_install/accessors/iframe_window_messaging.rs b/moli-renderer-v8/src/native_bridge/document/detached_install/accessors/iframe_window_messaging.rs
index a427c13f3..5021d2952 100644
--- a/moli-renderer-v8/src/native_bridge/document/detached_install/accessors/iframe_window_messaging.rs
+++ b/moli-renderer-v8/src/native_bridge/document/detached_install/accessors/iframe_window_messaging.rs
@@ -10,8 +10,6 @@ use moli_webapi_declare::WebApiObject;
use super::iframe_window_message_event::{detached_window_message_event, detached_window_origin};
-const DETACHED_IFRAME_WINDOW_EVENT_LISTENERS_SLOT: &str = "__lmDetachedIframeWindowEventListeners";
-
#[derive(Default, WebApiObject)]
#[webapi(plain)]
struct DetachedIframeWindowMethodsDeclaration {
@@ -23,7 +21,7 @@ pub(super) fn install_detached_iframe_window_messaging<'s>(
scope: &mut v8::PinScope<'s, '_>,
window: v8::Local<'s, v8::Object>,
) {
- install_simple_event_target_methods(scope, window, DETACHED_IFRAME_WINDOW_EVENT_LISTENERS_SLOT);
+ install_simple_event_target_methods(scope, window);
install_simple_window_event_handlers(scope, window);
let _ = DetachedIframeWindowMethodsDeclaration::default().initialize(scope, window);
let _ = install_child_window_own_methods(scope, window);
@@ -130,12 +128,6 @@ fn detached_iframe_window_post_message<'s>(
rv.set_undefined();
return;
};
- dispatch_simple_event_target_event(
- scope,
- target,
- DETACHED_IFRAME_WINDOW_EVENT_LISTENERS_SLOT,
- event_type,
- event,
- );
+ dispatch_simple_event_target_event(scope, target, event_type, event);
rv.set_undefined();
}
diff --git a/moli-renderer-v8/src/native_bridge/element/media/text_tracks.rs b/moli-renderer-v8/src/native_bridge/element/media/text_tracks.rs
index e0821d154..8c9c88221 100644
--- a/moli-renderer-v8/src/native_bridge/element/media/text_tracks.rs
+++ b/moli-renderer-v8/src/native_bridge/element/media/text_tracks.rs
@@ -1,6 +1,6 @@
use crate::context_bootstrap::{
- dispatch_simple_event_target_event, mark_simple_event_target_slot, set_text_track_cue_track,
- simple_event_target_slot_name, simple_object_event_set_handler,
+ dispatch_simple_event_target_event, initialize_simple_event_target, set_text_track_cue_track,
+ simple_object_event_set_handler,
};
use crate::document_runtime::DomHandle;
use crate::dom::native::Node;
@@ -27,7 +27,6 @@ use super::super::{
const TEXT_TRACK_CACHE_SLOT: &str = "__moliTextTrack";
const TEXT_TRACKS_CACHE_SLOT: &str = "__moliTextTracks";
const TEXT_TRACKS_MANUAL_SLOT: &str = "__moliTextTracksManual";
-const TEXT_TRACK_LIST_LISTENERS_SLOT: &str = "__moliTextTrackListListeners";
const TEXT_TRACK_OWNER_HANDLE_SLOT: &str = "__moliTextTrackOwnerHandle";
const TEXT_TRACK_MEDIA_HANDLE_SLOT: &str = "__moliTextTrackMediaHandle";
const TEXT_TRACK_KIND_SLOT: &str = "__moliTextTrackKind";
@@ -365,7 +364,7 @@ fn make_text_track_list<'s>(scope: &mut v8::PinScope<'s, '_>) -> Option<v8::Loca
let list = TextTrackListObjectDeclaration::new(Vec::new())
.bind(scope)
.ok()?;
- mark_simple_event_target_slot(scope, list, TEXT_TRACK_LIST_LISTENERS_SLOT);
+ initialize_simple_event_target(scope, list);
update_indexed_list(scope, list, &[]);
Some(list)
}
@@ -524,7 +523,7 @@ fn make_text_track<'s>(
)
.bind(scope)
.ok()?;
- mark_simple_event_target_slot(scope, track, "__moliTextTrackListeners");
+ initialize_simple_event_target(scope, track);
let cues = make_cue_list(scope)?;
let active_cues = make_cue_list(scope)?;
set_private_value(scope, track, TEXT_TRACK_CUES_SLOT, cues.into());
@@ -938,10 +937,7 @@ fn text_track_event_handler_setter<'s>(
event_type: &str,
slot: &'static str,
) {
- let Some(listeners_slot) = simple_event_target_slot_name(scope, receiver) else {
- return;
- };
- simple_object_event_set_handler(scope, receiver, &listeners_slot, event_type, slot, value);
+ simple_object_event_set_handler(scope, receiver, event_type, slot, value);
}
fn text_track_add_cue_callback<'s>(
@@ -1691,13 +1687,7 @@ pub(crate) fn dispatch_text_track_list_event<'s>(
return false;
};
if let Some(event) = construct_event(scope, "TrackEvent", event_type, init) {
- let _ = dispatch_simple_event_target_event(
- scope,
- list,
- TEXT_TRACK_LIST_LISTENERS_SLOT,
- event_type,
- event,
- );
+ let _ = dispatch_simple_event_target_event(scope, list, event_type, event);
true
} else {
false
diff --git a/moli-renderer-v8/src/network_host.rs b/moli-renderer-v8/src/network_host.rs
index c1bff22a9..350ee40f1 100644
--- a/moli-renderer-v8/src/network_host.rs
+++ b/moli-renderer-v8/src/network_host.rs
@@ -189,7 +189,6 @@ pub(crate) use self::xhr::{
apply_xhr_streaming_response_body_source, apply_xhr_streaming_response_chunk,
apply_xhr_streaming_response_head, apply_xhr_timeout, convert_xhr_send_body_from_args,
dispatch_xhr_loadstart, dispatch_xhr_upload_abort_if_in_progress, dispatch_xhr_upload_complete,
- finalize_xml_http_request_event_target_realm_bindings,
install_progress_event_template_bindings, install_window_xml_http_request_template_bindings,
install_xml_http_request_bindings, install_xml_http_request_event_target_bindings,
progress_event_constructor_callback, reset_xhr_response_for_request_error, set_xhr_state_bool,
diff --git a/moli-renderer-v8/src/network_host/event_source.rs b/moli-renderer-v8/src/network_host/event_source.rs
index c755fcd4b..4b7e11161 100644
--- a/moli-renderer-v8/src/network_host/event_source.rs
+++ b/moli-renderer-v8/src/network_host/event_source.rs
@@ -3,7 +3,8 @@ mod parser;
mod request;
use crate::context_bootstrap::{
- SIMPLE_EVENT_TARGET_SLOT, dispatch_simple_event_target_event, simple_object_event_set_handler,
+ SIMPLE_EVENT_TARGET_LISTENERS_SLOT, dispatch_simple_event_target_event,
+ simple_object_event_set_handler,
};
use crate::util::{
callback_data_index_value, callback_data_item, context_host_ptr_from_global_bridge,
@@ -29,7 +30,6 @@ const EVENT_SOURCE_RECONNECT_TIMER_SLOT: &str = "__lmEventSourceReconnectTimer";
const EVENT_SOURCE_RECONNECT_DELAY_SLOT: &str = "__lmEventSourceReconnectDelay";
const EVENT_SOURCE_LAST_EVENT_ID_SLOT: &str = "__lmEventSourceLastEventId";
const EVENT_SOURCE_RESPONSE_URL_SLOT: &str = "__lmEventSourceResponseUrl";
-const EVENT_SOURCE_LISTENERS_SLOT: &str = "__lmEventSourceListeners";
const EVENT_SOURCE_ONOPEN_SLOT: &str = "__lmEventSourceOnOpen";
const EVENT_SOURCE_ONMESSAGE_SLOT: &str = "__lmEventSourceOnMessage";
const EVENT_SOURCE_ONERROR_SLOT: &str = "__lmEventSourceOnError";
diff --git a/moli-renderer-v8/src/network_host/event_source/bindings.rs b/moli-renderer-v8/src/network_host/event_source/bindings.rs
index a4732795f..5f479b486 100644
--- a/moli-renderer-v8/src/network_host/event_source/bindings.rs
+++ b/moli-renderer-v8/src/network_host/event_source/bindings.rs
@@ -39,8 +39,8 @@ struct EventSourceObjectDeclaration<'scope> {
#[webapi(slot = EVENT_SOURCE_ONERROR_SLOT, init = "null")]
onerror: (),
- #[webapi(slot = SIMPLE_EVENT_TARGET_SLOT, value = EVENT_SOURCE_LISTENERS_SLOT)]
- event_target_slot: (),
+ #[webapi(slot = SIMPLE_EVENT_TARGET_LISTENERS_SLOT, init = "null_object")]
+ event_listeners: (),
}
#[derive(WebApiFunctionTemplate)]
@@ -342,13 +342,7 @@ pub(crate) fn dispatch_event_source_message<'s>(
return;
};
mark_event_trusted(scope, event);
- let _ = dispatch_simple_event_target_event(
- scope,
- event_source,
- EVENT_SOURCE_LISTENERS_SLOT,
- &message.event_name,
- event,
- );
+ let _ = dispatch_simple_event_target_event(scope, event_source, &message.event_name, event);
}
pub(crate) fn schedule_event_source_connect<'s>(
@@ -541,7 +535,6 @@ fn event_source_event_handler_setter<'s>(
simple_object_event_set_handler(
scope,
args.this(),
- EVENT_SOURCE_LISTENERS_SLOT,
handler.event_type,
handler.slot_name,
args.get(0),
@@ -567,13 +560,7 @@ fn dispatch_event_source_named_event<'s>(
return;
};
mark_event_trusted(scope, event);
- let _ = dispatch_simple_event_target_event(
- scope,
- event_source,
- EVENT_SOURCE_LISTENERS_SLOT,
- event_type,
- event,
- );
+ let _ = dispatch_simple_event_target_event(scope, event_source, event_type, event);
}
fn event_source_is_branded<'s>(
diff --git a/moli-renderer-v8/src/network_host/xhr.rs b/moli-renderer-v8/src/network_host/xhr.rs
index 754f64b83..c8ab51314 100644
--- a/moli-renderer-v8/src/network_host/xhr.rs
+++ b/moli-renderer-v8/src/network_host/xhr.rs
@@ -7,9 +7,8 @@ mod response_type;
mod send;
use super::*;
-use crate::context_bootstrap::SIMPLE_EVENT_TARGET_SLOT;
use crate::native_bridge::throw_dom_exception;
-use crate::util::{get_private_value, private_key};
+use crate::util::get_private_value;
use crate::web_api_interfaces;
use crate::worker::WORKER_STATE_SLOT;
use moli_webapi_declare::WebApiFunctionTemplate;
@@ -43,7 +42,6 @@ const XHR_PENDING_BODY_BYTES_SLOT: &str = "__lmXhrPendingBodyBytes";
const XHR_PENDING_BODY_LENGTH_SLOT: &str = "__lmXhrPendingBodyLength";
const XHR_PENDING_HEADERS_SLOT: &str = "__lmXhrPendingHeadersJson";
pub(crate) const XHR_ACTIVE_INTERNAL_ID_SLOT: &str = "__lmXhrActiveInternalId";
-pub(crate) const XHR_SIMPLE_EVENT_TARGET_LISTENERS_SLOT: &str = "__moliXhrEventTargetListeners";
pub(crate) use self::bindings::{
install_window_xml_http_request_template_bindings, install_xml_http_request_bindings,
@@ -94,23 +92,6 @@ pub(crate) fn install_progress_event_template_bindings<'s>(
}
}
-pub(crate) fn finalize_xml_http_request_event_target_realm_bindings<'s>(
- scope: &mut v8::PinScope<'s, '_>,
- event_target_prototype: v8::Local<'s, v8::Object>,
-) -> anyhow::Result<()> {
- let slot = SIMPLE_EVENT_TARGET_SLOT;
- let key = private_key(scope, slot).ok_or_else(|| {
- anyhow::anyhow!("failed to allocate XMLHttpRequestEventTarget slot `{slot}`")
- })?;
- let value = v8str(scope, XHR_SIMPLE_EVENT_TARGET_LISTENERS_SLOT).into();
- if event_target_prototype.set_private(scope, key, value) != Some(true) {
- return Err(anyhow::anyhow!(
- "failed to finalize XMLHttpRequestEventTarget slot `{slot}`"
- ));
- }
- Ok(())
-}
-
pub(crate) fn xhr_throw_invalid_state(scope: &mut v8::PinScope<'_, '_>, message: &'static str) {
throw_dom_exception(scope, "InvalidStateError", 11, message);
}
diff --git a/moli-renderer-v8/src/network_host/xhr/bindings/constants.rs b/moli-renderer-v8/src/network_host/xhr/bindings/constants.rs
index 96de07f17..398a98af5 100644
--- a/moli-renderer-v8/src/network_host/xhr/bindings/constants.rs
+++ b/moli-renderer-v8/src/network_host/xhr/bindings/constants.rs
@@ -444,14 +444,7 @@ fn xhr_value_setter<'s>(
};
set_xhr_state_value(scope, xhr, key, stored);
if let Some(event_type) = xhr_event_type_for_handler_slot(key) {
- simple_object_event_set_handler(
- scope,
- xhr,
- XHR_SIMPLE_EVENT_TARGET_LISTENERS_SLOT,
- event_type,
- key,
- stored,
- );
+ simple_object_event_set_handler(scope, xhr, event_type, key, stored);
} else {
set_private_value(scope, xhr, key, stored);
}
diff --git a/moli-renderer-v8/src/network_host/xhr/events/dispatch.rs b/moli-renderer-v8/src/network_host/xhr/events/dispatch.rs
index 5b4f4a578..5c9a8beec 100644
--- a/moli-renderer-v8/src/network_host/xhr/events/dispatch.rs
+++ b/moli-renderer-v8/src/network_host/xhr/events/dispatch.rs
@@ -29,13 +29,7 @@ pub(in crate::network_host::xhr) fn xhr_fire_readystatechange(
let event = XhrReadyStateChangeEventDeclaration::new("readystatechange", xhr, xhr)
.bind(scope)
.expect("XHR readystatechange event declaration should bind");
- let _ = dispatch_simple_event_target_event(
- scope,
- xhr,
- XHR_SIMPLE_EVENT_TARGET_LISTENERS_SLOT,
- "readystatechange",
- event,
- );
+ let _ = dispatch_simple_event_target_event(scope, xhr, "readystatechange", event);
}
fn xhr_dispatch_event(
@@ -46,13 +40,7 @@ fn xhr_dispatch_event(
) {
let xhr = local_object_in_scope(scope, xhr);
let event = local_object_in_scope(scope, event);
- let _ = dispatch_simple_event_target_event(
- scope,
- xhr,
- XHR_SIMPLE_EVENT_TARGET_LISTENERS_SLOT,
- event_type,
- event,
- );
+ let _ = dispatch_simple_event_target_event(scope, xhr, event_type, event);
}
pub(crate) fn xhr_dispatch_progress_event(
@@ -138,11 +126,5 @@ fn xhr_has_event_observers<'s>(
xhr: v8::Local<'s, v8::Object>,
event_type: &str,
) -> bool {
- !simple_object_event_listeners_snapshot(
- scope,
- xhr,
- XHR_SIMPLE_EVENT_TARGET_LISTENERS_SLOT,
- event_type,
- )
- .is_empty()
+ !simple_object_event_listeners_snapshot(scope, xhr, event_type).is_empty()
}
diff --git a/moli-renderer-v8/src/network_host/xhr/instance_state.rs b/moli-renderer-v8/src/network_host/xhr/instance_state.rs
index c298e4866..c0070f0fe 100644
--- a/moli-renderer-v8/src/network_host/xhr/instance_state.rs
+++ b/moli-renderer-v8/src/network_host/xhr/instance_state.rs
@@ -150,6 +150,7 @@ pub(crate) fn initialize_xml_http_request_instance(
execution_context: Option<&crate::native_bridge::WindowExecutionContextBinding>,
) {
let xhr = local_object_in_scope(scope, xhr);
+ crate::context_bootstrap::initialize_simple_event_target(scope, xhr);
let state = XmlHttpRequestStateDeclaration::default()
.bind(scope)
.expect("XMLHttpRequest state declaration should bind");
@@ -161,6 +162,7 @@ pub(crate) fn initialize_xml_http_request_instance(
))
.bind(scope)
.expect("XMLHttpRequestUpload declaration should bind");
+ crate::context_bootstrap::initialize_simple_event_target(scope, upload);
let _ = xhr.set_internal_field(XHR_UPLOAD_FIELD_INDEX, upload.into());
if let Some(execution_context) = execution_context {
@@ -396,11 +398,7 @@ pub(crate) fn xhr_has_upload_listeners(
xhr: v8::Local<'_, v8::Object>,
) -> bool {
xhr_upload_object(scope, xhr).is_some_and(|upload| {
- crate::context_bootstrap::simple_object_has_event_listeners(
- scope,
- upload,
- super::XHR_SIMPLE_EVENT_TARGET_LISTENERS_SLOT,
- )
+ crate::context_bootstrap::simple_object_has_event_listeners(scope, upload)
})
}
diff --git a/moli-renderer-v8/src/network_host/xhr/send.rs b/moli-renderer-v8/src/network_host/xhr/send.rs
index 969abdc65..eae431149 100644
--- a/moli-renderer-v8/src/network_host/xhr/send.rs
+++ b/moli-renderer-v8/src/network_host/xhr/send.rs
@@ -259,11 +259,7 @@ pub(crate) fn dispatch_xhr_loadstart(
xhr_state_number_property(scope, xhr, XHR_OPEN_GENERATION_SLOT).unwrap_or(0.0);
// The XHR loadstart listener can abort before upload.loadstart runs.
let has_upload_listeners = xhr_upload_object(scope, xhr).is_some_and(|upload| {
- crate::context_bootstrap::simple_object_has_event_listeners(
- scope,
- upload,
- XHR_SIMPLE_EVENT_TARGET_LISTENERS_SLOT,
- )
+ crate::context_bootstrap::simple_object_has_event_listeners(scope, upload)
});
set_xhr_state_bool(scope, xhr, XHR_UPLOAD_LISTENER_SLOT, has_upload_listeners);
set_xhr_state_bool(scope, xhr, XHR_UPLOAD_IN_PROGRESS_SLOT, send_body.is_some());
diff --git a/moli-renderer-v8/src/script_vm/tests/browser_api/simple_event_target_handlers.js b/moli-renderer-v8/src/script_vm/tests/browser_api/simple_event_target_handlers.js
index 79d16a0b1..eb9792fab 100644
--- a/moli-renderer-v8/src/script_vm/tests/browser_api/simple_event_target_handlers.js
+++ b/moli-renderer-v8/src/script_vm/tests/browser_api/simple_event_target_handlers.js
@@ -71,3 +71,32 @@ function checkUnregisteredHandler(target, realm = globalThis) {
target.dispatchEvent(new realm.Event('unregistered'));
delete target.onunregistered;
}
+
+function checkListenerIsolation(targets, realm = globalThis) {
+ const type = 'registry-isolation';
+ const trace = [];
+ function listener() { trace.push(targets.indexOf(this)); }
+ for (const target of targets) {
+ // Ordinary properties cannot select or replace private listener storage.
+ target.__moliEventTargetSlot = 'page-owned-slot';
+ target.__moliEventTargetListeners = {};
+ target.addEventListener(type, listener);
+ }
+ for (let index = 0; index < targets.length; index++) {
+ targets[index].dispatchEvent(new realm.Event(type));
+ if (JSON.stringify(trace.splice(0)) !== JSON.stringify([index])) {
+ throw new Error('listener registry leaked across targets at ' + index);
+ }
+ }
+ targets[0].removeEventListener(type, listener);
+ for (let index = 0; index < targets.length; index++) {
+ targets[index].dispatchEvent(new realm.Event(type));
+ const expected = index === 0 ? [] : [index];
+ if (JSON.stringify(trace.splice(0)) !== JSON.stringify(expected)) {
+ throw new Error('removing a listener changed another target at ' + index);
+ }
+ targets[index].removeEventListener(type, listener);
+ delete targets[index].__moliEventTargetSlot;
+ delete targets[index].__moliEventTargetListeners;
+ }
+}
diff --git a/moli-renderer-v8/src/script_vm/tests/browser_api/simple_event_target_handlers.rs b/moli-renderer-v8/src/script_vm/tests/browser_api/simple_event_target_handlers.rs
index 0b925fad6..ac3f3ee29 100644
--- a/moli-renderer-v8/src/script_vm/tests/browser_api/simple_event_target_handlers.rs
+++ b/moli-renderer-v8/src/script_vm/tests/browser_api/simple_event_target_handlers.rs
@@ -2,6 +2,39 @@ use super::*;
const PROBE: &str = include_str!("simple_event_target_handlers.js");
+#[test]
+fn simple_event_target_listener_storage_is_private_and_separate_for_each_instance() {
+ let mut vm = new_parsed_test_vm(
+ "https://simple-event-target-storage.test/",
+ "<body><iframe id=child></iframe></body>",
+ );
+ vm.exec(PROBE, None).unwrap();
+ assert_eq!(
+ vm.eval(
+ r#"(() => {
+ for (const w of [window, document.getElementById('child').contentWindow]) {
+ const first = new w.XMLHttpRequest(), second = new w.XMLHttpRequest();
+ const channel = new w.MessageChannel();
+ const targets = [
+ new w.EventTarget(), new w.EventTarget(),
+ new w.FileReader(), new w.FileReader(),
+ first, second, first.upload, second.upload,
+ new w.AbortController().signal, new w.AbortController().signal,
+ channel.port1, channel.port2,
+ new w.VTTCue(0, 1, ''), new w.VTTCue(0, 1, ''),
+ w.performance, w.screen.orientation, w.visualViewport,
+ ];
+ try { checkListenerIsolation(targets, w); }
+ finally { channel.port1.close(); channel.port2.close(); }
+ }
+ return true;
+ })()"#
+ )
+ .unwrap(),
+ "true"
+ );
+}
+
#[test]
fn indexed_db_handlers_share_synthetic_and_native_listener_order() {
let mut vm = new_storage_page_task_executor_test_vm("https://idb-handler-order.test/");
@@ -22,6 +55,7 @@ fn indexed_db_handlers_share_synthetic_and_native_listener_order() {
const db = open.result;
const tx = db.transaction('values');
const request = tx.objectStore('values').get('missing');
+ checkListenerIsolation([db, tx, request, open]);
for (const [target, types] of [
[db, ['abort', 'close', 'error', 'versionchange']],
[tx, ['abort', 'complete', 'error']],
@@ -92,6 +126,7 @@ fn simple_window_handlers_share_dispatch_and_mutation_semantics() {
checkHandlerDispatch(target, 'message');
checkUnregisteredHandler(target);
}
+ checkListenerIsolation([popup, frame.contentWindow]);
return true;
} finally { popup.close(); }
})()"#,
diff --git a/moli-renderer-v8/src/window_host.rs b/moli-renderer-v8/src/window_host.rs
index c8f64ac5a..9a5d4b64e 100644
--- a/moli-renderer-v8/src/window_host.rs
+++ b/moli-renderer-v8/src/window_host.rs
@@ -8,12 +8,12 @@ use super::{
context_bootstrap::event_is_dispatching,
context_bootstrap::event_is_mouse_event,
context_bootstrap::increment_performance_event_count,
+ context_bootstrap::is_simple_event_target,
context_bootstrap::mark_event_trusted,
context_bootstrap::performance_slot_number,
context_bootstrap::simple_event_target_add_event_listener_callback,
context_bootstrap::simple_event_target_dispatch_event_callback,
context_bootstrap::simple_event_target_remove_event_listener_callback,
- context_bootstrap::simple_event_target_slot_name,
context_bootstrap::trusted_script_string_or_type_error,
document_runtime::{DocumentContentSecurityPolicyViolation, DomHandle, EventTargetHandle},
native_bridge::{
@@ -145,7 +145,7 @@ pub(super) fn event_target_add_event_listener_callback<'s>(
args: v8::FunctionCallbackArguments<'s>,
rv: v8::ReturnValue<'s, v8::Value>,
) {
- if simple_event_target_slot_name(scope, args.this()).is_some() {
+ if is_simple_event_target(scope, args.this()) {
simple_event_target_add_event_listener_callback(scope, args, rv);
return;
}
@@ -267,7 +267,7 @@ pub(super) fn event_target_remove_event_listener_callback<'s>(
args: v8::FunctionCallbackArguments<'s>,
rv: v8::ReturnValue<'s, v8::Value>,
) {
- if simple_event_target_slot_name(scope, args.this()).is_some() {
+ if is_simple_event_target(scope, args.this()) {
simple_event_target_remove_event_listener_callback(scope, args, rv);
return;
}
@@ -307,7 +307,7 @@ pub(super) fn event_target_dispatch_event_callback<'s>(
args: v8::FunctionCallbackArguments<'s>,
mut rv: v8::ReturnValue<'s, v8::Value>,
) {
- if simple_event_target_slot_name(scope, args.this()).is_some() {
+ if is_simple_event_target(scope, args.this()) {
simple_event_target_dispatch_event_callback(scope, args, rv);
return;
}
diff --git a/moli-renderer-v8/src/worker/global_scope/bootstrap.rs b/moli-renderer-v8/src/worker/global_scope/bootstrap.rs
index 27a4f68c5..c59fb9756 100644
--- a/moli-renderer-v8/src/worker/global_scope/bootstrap.rs
+++ b/moli-renderer-v8/src/worker/global_scope/bootstrap.rs
@@ -204,7 +204,7 @@ pub(in crate::worker) fn install_worker_global_scope<'s>(
)?;
crate::context_bootstrap::install_worker_indexed_db_runtime_state(scope, global)?;
crate::context_bootstrap::install_worker_base64_runtime_state(scope, global)?;
- install_simple_event_target_methods(scope, global, WORKER_GLOBAL_LISTENERS_SLOT);
+ install_simple_event_target_methods(scope, global);
let script_url = state.borrow().current_script_url.clone();
let origin = script_url
diff --git a/moli-renderer-v8/src/worker/global_scope/content_security_policy.rs b/moli-renderer-v8/src/worker/global_scope/content_security_policy.rs
index b16f88929..80f2622f6 100644
--- a/moli-renderer-v8/src/worker/global_scope/content_security_policy.rs
+++ b/moli-renderer-v8/src/worker/global_scope/content_security_policy.rs
@@ -32,8 +32,8 @@ use moli_fetch::{
};
use super::{
- PendingWorkerCspReport, WORKER_GLOBAL_LISTENERS_SLOT, WorkerGlobalState, get_worker_state,
- next_fetch_id, record_worker_subresource_failure_with_handle, request_body_text,
+ PendingWorkerCspReport, WorkerGlobalState, get_worker_state, next_fetch_id,
+ record_worker_subresource_failure_with_handle, request_body_text,
};
pub(super) fn dispatch_worker_content_security_policy_violation_event<'s>(
@@ -54,13 +54,7 @@ pub(super) fn dispatch_worker_content_security_policy_violation_event<'s>(
&violation.report_uri_endpoints,
&violation.report_to_endpoints,
);
- dispatch_simple_event_target_event(
- scope,
- global,
- WORKER_GLOBAL_LISTENERS_SLOT,
- "securitypolicyviolation",
- event,
- );
+ dispatch_simple_event_target_event(scope, global, "securitypolicyviolation", event);
}
pub(super) fn dispatch_worker_content_security_policy_violation_event_for_state<'s>(
@@ -74,13 +68,7 @@ pub(super) fn dispatch_worker_content_security_policy_violation_event_for_state<
return;
};
send_worker_content_security_policy_reports_for_state(state, violation);
- dispatch_simple_event_target_event(
- scope,
- global,
- WORKER_GLOBAL_LISTENERS_SLOT,
- "securitypolicyviolation",
- event,
- );
+ dispatch_simple_event_target_event(scope, global, "securitypolicyviolation", event);
}
pub(super) fn dispatch_worker_trusted_types_sink_violation_event_for_state<'s>(
diff --git a/moli-renderer-v8/src/worker/global_scope/event_handlers.rs b/moli-renderer-v8/src/worker/global_scope/event_handlers.rs
index 23c87d58f..d43752cf2 100644
--- a/moli-renderer-v8/src/worker/global_scope/event_handlers.rs
+++ b/moli-renderer-v8/src/worker/global_scope/event_handlers.rs
@@ -2,8 +2,6 @@
use super::*;
-pub(in crate::worker) const WORKER_GLOBAL_LISTENERS_SLOT: &str = "__moliWorkerGlobalListeners";
-
const WORKER_GLOBAL_ONMESSAGE_SLOT: &str = "__moliWorkerGlobalOnMessage";
const WORKER_GLOBAL_ONMESSAGEERROR_SLOT: &str = "__moliWorkerGlobalOnMessageError";
@@ -266,14 +264,7 @@ fn set_worker_global_event_handler<'s>(
slot_name: &'static str,
event_type: &str,
) {
- simple_object_event_set_handler(
- scope,
- global,
- WORKER_GLOBAL_LISTENERS_SLOT,
- event_type,
- slot_name,
- value,
- );
+ simple_object_event_set_handler(scope, global, event_type, slot_name, value);
}
fn worker_global_onmessage_getter<'s>(
@@ -696,12 +687,7 @@ pub(in crate::worker) fn service_worker_fetch_handler_type<'s>(
scope: &mut v8::PinScope<'s, '_>,
global: v8::Local<'s, v8::Object>,
) -> WorkerFetchHandlerType {
- let listeners = simple_object_event_listeners_snapshot(
- scope,
- global,
- WORKER_GLOBAL_LISTENERS_SLOT,
- "fetch",
- );
+ let listeners = simple_object_event_listeners_snapshot(scope, global, "fetch");
if listeners.is_empty() {
return WorkerFetchHandlerType::NoHandler;
}
diff --git a/moli-renderer-v8/src/worker/global_scope/mod.rs b/moli-renderer-v8/src/worker/global_scope/mod.rs
index f8b358183..bbd20d35a 100644
--- a/moli-renderer-v8/src/worker/global_scope/mod.rs
+++ b/moli-renderer-v8/src/worker/global_scope/mod.rs
@@ -178,7 +178,7 @@ pub(crate) use content_security_policy::{
worker_trusted_types_for_script_requirements,
};
use event_handlers::install_worker_global_event_handler_accessors;
-pub(super) use event_handlers::{WORKER_GLOBAL_LISTENERS_SLOT, service_worker_fetch_handler_type};
+pub(super) use event_handlers::service_worker_fetch_handler_type;
use extendable_events::install_service_worker_extendable_event_constructors;
pub(super) use extendable_events::{
PendingServiceWorkerFetchEvent, PendingServiceWorkerLifecycleEvent,
diff --git a/moli-renderer-v8/src/worker/global_scope/service_worker_api.rs b/moli-renderer-v8/src/worker/global_scope/service_worker_api.rs
index 12ac794db..fb9874d93 100644
--- a/moli-renderer-v8/src/worker/global_scope/service_worker_api.rs
+++ b/moli-renderer-v8/src/worker/global_scope/service_worker_api.rs
@@ -195,7 +195,7 @@ pub(in crate::worker) fn build_service_worker_global_service_worker<'s>(
SERVICE_WORKER_VERSION_ID_SLOT,
version_id_value.into(),
);
- install_simple_event_target_methods(scope, worker, SERVICE_WORKER_WORKER_EVENTS_SLOT);
+ install_simple_event_target_methods(scope, worker);
Ok(worker)
}
@@ -1839,8 +1839,6 @@ const SERVICE_WORKER_REGISTRATION_ID_SLOT: &str = "__moliServiceWorkerRegistrati
pub(super) const SERVICE_WORKER_VERSION_ID_SLOT: &str = "__moliServiceWorkerVersionId";
-const SERVICE_WORKER_WORKER_EVENTS_SLOT: &str = "__moliServiceWorkerWorkerEvents";
-
const SERVICE_WORKER_NAVIGATION_PRELOAD_MANAGER_SCOPE_SLOT: &str =
"__moliServiceWorkerNavigationPreloadManagerScope";
diff --git a/moli-renderer-v8/src/worker/thread/dispatch.rs b/moli-renderer-v8/src/worker/thread/dispatch.rs
index d8730f40e..cfcc6c018 100644
--- a/moli-renderer-v8/src/worker/thread/dispatch.rs
+++ b/moli-renderer-v8/src/worker/thread/dispatch.rs
@@ -62,8 +62,8 @@ use super::super::global_scope::{
PendingServiceWorkerMessageEvent, PendingServiceWorkerNavigationPreload,
PendingServiceWorkerNotificationEvent, PendingServiceWorkerPeriodicSyncEvent,
PendingServiceWorkerPushEvent, PendingServiceWorkerSyncEvent, WORKER_EXCEPTION_COLUMN_SLOT,
- WORKER_EXCEPTION_LINE_SLOT, WORKER_EXCEPTION_SOURCE_SLOT, WORKER_GLOBAL_LISTENERS_SLOT,
- get_worker_state, register_shared_worker_connection_port, worker_exception_report_target,
+ WORKER_EXCEPTION_LINE_SLOT, WORKER_EXCEPTION_SOURCE_SLOT, get_worker_state,
+ register_shared_worker_connection_port, worker_exception_report_target,
};
use super::super::handle::{
WorkerErrorPhase, WorkerErrorSource, WorkerMessage, WorkerParentErrorEventKind,
@@ -760,12 +760,7 @@ fn dispatch_worker_promise_rejection_event<'s>(
let event = new_worker_promise_rejection_event(scope, event_type, promise, reason);
set_event_dispatch_fields(scope, global, event);
- let listeners = simple_object_event_listeners_snapshot(
- scope,
- global,
- WORKER_GLOBAL_LISTENERS_SLOT,
- event_type,
- );
+ let listeners = simple_object_event_listeners_snapshot(scope, global, event_type);
for listener in &listeners {
if let Err(error) = invoke_worker_listener(
scope,
@@ -907,9 +902,7 @@ fn invoke_worker_listener<'s>(
if event_stop_immediate_propagation(scope, event) {
return Ok(());
}
- let Some(listener) =
- listener.prepare_for_invocation(scope, target, WORKER_GLOBAL_LISTENERS_SLOT, event_type)
- else {
+ let Some(listener) = listener.prepare_for_invocation(scope, target, event_type) else {
return Ok(());
};
let arguments = [event.into()];
@@ -961,13 +954,7 @@ pub(super) fn dispatch_worker_error_event<'s>(
};
let event = new_worker_error_event(scope, report, script_url, exception);
mark_event_trusted(scope, event);
- !crate::context_bootstrap::dispatch_simple_event_target_event(
- scope,
- global,
- WORKER_GLOBAL_LISTENERS_SLOT,
- "error",
- event,
- )
+ !crate::context_bootstrap::dispatch_simple_event_target_event(scope, global, "error", event)
}
pub(super) fn dispatch_service_worker_lifecycle_event(
@@ -1174,12 +1161,7 @@ fn dispatch_service_worker_lifecycle_event_in_context<'s>(
}
let event_type = event.kind.as_str();
- let listeners = simple_object_event_listeners_snapshot(
- scope,
- global,
- WORKER_GLOBAL_LISTENERS_SLOT,
- event_type,
- );
+ let listeners = simple_object_event_listeners_snapshot(scope, global, event_type);
for listener in &listeners {
if let Err(error) = invoke_worker_listener(
scope,
@@ -1291,12 +1273,7 @@ fn dispatch_service_worker_fetch_event_in_context<'s>(
.insert(event.event_id, pending);
}
- let listeners = simple_object_event_listeners_snapshot(
- scope,
- global,
- WORKER_GLOBAL_LISTENERS_SLOT,
- "fetch",
- );
+ let listeners = simple_object_event_listeners_snapshot(scope, global, "fetch");
for listener in &listeners {
if let Err(error) = invoke_worker_listener(
scope,
@@ -1373,12 +1350,7 @@ fn dispatch_service_worker_message_event_in_context<'s>(
}
}
- let listeners = simple_object_event_listeners_snapshot(
- scope,
- global,
- WORKER_GLOBAL_LISTENERS_SLOT,
- event_type,
- );
+ let listeners = simple_object_event_listeners_snapshot(scope, global, event_type);
for listener in &listeners {
if let Err(error) = invoke_worker_listener(
scope,
@@ -1451,12 +1423,7 @@ fn dispatch_service_worker_notification_event_in_context<'s>(
}
let event_type = event.kind.as_str();
- let listeners = simple_object_event_listeners_snapshot(
- scope,
- global,
- WORKER_GLOBAL_LISTENERS_SLOT,
- event_type,
- );
+ let listeners = simple_object_event_listeners_snapshot(scope, global, event_type);
for listener in &listeners {
if let Err(error) = invoke_worker_listener(
scope,
@@ -1521,8 +1488,7 @@ fn dispatch_service_worker_push_event_in_context<'s>(
);
}
- let listeners =
- simple_object_event_listeners_snapshot(scope, global, WORKER_GLOBAL_LISTENERS_SLOT, "push");
+ let listeners = simple_object_event_listeners_snapshot(scope, global, "push");
for listener in &listeners {
if let Err(error) = invoke_worker_listener(
scope,
@@ -1591,8 +1557,7 @@ fn dispatch_service_worker_sync_event_in_context<'s>(
);
}
- let listeners =
- simple_object_event_listeners_snapshot(scope, global, WORKER_GLOBAL_LISTENERS_SLOT, "sync");
+ let listeners = simple_object_event_listeners_snapshot(scope, global, "sync");
for listener in &listeners {
if let Err(error) = invoke_worker_listener(
scope,
@@ -1661,12 +1626,7 @@ fn dispatch_service_worker_periodic_sync_event_in_context<'s>(
);
}
- let listeners = simple_object_event_listeners_snapshot(
- scope,
- global,
- WORKER_GLOBAL_LISTENERS_SLOT,
- "periodicsync",
- );
+ let listeners = simple_object_event_listeners_snapshot(scope, global, "periodicsync");
for listener in &listeners {
if let Err(error) = invoke_worker_listener(
scope,
@@ -4198,12 +4158,7 @@ fn dispatch_worker_global_message_event<'s>(
let event = new_worker_message_event(scope, event_type, data, None, ports);
set_event_dispatch_fields(scope, global, event);
- let listeners = simple_object_event_listeners_snapshot(
- scope,
- global,
- WORKER_GLOBAL_LISTENERS_SLOT,
- event_type,
- );
+ let listeners = simple_object_event_listeners_snapshot(scope, global, event_type);
for listener in &listeners {
if let Err(error) = invoke_worker_listener(
scope,
@@ -4306,12 +4261,7 @@ pub(super) fn dispatch_shared_worker_connect_event(
let event = new_worker_message_event(scope, "connect", data, source, ports);
set_event_dispatch_fields(scope, global, event);
- let listeners = simple_object_event_listeners_snapshot(
- scope,
- global,
- WORKER_GLOBAL_LISTENERS_SLOT,
- "connect",
- );
+ let listeners = simple_object_event_listeners_snapshot(scope, global, "connect");
for listener in &listeners {
if let Err(error) = invoke_worker_listener(
scope,
diff --git a/moli-renderer-v8/src/worker/thread/tests/performance_handler_order.rs b/moli-renderer-v8/src/worker/thread/tests/performance_handler_order.rs
index 0eb93843e..6e6245254 100644
--- a/moli-renderer-v8/src/worker/thread/tests/performance_handler_order.rs
+++ b/moli-renderer-v8/src/worker/thread/tests/performance_handler_order.rs
@@ -20,6 +20,16 @@ async fn worker_simple_event_handlers_share_dispatch_and_mutation_semantics() {
checkUnregisteredHandler(target);
}}
checkUnregisteredHandler(new EventTarget());
+ const first = new XMLHttpRequest(), second = new XMLHttpRequest();
+ const channel = new MessageChannel();
+ try {{
+ checkListenerIsolation([
+ self, performance, new EventTarget(), new EventTarget(),
+ new FileReader(), new FileReader(), first, second, first.upload, second.upload,
+ new AbortController().signal, new AbortController().signal,
+ channel.port1, channel.port2,
+ ]);
+ }} finally {{ channel.port1.close(); channel.port2.close(); }}
postMessage(true);
close();"#
);