Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust
Rust ai-agentsai-toolsbrowserbrowser-automationcloud-browserheadlessheadless-browserkitesurfplaywrightpuppeteerrustservoweb-crawlerweb-crawlingweb-scraperweb-scraping
feat(webidl): derive dictionary member order and inheritance
ldm0a423ba43b1fc
diff --git a/moli-renderer-v8/src/context_bootstrap/events.rs b/moli-renderer-v8/src/context_bootstrap/events.rsindex 41205f7ca..c238c7488 100644--- a/moli-renderer-v8/src/context_bootstrap/events.rs+++ b/moli-renderer-v8/src/context_bootstrap/events.rs@@ -369,7 +369,7 @@ pub(super) use base::{event_target_getter_function, event_type_getter_function, set_event_dispatch_fields,set_event_initialized,};-pub(in crate::context_bootstrap) use init::parse_event_init;+pub(in crate::context_bootstrap) use init::{EventInit, parse_event_init};pub(super) use kind::EventSubclassKind;pub(super) use methods::{event_cancel_bubble_getter_function, event_cancel_bubble_setter_function,diff --git a/moli-renderer-v8/src/context_bootstrap/events/audio.rs b/moli-renderer-v8/src/context_bootstrap/events/audio.rsindex 2644fa7e5..e409243e9 100644--- a/moli-renderer-v8/src/context_bootstrap/events/audio.rs+++ b/moli-renderer-v8/src/context_bootstrap/events/audio.rs@@ -4,6 +4,7 @@ use super::{define_event_property, event_private_value, initialize_event_object_with_type,initialize_event_wrapper, new_event_state, set_event_private_value,};+use crate::context_bootstrap::events::EventInit;use crate::{util::{new_null_prototype_object, throw_type_error, v8str},web_api_interfaces, webidl,@@ -52,12 +53,8 @@ struct OfflineAudioCompletionEventPrototypeDeclaration {#[derive(webidl::WebIdlDictionary)]#[webidl(prefix = "AudioProcessingEventInit")]struct AudioProcessingEventInit<'s> {- #[webidl(default = false)]- bubbles: bool,- #[webidl(default = false)]- cancelable: bool,- #[webidl(default = false)]- composed: bool,+ #[webidl(inherit)]+ base: EventInit,#[webidl(required, interface = web_api_interfaces::AudioBuffer)]input_buffer: v8::Local<'s, v8::Object>,#[webidl(required, interface = web_api_interfaces::AudioBuffer)]@@ -69,12 +66,8 @@ struct AudioProcessingEventInit<'s> {#[derive(webidl::WebIdlDictionary)]#[webidl(prefix = "OfflineAudioCompletionEventInit")]struct OfflineAudioCompletionEventInit<'s> {- #[webidl(default = false)]- bubbles: bool,- #[webidl(default = false)]- cancelable: bool,- #[webidl(default = false)]- composed: bool,+ #[webidl(inherit)]+ base: EventInit,#[webidl(required, interface = web_api_interfaces::AudioBuffer)]rendered_buffer: v8::Local<'s, v8::Object>,}@@ -164,7 +157,11 @@ fn audio_event_constructor<'s>(PLAYBACK_TIME_SLOT,v8::Number::new(scope, parsed.playback_time).into(),);- (parsed.bubbles, parsed.cancelable, parsed.composed)+ (+ parsed.base.bubbles,+ parsed.base.cancelable,+ parsed.base.composed,+ )}AudioEventKind::Completion => {let parsed = webidl::parse_dictionary_object::<OfflineAudioCompletionEventInit>(@@ -176,7 +173,11 @@ fn audio_event_constructor<'s>(RENDERED_BUFFER_SLOT,parsed.rendered_buffer.into(),);- (parsed.bubbles, parsed.cancelable, parsed.composed)+ (+ parsed.base.bubbles,+ parsed.base.cancelable,+ parsed.base.composed,+ )}};initialize_event_object_with_type(scope, state, event_type, bubbles, cancelable);diff --git a/moli-renderer-v8/src/context_bootstrap/events/device.rs b/moli-renderer-v8/src/context_bootstrap/events/device.rsindex bd379049c..b868cb6c2 100644--- a/moli-renderer-v8/src/context_bootstrap/events/device.rs+++ b/moli-renderer-v8/src/context_bootstrap/events/device.rs@@ -5,6 +5,7 @@ use super::{define_event_property, event_private_value, initialize_event_object_with_type,initialize_event_wrapper, new_event_state, set_event_private_value,};+use crate::context_bootstrap::events::EventInit;use crate::{util::{get_private_value, new_null_prototype_object, throw_type_error, v8str},web_api_interfaces, webidl,@@ -102,12 +103,8 @@ struct RotationRatePrototype {#[derive(webidl::WebIdlDictionary)]#[webidl(prefix = "DeviceOrientationEventInit")]struct OrientationInit {- #[webidl(default = false)]- bubbles: bool,- #[webidl(default = false)]- cancelable: bool,- #[webidl(default = false)]- composed: bool,+ #[webidl(inherit)]+ base: EventInit,#[webidl(default = false)]absolute: bool,#[webidl(nullable, converter = "double")]@@ -121,12 +118,8 @@ struct OrientationInit {#[derive(webidl::WebIdlDictionary)]#[webidl(prefix = "DeviceMotionEventInit")]struct MotionInit {- #[webidl(default = false)]- bubbles: bool,- #[webidl(default = false)]- cancelable: bool,- #[webidl(default = false)]- composed: bool,+ #[webidl(inherit)]+ base: EventInit,#[webidl(dictionary)]acceleration: Option<AccelerationInit>,#[webidl(name = "accelerationIncludingGravity", dictionary)]@@ -296,7 +289,11 @@ fn initialize_payload<'s>(ABSOLUTE,v8::Boolean::new(scope, parsed.absolute).into(),);- Ok((parsed.bubbles, parsed.cancelable, parsed.composed))+ Ok((+ parsed.base.bubbles,+ parsed.base.cancelable,+ parsed.base.composed,+ ))}DeviceEventKind::Motion => {let parsed = webidl::parse_dictionary_object::<MotionInit>(scope, dictionary)?;@@ -318,7 +315,11 @@ fn initialize_payload<'s>(INTERVAL,v8::Number::new(scope, parsed.interval).into(),);- Ok((parsed.bubbles, parsed.cancelable, parsed.composed))+ Ok((+ parsed.base.bubbles,+ parsed.base.cancelable,+ parsed.base.composed,+ ))}}}diff --git a/moli-renderer-v8/src/context_bootstrap/events/init.rs b/moli-renderer-v8/src/context_bootstrap/events/init.rsindex 0cc8271ce..31ee84aab 100644--- a/moli-renderer-v8/src/context_bootstrap/events/init.rs+++ b/moli-renderer-v8/src/context_bootstrap/events/init.rs@@ -3,15 +3,15 @@ use crate::{webidl,};-#[derive(webidl::WebIdlDictionary)]+#[derive(Default, webidl::WebIdlDictionary)]#[webidl(prefix = "EventInit")]-struct EventInitMembers {+pub(in crate::context_bootstrap) struct EventInit {#[webidl(default = false)]- bubbles: bool,+ pub(in crate::context_bootstrap) bubbles: bool,#[webidl(default = false)]- cancelable: bool,+ pub(in crate::context_bootstrap) cancelable: bool,#[webidl(default = false)]- composed: bool,+ pub(in crate::context_bootstrap) composed: bool,}pub(super) fn init_bool_property<'s>(@@ -104,6 +104,6 @@ pub(in crate::context_bootstrap) fn parse_event_init<'s>(let Some(init) = init else {return Ok((false, false, false));};- webidl::parse_dictionary_object::<EventInitMembers>(scope, init)+ webidl::parse_dictionary_object::<EventInit>(scope, init).map(|parsed| (parsed.bubbles, parsed.cancelable, parsed.composed))}diff --git a/moli-renderer-v8/src/context_bootstrap/events/message.rs b/moli-renderer-v8/src/context_bootstrap/events/message.rsindex ffcc2f6e7..c1ffbaa1e 100644--- a/moli-renderer-v8/src/context_bootstrap/events/message.rs+++ b/moli-renderer-v8/src/context_bootstrap/events/message.rs@@ -1,4 +1,5 @@use super::{event_backing, reinitialize_event_object};+use crate::context_bootstrap::events::EventInit;use crate::util::{v8_string, v8_string_from_utf16_units};use crate::{web_api_interfaces, webidl};use moli_webapi_declare::WebApiObject;@@ -25,12 +26,8 @@ impl MessageEventSource {#[derive(webidl::WebIdlDictionary)]#[webidl(prefix = "MessageEventInit")]pub(super) struct MessageEventInit<'s> {- #[webidl(default = false)]- bubbles: bool,- #[webidl(default = false)]- cancelable: bool,- #[webidl(default = false)]- composed: bool,+ #[webidl(inherit)]+ base: EventInit,#[webidl(converter = "raw")]data: Option<v8::Local<'s, v8::Value>>,#[webidl(name = "lastEventId", default = webidl::DomString16(Vec::new()), converter = "raw")]@@ -45,7 +42,7 @@ pub(super) struct MessageEventInit<'s> {impl MessageEventInit<'_> {pub(super) fn event_flags(&self) -> (bool, bool, bool) {- (self.bubbles, self.cancelable, self.composed)+ (self.base.bubbles, self.base.cancelable, self.base.composed)}}@@ -57,9 +54,7 @@ pub(super) fn parse_message_event_init<'s>(.and_then(|object| match object {Some(object) => webidl::parse_dictionary_object(scope, object),None => Ok(MessageEventInit {- bubbles: false,- cancelable: false,- composed: false,+ base: EventInit::default(),data: None,last_event_id: webidl::DomString16(Vec::new()),origin: String::new(),@@ -209,9 +204,11 @@ pub(in crate::context_bootstrap) fn message_event_init_callback<'s>(scope,event,MessageEventInit {- bubbles: parsed.bubbles,- cancelable: parsed.cancelable,- composed: false,+ base: EventInit {+ bubbles: parsed.bubbles,+ cancelable: parsed.cancelable,+ composed: false,+ },data: parsed.data,last_event_id: parsed.last_event_id,origin: parsed.origin,diff --git a/moli-renderer-v8/src/context_bootstrap/events/subclasses/data.rs b/moli-renderer-v8/src/context_bootstrap/events/subclasses/data.rsindex 782566a22..f0dcc8386 100644--- a/moli-renderer-v8/src/context_bootstrap/events/subclasses/data.rs+++ b/moli-renderer-v8/src/context_bootstrap/events/subclasses/data.rs@@ -1,4 +1,5 @@use super::*;+use crate::context_bootstrap::events::EventInit;use crate::context_bootstrap::file_api::is_branded_data_transfer_object;use crate::context_bootstrap::navigation_activation::install_navigation_transition;use crate::context_bootstrap::navigation_events::navigation_scroll_event_is_active;@@ -267,12 +268,8 @@ struct ToggleEventInitMembers<'s> {#[derive(Default, webidl::WebIdlDictionary)]#[webidl(prefix = "StorageEventInit")]pub(super) struct StorageEventInitMembers<'s> {- #[webidl(default = false)]- bubbles: bool,- #[webidl(default = false)]- cancelable: bool,- #[webidl(default = false)]- composed: bool,+ #[webidl(inherit)]+ base: EventInit,#[webidl(nullable, converter = "raw")]key: Option<webidl::DomString16>,#[webidl(name = "newValue", nullable, converter = "raw")]@@ -287,7 +284,7 @@ pub(super) struct StorageEventInitMembers<'s> {impl StorageEventInitMembers<'_> {pub(super) fn event_flags(&self) -> (bool, bool, bool) {- (self.bubbles, self.cancelable, self.composed)+ (self.base.bubbles, self.base.cancelable, self.base.composed)}}diff --git a/moli-renderer-v8/src/context_bootstrap/events/subclasses/error.rs b/moli-renderer-v8/src/context_bootstrap/events/subclasses/error.rsindex a2a006f37..aa063018b 100644--- a/moli-renderer-v8/src/context_bootstrap/events/subclasses/error.rs+++ b/moli-renderer-v8/src/context_bootstrap/events/subclasses/error.rs@@ -1,3 +1,4 @@+use crate::context_bootstrap::events::EventInit;use crate::util::{v8_string, v8_string_from_utf16_units};use crate::webidl;use moli_webapi_declare::WebApiObject;@@ -7,12 +8,8 @@ use moli_webapi_declare::WebApiObject;#[derive(webidl::WebIdlDictionary)]#[webidl(prefix = "ErrorEventInit")]pub(super) struct ErrorEventInit<'s> {- #[webidl(default = false)]- bubbles: bool,- #[webidl(default = false)]- cancelable: bool,- #[webidl(default = false)]- composed: bool,+ #[webidl(inherit)]+ base: EventInit,#[webidl(default = 0)]colno: u32,#[webidl(converter = "raw")]@@ -28,9 +25,7 @@ pub(super) struct ErrorEventInit<'s> {impl Default for ErrorEventInit<'_> {fn default() -> Self {Self {- bubbles: false,- cancelable: false,- composed: false,+ base: EventInit::default(),colno: 0,error: None,filename: String::new(),@@ -70,7 +65,7 @@ struct ErrorEventState<'s> {impl<'s> ErrorEventInit<'s> {pub(super) fn event_flags(&self) -> (bool, bool, bool) {- (self.bubbles, self.cancelable, self.composed)+ (self.base.bubbles, self.base.cancelable, self.base.composed)}pub(super) fn initialize(diff --git a/moli-renderer-v8/src/context_bootstrap/events/subclasses/security_policy.rs b/moli-renderer-v8/src/context_bootstrap/events/subclasses/security_policy.rsindex 480d4f880..cbc93e66a 100644--- a/moli-renderer-v8/src/context_bootstrap/events/subclasses/security_policy.rs+++ b/moli-renderer-v8/src/context_bootstrap/events/subclasses/security_policy.rs@@ -1,6 +1,7 @@use crate::content_security_policy::{ContentSecurityPolicyDisposition, ContentSecurityPolicyViolationEventDeclaration,};+use crate::context_bootstrap::events::EventInit;use crate::util::{v8_string, v8_string_from_utf16_units};use crate::webidl;@@ -9,12 +10,8 @@ use crate::webidl;#[derive(webidl::WebIdlDictionary)]#[webidl(prefix = "SecurityPolicyViolationEventInit")]pub(super) struct SecurityPolicyViolationEventInit {- #[webidl(default = false)]- bubbles: bool,- #[webidl(default = false)]- cancelable: bool,- #[webidl(default = false)]- composed: bool,+ #[webidl(inherit)]+ base: EventInit,#[webidl(name = "blockedURI", default = "", converter = "usv_string")]blocked_uri: String,#[webidl(name = "columnNumber", default = 0)]@@ -44,9 +41,7 @@ pub(super) struct SecurityPolicyViolationEventInit {impl Default for SecurityPolicyViolationEventInit {fn default() -> Self {Self {- bubbles: false,- cancelable: false,- composed: false,+ base: EventInit::default(),blocked_uri: String::new(),column_number: 0,disposition: ContentSecurityPolicyDisposition::Enforce,@@ -87,7 +82,7 @@ pub(super) fn parse_security_policy_violation_event_init<'s>(impl SecurityPolicyViolationEventInit {pub(super) fn event_flags(&self) -> (bool, bool, bool) {- (self.bubbles, self.cancelable, self.composed)+ (self.base.bubbles, self.base.cancelable, self.base.composed)}pub(super) fn initialize<'s>(diff --git a/moli-renderer-v8/src/context_bootstrap/events/value.rs b/moli-renderer-v8/src/context_bootstrap/events/value.rsindex 1412d20d6..37af5c543 100644--- a/moli-renderer-v8/src/context_bootstrap/events/value.rs+++ b/moli-renderer-v8/src/context_bootstrap/events/value.rs@@ -4,6 +4,7 @@ use super::{define_event_property, event_private_value, initialize_event_object_with_type,initialize_event_wrapper, new_event_state, set_event_private_value,};+use crate::context_bootstrap::events::EventInit;use crate::{util::{new_null_prototype_object, throw_type_error, v8str},web_api_interfaces, webidl,@@ -106,12 +107,8 @@ struct ToolCancelEventPrototypeDeclaration {#[derive(webidl::WebIdlDictionary)]#[webidl(prefix = "ToolEventInit")]struct ToolEventInit<'s> {- #[webidl(default = false)]- bubbles: bool,- #[webidl(default = false)]- cancelable: bool,- #[webidl(default = false)]- composed: bool,+ #[webidl(inherit)]+ base: EventInit,#[webidl(name = "toolName", with = string_member)]tool_name: v8::Local<'s, v8::String>,}@@ -119,12 +116,8 @@ struct ToolEventInit<'s> {#[derive(webidl::WebIdlDictionary)]#[webidl(prefix = "WebGLContextEventInit")]struct WebGlContextEventInit<'s> {- #[webidl(default = false)]- bubbles: bool,- #[webidl(default = false)]- cancelable: bool,- #[webidl(default = false)]- composed: bool,+ #[webidl(inherit)]+ base: EventInit,#[webidl(with = string_member)]status_message: v8::Local<'s, v8::String>,}@@ -134,12 +127,8 @@ struct WebGlContextEventInit<'s> {#[derive(webidl::WebIdlDictionary)]#[webidl(prefix = "AnimationEventInit")]struct AnimationEventInit<'s> {- #[webidl(default = false)]- bubbles: bool,- #[webidl(default = false)]- cancelable: bool,- #[webidl(default = false)]- composed: bool,+ #[webidl(inherit)]+ base: EventInit,#[webidl(name = "animationName", with = string_member)]animation_name: v8::Local<'s, v8::String>,#[webidl(name = "elapsedTime", converter = "double", default = 0.0)]@@ -151,12 +140,8 @@ struct AnimationEventInit<'s> {#[derive(webidl::WebIdlDictionary)]#[webidl(prefix = "TransitionEventInit")]struct TransitionEventInit<'s> {- #[webidl(default = false)]- bubbles: bool,- #[webidl(default = false)]- cancelable: bool,- #[webidl(default = false)]- composed: bool,+ #[webidl(inherit)]+ base: EventInit,#[webidl(name = "elapsedTime", converter = "double", default = 0.0)]elapsed_time: f64,#[webidl(name = "propertyName", with = string_member)]@@ -207,12 +192,8 @@ fn gamepad_member<'s>(#[derive(webidl::WebIdlDictionary)]#[webidl(prefix = "BlobEventInit")]struct BlobEventInit<'s> {- #[webidl(default = false)]- bubbles: bool,- #[webidl(default = false)]- cancelable: bool,- #[webidl(default = false)]- composed: bool,+ #[webidl(inherit)]+ base: EventInit,#[webidl(required, interface = web_api_interfaces::Blob)]data: v8::Local<'s, v8::Object>,#[webidl(converter = "double")]@@ -338,7 +319,11 @@ fn value_event_constructor<'s>(PSEUDO_ELEMENT_SLOT,parsed.pseudo_element.into(),);- (parsed.bubbles, parsed.cancelable, parsed.composed)+ (+ parsed.base.bubbles,+ parsed.base.cancelable,+ parsed.base.composed,+ )}ValueEventKind::Transition => {let parsed =@@ -356,7 +341,11 @@ fn value_event_constructor<'s>(PSEUDO_ELEMENT_SLOT,parsed.pseudo_element.into(),);- (parsed.bubbles, parsed.cancelable, parsed.composed)+ (+ parsed.base.bubbles,+ parsed.base.cancelable,+ parsed.base.composed,+ )}ValueEventKind::WebGlContext => {let parsed =@@ -367,7 +356,11 @@ fn value_event_constructor<'s>(STATUS_MESSAGE_SLOT,parsed.status_message.into(),);- (parsed.bubbles, parsed.cancelable, parsed.composed)+ (+ parsed.base.bubbles,+ parsed.base.cancelable,+ parsed.base.composed,+ )}ValueEventKind::Blob => {let parsed = webidl::parse_dictionary_object::<BlobEventInit>(scope, dictionary)?;@@ -378,12 +371,20 @@ fn value_event_constructor<'s>(TIMECODE_SLOT,v8::Number::new(scope, parsed.timecode.unwrap_or(f64::NAN)).into(),);- (parsed.bubbles, parsed.cancelable, parsed.composed)+ (+ parsed.base.bubbles,+ parsed.base.cancelable,+ parsed.base.composed,+ )}ValueEventKind::ToolActivated | ValueEventKind::ToolCancel => {let parsed = webidl::parse_dictionary_object::<ToolEventInit>(scope, dictionary)?;set_event_private_value(scope, state, TOOL_NAME_SLOT, parsed.tool_name.into());- (parsed.bubbles, parsed.cancelable, parsed.composed)+ (+ parsed.base.bubbles,+ parsed.base.cancelable,+ parsed.base.composed,+ )}ValueEventKind::Gamepad => {let parsed =diff --git a/moli-renderer-v8/src/context_bootstrap/indexed_db/event_target/version_change.rs b/moli-renderer-v8/src/context_bootstrap/indexed_db/event_target/version_change.rsindex 8ecf2c1ba..75c0884d5 100644--- a/moli-renderer-v8/src/context_bootstrap/indexed_db/event_target/version_change.rs+++ b/moli-renderer-v8/src/context_bootstrap/indexed_db/event_target/version_change.rs@@ -1,5 +1,6 @@use super::super::super::events;use super::*;+use crate::context_bootstrap::events::EventInit;use crate::web_api_interfaces;use crate::webidl;use moli_webapi_declare::{WebApiFunctionTemplate, WebApiObject};@@ -69,14 +70,10 @@ struct IdbVersionChangeEventConstructorArgs {#[derive(Default, webidl::WebIdlDictionary)]#[webidl(prefix = "IDBVersionChangeEventInit")]struct IdbVersionChangeEventInit {+ #[webidl(inherit)]+ base: EventInit,// WebIDL reads inherited EventInit members first, then this dictionary's- // members in lexicographic order. The derive preserves declaration order.- #[webidl(default = false)]- bubbles: bool,- #[webidl(default = false)]- cancelable: bool,- #[webidl(default = false)]- composed: bool,+ // members in lexicographic order. The derive preserves inheritance order.#[webidl(nullable)]new_version: Option<u64>,#[webidl(default = 0)]@@ -105,14 +102,14 @@ pub(in crate::context_bootstrap) fn idb_version_change_event_constructor_callbacscope,event,&parsed.event_type,- parsed.init.bubbles,- parsed.init.cancelable,+ parsed.init.base.bubbles,+ parsed.init.base.cancelable,);events::define_event_property(scope,event,"composed",- v8::Boolean::new(scope, parsed.init.composed).into(),+ v8::Boolean::new(scope, parsed.init.base.composed).into(),);IdbVersionChangeEventFieldsDeclaration::new(parsed.init.old_version,diff --git a/moli-renderer-v8/src/context_bootstrap/media_queries/event.rs b/moli-renderer-v8/src/context_bootstrap/media_queries/event.rsindex 7bdfaaa9a..f4b28775f 100644--- a/moli-renderer-v8/src/context_bootstrap/media_queries/event.rs+++ b/moli-renderer-v8/src/context_bootstrap/media_queries/event.rs@@ -1,3 +1,4 @@+use crate::context_bootstrap::events::EventInit;use crate::{context_bootstrap::events::{initialize_event_object, mark_event_trusted},util::{throw_type_error, v8str},@@ -31,12 +32,8 @@ struct MediaQueryListEventPrototype {#[derive(webidl::WebIdlDictionary)]#[webidl(prefix = "MediaQueryListEventInit")]struct MediaQueryListEventInit<'s> {- #[webidl(default = false)]- bubbles: bool,- #[webidl(default = false)]- cancelable: bool,- #[webidl(default = false)]- composed: bool,+ #[webidl(inherit)]+ base: EventInit,#[webidl(default = false)]matches: bool,#[webidl(with = media_member)]@@ -84,9 +81,7 @@ fn constructor<'s>(.and_then(|object| match object {Some(object) => webidl::parse_dictionary_object::<MediaQueryListEventInit>(scope, object),None => Ok(MediaQueryListEventInit {- bubbles: false,- cancelable: false,- composed: false,+ base: EventInit::default(),matches: false,media: v8str(scope, ""),}),@@ -100,12 +95,12 @@ fn constructor<'s>(};let wrapper = args.this();let event = crate::context_bootstrap::new_event_state(scope);- initialize_event_object(scope, event, "", init.bubbles, init.cancelable);+ initialize_event_object(scope, event, "", init.base.bubbles, init.base.cancelable);let _ = event.set(scope, v8str(scope, "type").into(), event_type.into());let _ = event.set(scope,v8str(scope, "composed").into(),- v8::Boolean::new(scope, init.composed).into(),+ v8::Boolean::new(scope, init.base.composed).into(),);MediaQueryListEventState::new(init.media, init.matches).initialize(scope, event)diff --git a/moli-renderer-v8/src/script_vm/tests/event_receivers.rs b/moli-renderer-v8/src/script_vm/tests/event_receivers.rsindex 988482749..933f64a16 100644--- a/moli-renderer-v8/src/script_vm/tests/event_receivers.rs+++ b/moli-renderer-v8/src/script_vm/tests/event_receivers.rs@@ -1,5 +1,64 @@use super::*;+#[test]+fn derived_event_dictionaries_convert_ancestors_before_own_members() {+ let mut vm = new_storage_page_task_executor_test_vm("https://event-dictionary-order.test/");+ vm.eval("document.body.innerHTML = '<iframe></iframe>'")+ .unwrap();+ assert_eq!(+ vm.eval(+ r#"(() => {+ const base = ['bubbles', 'cancelable', 'composed'];+ const cases = [+ ['AnimationEvent', ['animationName', 'elapsedTime', 'pseudoElement']],+ ['TransitionEvent', ['elapsedTime', 'propertyName', 'pseudoElement']],+ ['WebGLContextEvent', ['statusMessage']],+ ['BlobEvent', ['data', 'timecode']],+ ['MessageEvent', ['data', 'lastEventId', 'origin', 'ports', 'source']],+ ['StorageEvent', ['key', 'newValue', 'oldValue', 'storageArea', 'url']],+ ['ErrorEvent', ['colno', 'error', 'filename', 'lineno', 'message']],+ ['DeviceOrientationEvent', ['absolute', 'alpha', 'beta', 'gamma']],+ ['DeviceMotionEvent', ['acceleration', 'accelerationIncludingGravity', 'interval', 'rotationRate']],+ ['MediaQueryListEvent', ['matches', 'media']],+ ['IDBVersionChangeEvent', ['newVersion', 'oldVersion']],+ ['SecurityPolicyViolationEvent', ['blockedURI', 'columnNumber', 'disposition', 'documentURI', 'effectiveDirective', 'lineNumber', 'originalPolicy', 'referrer', 'sample', 'sourceFile', 'statusCode', 'violatedDirective']],+ ];+ for (const realm of [window, document.querySelector('iframe').contentWindow]) {+ for (const [name, own] of cases) {+ const trace = [], expected = [...base, ...own];+ const init = new Proxy({}, {get(_, key) {+ trace.push(key);+ if (base.includes(key)) return true;+ if (name === 'BlobEvent' && key === 'data') return new realm.Blob([]);+ return undefined;+ }});+ const event = new realm[name]('order', init);+ if (trace.join() !== expected.join() || !event.bubbles ||+ !event.cancelable || !event.composed)+ throw Error(name + ' conversion order: ' + trace);+ for (const member of base) {+ const sentinel = {}, before = [];+ const failing = new Proxy({}, {get(_, key) {+ before.push(key);+ if (key === member) throw sentinel;+ return false;+ }});+ let error;+ try {new realm[name]('order', failing);} catch (caught) {error = caught;}+ if (error !== sentinel || before.join() !==+ base.slice(0, base.indexOf(member) + 1).join())+ throw Error(name + ' ancestor exception: ' + before);+ }+ }+ }+ return true;+ })()"#,+ )+ .unwrap(),+ "true"+ );+}+#[test]fn event_bindings_validate_native_receivers_before_conversion_in_the_callee_realm() {let mut vm = new_parsed_test_vm(diff --git a/moli-webidl-derive/src/attrs.rs b/moli-webidl-derive/src/attrs.rsindex 70d432408..4be1bf119 100644--- a/moli-webidl-derive/src/attrs.rs+++ b/moli-webidl-derive/src/attrs.rs@@ -1,3 +1,4 @@+use syn::ext::IdentExt;use syn::spanned::Spanned;use syn::{Error, Expr, Field, Ident, LitInt, LitStr, Path};@@ -52,6 +53,7 @@ pub(crate) fn parse_rename_rule(value: &LitStr) -> Result<RenameRule, Error> {#[derive(Default)]pub(crate) struct FieldAttrs {+ pub(crate) inherit: bool,pub(crate) required: bool,pub(crate) name: Option<LitStr>,pub(crate) default: Option<Expr>,@@ -77,6 +79,13 @@ pub(crate) fn parse_field_attrs(field: &Field) -> Result<FieldAttrs, Error> {.filter(|attr| attr.path().is_ident("webidl")){attr.parse_nested_meta(|meta| {+ if meta.path.is_ident("inherit") {+ if parsed.inherit {+ return Err(meta.error("duplicate inherit attribute"));+ }+ parsed.inherit = true;+ return Ok(());+ }if meta.path.is_ident("required") {parsed.required = true;return Ok(());@@ -154,6 +163,28 @@ pub(crate) fn parse_field_attrs(field: &Field) -> Result<FieldAttrs, Error> {Err(meta.error("unsupported #[webidl(...)] field attribute"))})?;}+ if parsed.inherit+ && (parsed.required+ || parsed.name.is_some()+ || parsed.default.is_some()+ || parsed.converter.is_some()+ || parsed.dictionary+ || parsed.sequence+ || parsed.interface.is_some()+ || parsed.brand_check.is_some()+ || parsed.missing_message.is_some()+ || parsed.index.is_some()+ || parsed.legacy_nullish+ || parsed.treat_null_as_empty_string+ || parsed.nullable+ || parsed.with.is_some()+ || parsed.variadic)+ {+ return Err(Error::new(+ field.span(),+ "inherit cannot be combined with member or conversion attributes",+ ));+ }if let Some(brand_check) = &parsed.brand_check&& parsed.interface.is_none(){@@ -371,7 +402,7 @@ pub(crate) fn field_member_name(return Ok(name);}let ident = field_ident(field)?;- let raw_name = ident.to_string();+ let raw_name = ident.unraw().to_string();let renamed = apply_rename_rule(&raw_name, rename_all);Ok(LitStr::new(&renamed, ident.span()))}diff --git a/moli-webidl-derive/src/expand.rs b/moli-webidl-derive/src/expand.rsindex 1ad1a1f0b..a1280c6f2 100644--- a/moli-webidl-derive/src/expand.rs+++ b/moli-webidl-derive/src/expand.rs@@ -88,9 +88,41 @@ pub(crate) fn expand_webidl_dictionary(let rename_all = attrs.rename_all.unwrap_or(RenameRule::CamelCase);let fields = named_fields(&input.data)?;- let bindings = fields- .iter()- .map(|field| expand_dictionary_field(field, &prefix, rename_all))+ // Dictionary inheritance is converted before this dictionary's members,+ // which WebIDL orders by their final JavaScript names, not Rust layout.+ let mut inherited = None;+ let mut members = std::collections::BTreeMap::new();+ for field in &fields {+ let attrs = parse_field_attrs(field)?;+ if attrs.inherit {+ if inherited.replace(field).is_some() {+ return Err(Error::new(+ field.span(),+ "WebIdlDictionary supports only one inherited dictionary",+ ));+ }+ if is_option_type(&field.ty) {+ return Err(Error::new(+ field.ty.span(),+ "inherited dictionaries cannot use Option<T>",+ ));+ }+ } else {+ let name = field_member_name(field, &attrs, rename_all)?;+ if let Some(previous) = members.insert(name.value(), field) {+ let mut error = Error::new(+ name.span(),+ format!("duplicate WebIDL dictionary member `{}`", name.value()),+ );+ error.combine(Error::new(previous.span(), "previous member defined here"));+ return Err(error);+ }+ }+ }+ let bindings = inherited+ .into_iter()+ .chain(members.into_values())+ .map(|field| expand_dictionary_field(field, &prefix, rename_all, &scope_lifetime)).collect::<Result<Vec<_>, _>>()?;let idents = fields.iter()@@ -269,6 +301,12 @@ fn expand_args_field() -> Result<proc_macro2::TokenStream, Error> {let ident = field_ident(field)?;let attrs = parse_field_attrs(field)?;+ if attrs.inherit {+ return Err(Error::new(+ field.span(),+ "inherit only applies to WebIdlDictionary fields",+ ));+ }if attrs.variadic {// Variadic arguments represent the rest parameter tail. They cannot be// required, nullable, defaulted, or custom-parsed because the generated@@ -448,9 +486,16 @@ fn expand_dictionary_field(field: &Field,prefix: &LitStr,rename_all: RenameRule,+ scope_lifetime: &syn::Lifetime,) -> Result<proc_macro2::TokenStream, Error> {let ident = field_ident(field)?;let attrs = parse_field_attrs(field)?;+ if attrs.inherit {+ let ty = &field.ty;+ return Ok(quote! {+ let #ident = <#ty as ::moli_webidl::WebIdlDictionary<#scope_lifetime>>::parse_dictionary(scope, object)?;+ });+ }if let Some(with) = attrs.with.as_ref() {// Custom dictionary parsers receive the resolved member name and own all// reads/conversion for the field. Use this for APIs whose WebIDL order@@ -623,6 +668,61 @@ mod tests {use super::{expand_webidl_args, expand_webidl_dictionary, impl_parts_for_scope};use syn::parse_quote;+ #[test]+ fn dictionary_member_names_must_be_unique_after_renaming() {+ for input in [+ parse_quote! {struct Options { #[webidl(name = "same")] first: Option<String>, #[webidl(name = "same")] second: Option<String> }},+ parse_quote! {struct Options { first_name: Option<String>, #[webidl(name = "firstName")] other: Option<String> }},+ parse_quote! {struct Options { r#type: Option<String>, #[webidl(name = "type")] other: Option<String> }},+ ] {+ assert!(+ expand_webidl_dictionary(input)+ .unwrap_err()+ .to_string()+ .starts_with("duplicate WebIDL dictionary member")+ );+ }+ }++ #[test]+ fn inheritance_requires_one_unmodified_dictionary_field() {+ let positional = parse_quote! {struct Args { #[webidl(inherit)] base: Base }};+ assert_eq!(+ expand_webidl_args(positional).unwrap_err().to_string(),+ "inherit only applies to WebIdlDictionary fields"+ );+ for input in [+ parse_quote! {struct Options { #[webidl(inherit)] base: Base, #[webidl(inherit)] other: Other }},+ parse_quote! {struct Options { #[webidl(inherit)] base: Option<Base> }},+ parse_quote! {struct Options { #[webidl(inherit, inherit)] base: Base }},+ ] {+ assert!(expand_webidl_dictionary(input).is_err());+ }+ for attrs in [+ quote::quote!(required),+ quote::quote!(name = "base"),+ quote::quote!(default = Base::default()),+ quote::quote!(converter = "raw"),+ quote::quote!(dictionary),+ quote::quote!(sequence),+ quote::quote!(interface = Base),+ quote::quote!(brand_check = check),+ quote::quote!(missing_message = "base"),+ quote::quote!(index = 1),+ quote::quote!(legacy_nullish),+ quote::quote!(treat_null_as_empty_string),+ quote::quote!(nullable),+ quote::quote!(with = parse),+ quote::quote!(variadic),+ ] {+ let input = parse_quote! {struct Options { #[webidl(inherit, #attrs)] base: Base }};+ assert_eq!(+ expand_webidl_dictionary(input).unwrap_err().to_string(),+ "inherit cannot be combined with member or conversion attributes"+ );+ }+ }+#[test]fn dictionary_attributes_reject_conflicting_conversion_paths() {for (attrs, message) in [diff --git a/moli-webidl-derive/src/lib.rs b/moli-webidl-derive/src/lib.rsindex d2541aef5..e9f7e0ccb 100644--- a/moli-webidl-derive/src/lib.rs+++ b/moli-webidl-derive/src/lib.rs@@ -36,6 +36,12 @@ pub fn derive_webidl_args(input: TokenStream) -> TokenStream {/// `nullable`, legacy nullish handling, explicit converters, and hand-written/// member parser hooks. Unnamed fields use `camelCase` member names by default,/// matching common WebIDL dictionary spelling.+/// Members are read and converted in lexicographical order of their final+/// JavaScript names, including `name` and `rename_all` overrides. Rust raw+/// identifiers such as `r#type` refer to the member `type`.+/// One `#[webidl(inherit)]` field delegates to its `WebIdlDictionary` type on+/// the same object before all own members, without reading a property for the+/// field. Inheritance cannot be combined with member/conversion attributes./// Object members support `interface = Type` and an optional `brand_check = path`/// using the same native identity conversion as positional arguments./// Nested members support `dictionary`: null parses an empty dictionary whilediff --git a/moli-webidl/src/lib.rs b/moli-webidl/src/lib.rsindex 698e59cdc..6d99ca44b 100644--- a/moli-webidl/src/lib.rs+++ b/moli-webidl/src/lib.rs@@ -29,6 +29,10 @@//! generates named property parsing for dictionary objects. Both derives use//! the converter wrappers in `types` and only produce Rust values; object shape//! declaration and Web API wrapper allocation remain outside this crate.+//! Dictionary members are converted in lexicographical order of their final+//! JavaScript names. `#[webidl(inherit)]` on one dictionary field converts the+//! ancestor's members from the same object first; it does not read a nested+//! property. Positional arguments retain their declaration/index order.//!//! Interface fields use `#[webidl(interface = interfaces::EventTarget)]` with//! `v8::Local<'s, v8::Object>`, optionally wrapped in `Option` or a variadicdiff --git a/moli-webidl/tests/dictionaries.rs b/moli-webidl/tests/dictionaries.rsindex b18db4017..02833f15e 100644--- a/moli-webidl/tests/dictionaries.rs+++ b/moli-webidl/tests/dictionaries.rs@@ -385,7 +385,7 @@ fn required_dictionary_members_and_argument_arity_are_not_bypassed_by_nullish_va}#[test]-fn dictionary_getters_coercions_and_exceptions_preserve_field_order() {+fn dictionary_getters_coercions_and_exceptions_follow_member_order() {run_checks(r#"const assert = (ok, message) => { if (!ok) throw new Error(message); };@@ -401,11 +401,11 @@ fn dictionary_getters_coercions_and_exceptions_preserve_field_order() {get nullable() { order.push('nullable'); return undefined; },get after() { order.push('after'); return text('last'); }});- assert(order.join() === 'child,limit,number,label,string,marker,nullable,after,last', 'dictionary order: ' + order);+ assert(order.join() === 'after,last,child,label,string,limit,number,marker,nullable', 'dictionary order: ' + order);assert(parsed[0][0] === 4 && parsed[0][2] === 'identity', 'inherited members');order.length = 0;defaults(text('before'), child, text('after'));- assert(order.join() === 'before,limit,number,label,string,marker,after', 'argument order: ' + order);+ assert(order.join() === 'before,label,string,limit,number,marker,after', 'argument order: ' + order);const sentinel = {};let after = 0;for (const child of [@@ -420,7 +420,7 @@ fn dictionary_getters_coercions_and_exceptions_preserve_field_order() {}let error;try { requiredNested({child: null, get after() {after++; return '';}}); } catch (caught) {error = caught;}- assert(error instanceof CalleeTypeError && after === 0, 'failed child prevents later getters');+ assert(error instanceof CalleeTypeError && after === 5, 'earlier member precedes child conversion failures');const marker = {};assert(nested({child: {marker}})[0][2] === marker, 'retain raw member identity');true;diff --git a/moli-webidl/tests/dictionary_order.rs b/moli-webidl/tests/dictionary_order.rsnew file mode 100644index 000000000..9dc166925--- /dev/null+++ b/moli-webidl/tests/dictionary_order.rs@@ -0,0 +1,298 @@+use moli_webidl::{Context, WebIdlArgs, WebIdlDictionary};++#[derive(WebIdlArgs, WebIdlDictionary)]+#[webidl(rename_all = "none")]+struct Renamed {+ #[webidl(name = "zulu", default = 0)]+ first: u32,+ #[webidl(name = "Alpha", default = 0)]+ second: u32,+ #[webidl(default = 0)]+ r#type: u32,+ #[webidl(default = 0)]+ middle: u32,+}++#[derive(WebIdlDictionary)]+#[webidl(rename_all = "kebab-case")]+struct Kebab {+ #[webidl(default = 0)]+ z_value: u32,+ #[webidl(default = 0)]+ a_value: u32,+}++#[derive(WebIdlDictionary)]+struct Base<'s> {+ #[webidl(default = 7)]+ zulu: u32,+ #[webidl(default = "base")]+ bravo: String,+ #[webidl(converter = "raw")]+ marker: Option<v8::Local<'s, v8::Value>>,+}++#[derive(WebIdlDictionary)]+struct Derived<'s> {+ #[webidl(default = "derived")]+ delta: String,+ #[webidl(inherit)]+ base: Base<'s>,+ #[webidl(default = 9)]+ alpha: u32,+}++#[derive(WebIdlDictionary)]+struct MostDerived<'s> {+ #[webidl(required)]+ aardvark: String,+ #[webidl(inherit)]+ parent: Derived<'s>,+}++fn renamed<'s>(+ scope: &mut v8::PinScope<'s, '_>,+ args: v8::FunctionCallbackArguments<'s>,+ mut rv: v8::ReturnValue<'s>,+) {+ match moli_webidl::convert::<moli_webidl::Dictionary<Renamed>>(+ scope,+ args.get(0),+ Context::argument("Test.renamed", 1),+ ) {+ Ok(value) => rv.set(+ v8::Integer::new_from_unsigned(+ scope,+ value.0.first + value.0.second + value.0.r#type + value.0.middle,+ )+ .into(),+ ),+ Err(error) => moli_webidl::throw_error(scope, &error),+ }+}++fn positional<'s>(+ scope: &mut v8::PinScope<'s, '_>,+ args: v8::FunctionCallbackArguments<'s>,+ mut rv: v8::ReturnValue<'s>,+) {+ if let Some(value) = moli_webidl::parse_args::<Renamed>(scope, &args) {+ rv.set(+ v8::Integer::new_from_unsigned(+ scope,+ value.first + value.second + value.r#type + value.middle,+ )+ .into(),+ );+ }+}++fn kebab<'s>(+ scope: &mut v8::PinScope<'s, '_>,+ args: v8::FunctionCallbackArguments<'s>,+ mut rv: v8::ReturnValue<'s>,+) {+ match moli_webidl::convert::<moli_webidl::Dictionary<Kebab>>(+ scope,+ args.get(0),+ Context::argument("Test.kebab", 1),+ ) {+ Ok(value) => {+ rv.set(v8::Integer::new_from_unsigned(scope, value.0.a_value + value.0.z_value).into())+ }+ Err(error) => moli_webidl::throw_error(scope, &error),+ }+}++fn inherited<'s>(+ scope: &mut v8::PinScope<'s, '_>,+ args: v8::FunctionCallbackArguments<'s>,+ mut rv: v8::ReturnValue<'s>,+) {+ match moli_webidl::convert::<moli_webidl::Dictionary<MostDerived>>(+ scope,+ args.get(0),+ Context::argument("Test.inherited", 1),+ ) {+ Ok(value) => {+ let value = value.0;+ let base = value.parent.base;+ let text = v8::String::new(+ scope,+ &format!(+ "{}|{}|{}|{}|{}",+ base.bravo, base.zulu, value.parent.alpha, value.parent.delta, value.aardvark,+ ),+ )+ .unwrap();+ let marker = base.marker.unwrap_or_else(|| v8::undefined(scope).into());+ rv.set(v8::Array::new_with_elements(scope, &[text.into(), marker]).into());+ }+ Err(error) => moli_webidl::throw_error(scope, &error),+ }+}++fn run_checks(source: &str) {+ moli_v8_test_util::ensure_v8();+ let mut isolate = v8::Isolate::new(Default::default());+ let scope = std::pin::pin!(v8::HandleScope::new(&mut isolate));+ let scope = &mut scope.init();+ let callee = v8::Context::new(scope, Default::default());+ let exports = {+ let scope = &mut v8::ContextScope::new(scope, callee);+ let key = v8::String::new(scope, "TypeError").unwrap();+ [+ ("renamed", v8::Function::new(scope, renamed).unwrap().into()),+ (+ "positional",+ v8::Function::new(scope, positional).unwrap().into(),+ ),+ ("kebab", v8::Function::new(scope, kebab).unwrap().into()),+ (+ "inherited",+ v8::Function::new(scope, inherited).unwrap().into(),+ ),+ (+ "CalleeTypeError",+ callee.global(scope).get(scope, key.into()).unwrap(),+ ),+ ]+ };+ let caller = v8::Context::new(scope, Default::default());+ let scope = &mut v8::ContextScope::new(scope, caller);+ for (name, value) in exports {+ let name = v8::String::new(scope, name).unwrap();+ assert_eq!(+ caller.global(scope).set(scope, name.into(), value),+ Some(true)+ );+ }+ v8::tc_scope!(let scope, scope);+ let source = v8::String::new(scope, source).unwrap();+ let result = v8::Script::compile(scope, source, None).unwrap().run(scope);+ let error = scope+ .exception()+ .map(|value| value.to_rust_string_lossy(scope));+ assert!(result.is_some_and(|value| value.is_true()), "{error:?}");+}++#[test]+fn final_member_names_determine_dictionary_order_but_not_argument_order() {+ run_checks(+ r#"+ const assert = (ok, message) => {if (!ok) throw Error(message);};+ const names = ['Alpha', 'middle', 'type', 'zulu'];+ for (const kind of ['own', 'inherited', 'proxy']) {+ const order = [], target = {};+ for (const key of names) Object.defineProperty(target, key, {get() {+ order.push(key); return {valueOf() {order.push(key + ':number'); return 1;}};+ }});+ const value = kind === 'inherited' ? Object.create(target) : kind === 'proxy' ? new Proxy(target, {}) : target;+ assert(renamed(value) === 4, 'parsed values');+ assert(order.join() === names.flatMap(key => [key, key + ':number']).join(), 'final name order: ' + order);+ }+ const order = [];+ assert(positional(...[1,2,3,4].map(n => ({valueOf() {order.push(n); return n;}}))) === 10, 'positional values');+ assert(order.join() === '1,2,3,4', 'positional declaration order');+ order.length = 0;+ assert(kebab(new Proxy({}, {get(_, key) {order.push(key); return 1;}})) === 2, 'renamed values');+ assert(order.join() === 'a-value,z-value', 'rename_all before sorting');+ true;+ "#,+ );+}++#[test]+fn each_member_converts_before_the_next_getter_and_rethrows_original_exceptions() {+ run_checks(+ r#"+ const assert = (ok, message) => {if (!ok) throw Error(message);};+ const names = ['Alpha', 'middle', 'type', 'zulu'];+ for (const key of names) for (const conversion of [false, true]) {+ const sentinel = {}, order = [], value = {};+ for (const name of names) Object.defineProperty(value, name, {get() {+ order.push(name);+ if (name === key) {+ if (!conversion) throw sentinel;+ return {valueOf() {order.push(name + ':number'); throw sentinel;}};+ }+ return 1;+ }});+ let error;+ try {renamed(value);} catch (caught) {error = caught;}+ const expected = names.slice(0, names.indexOf(key) + 1);+ if (conversion) expected.push(key + ':number');+ assert(error === sentinel && order.join() === expected.join(), 'short circuit ' + key);+ }+ true;+ "#,+ );+}++#[test]+fn inherited_dictionaries_read_one_object_in_ancestor_order_with_scoped_values() {+ run_checks(+ r#"+ const assert = (ok, message) => {if (!ok) throw Error(message);};+ const names = ['bravo', 'marker', 'zulu', 'alpha', 'delta', 'aardvark'];+ const marker = {};+ for (const kind of ['own', 'inherited', 'proxy']) {+ const order = [], target = {};+ for (const key of names) Object.defineProperty(target, key, {get() {+ order.push(key);+ if (key === 'marker') return marker;+ return key === 'zulu' || key === 'alpha'+ ? {valueOf() {order.push(key + ':number'); return 1;}}+ : {toString() {order.push(key + ':string'); return key;}};+ }});+ Object.defineProperty(target, 'base', {get() {throw Error('nested base property');}});+ Object.defineProperty(target, 'parent', {get() {throw Error('nested parent property');}});+ const value = kind === 'inherited' ? Object.create(target) : kind === 'proxy' ? new Proxy(target, {}) : target;+ const result = inherited(value);+ assert(result[0] === 'bravo|1|1|delta|aardvark' && result[1] === marker, 'values and scoped identity');+ assert(order.join() === 'bravo,bravo:string,marker,zulu,zulu:number,alpha,alpha:number,delta,delta:string,aardvark,aardvark:string', 'ancestor before own: ' + order);+ }+ assert(inherited({aardvark: 'required'})[0] === 'base|7|9|derived|required', 'ancestor defaults');+ true;+ "#,+ );+}++#[test]+fn inherited_conversion_errors_stop_before_later_members_and_required_checks() {+ run_checks(+ r#"+ const assert = (ok, message) => {if (!ok) throw Error(message);};+ const names = ['bravo', 'marker', 'zulu', 'alpha', 'delta', 'aardvark'];+ for (const key of names) for (const conversion of [false, true]) {+ if (conversion && key === 'marker') continue;+ const sentinel = {}, order = [];+ const value = new Proxy({}, {get(_, name) {+ order.push(name);+ if (name === key) {+ if (!conversion) throw sentinel;+ const fail = () => {order.push(name + ':convert'); throw sentinel;};+ return name === 'zulu' || name === 'alpha' ? {valueOf: fail} : {toString: fail};+ }+ return name === 'marker' ? undefined : name === 'zulu' || name === 'alpha' ? 1 : name;+ }});+ let error;+ try {inherited(value);} catch (caught) {error = caught;}+ const expected = names.slice(0, names.indexOf(key) + 1);+ if (conversion) expected.push(key + ':convert');+ assert(error === sentinel && order.join() === expected.join(), 'inherited exception ' + key);+ }+ const order = [];+ let error;+ try {inherited(new Proxy({}, {get(_, key) {order.push(key); return undefined;}}));} catch (caught) {error = caught;}+ assert(error instanceof CalleeTypeError && !(error instanceof TypeError), 'callee required-member TypeError');+ assert(order.join() === names.join(), 'required check after all preceding members');+ for (const value of [undefined, null]) {+ error = undefined;+ try {inherited(value);} catch (caught) {error = caught;}+ assert(error instanceof CalleeTypeError, 'required descendant of empty dictionary');+ }+ true;+ "#,+ );+}diff --git a/moli-webidl/tests/interfaces.rs b/moli-webidl/tests/interfaces.rsindex ca1c1ad8e..abb0b253b 100644--- a/moli-webidl/tests/interfaces.rs+++ b/moli-webidl/tests/interfaces.rs@@ -385,10 +385,11 @@ fn interface_dictionary_members_preserve_getters_nullability_and_native_identityconst error = typeError(() => dictionary({get before() { order.push('before'); return 'label'; },get optional() { order.push('optional'); return value; },- get nullable() { order.push('nullable'); throw sentinel; }+ get nullable() { order.push('nullable'); return native; },+ get special() { order.push('special'); throw sentinel; }}));assert(error.message.includes('RenamedBase') && error.message.includes('optional'), 'interface member error context');- assert(order.join() === 'before,optional', 'validation precedes later getter');+ assert(order.join() === 'before,nullable,optional', 'validation precedes later getter');}assert(traps === 0, 'member value identity checks never invoke author traps');assert(caught(() => dictionary({get optional() { throw sentinel; }})) === sentinel, 'getter exception identity');@@ -400,7 +401,7 @@ fn interface_dictionary_members_preserve_getters_nullability_and_native_identityget special() { order.push('special'); return special; },get after() { order.push('after'); return 1; }});- assert(order.join() === 'before,optional,nullable,special,after', 'successful getter order');+ assert(order.join() === 'after,before,nullable,optional,special', 'successful getter order');return true;})()"#,diff --git a/moli-webidl/tests/sequences.rs b/moli-webidl/tests/sequences.rsindex 6353d58da..28128ca8f 100644--- a/moli-webidl/tests/sequences.rs+++ b/moli-webidl/tests/sequences.rs@@ -355,7 +355,7 @@ fn sequence_iteration_stays_interleaved_with_conversion_and_stops_at_first_error}};items({get strings() {order.push('strings'); return iterable;}, get nullStrings() {order.push('after');}});- assert(order.join() === 'strings,iterator,call,next,string,next,string,next,after', 'interleaving: ' + order);+ assert(order.join() === 'after,strings,iterator,call,next,string,next,string,next', 'interleaving: ' + order);let beforeCalls = 0;const poison = {toString() {beforeCalls++; throw 'before';}};let error;@@ -369,8 +369,8 @@ fn sequence_iteration_stays_interleaved_with_conversion_and_stops_at_first_error}};try { sequence({objects: invalid, get after() {afterCalls++; return '';}}); } catch (caught) {error = caught;}- assert(error instanceof CalleeTypeError && nextCalls === 1 && closes === 0 && afterCalls === 0,- 'brand failure must stop without iterator close or later getters');+ assert(error instanceof CalleeTypeError && nextCalls === 1 && closes === 0 && afterCalls === 1,+ 'earlier member precedes brand failure without iterator close');const sentinel = {};for (const objects of [{get [Symbol.iterator]() {throw sentinel;}},@@ -383,7 +383,7 @@ fn sequence_iteration_stays_interleaved_with_conversion_and_stops_at_first_errorassert(error === sentinel, 'preserve original iterator exception');}try { itemsArgs([{toString() {throw sentinel;}}]); } catch (caught) {error = caught;}- assert(error === sentinel && afterCalls === 0, 'item exception and stop position');+ assert(error === sentinel && afterCalls === 6, 'item exception and earlier member count');true;"#,);