Truly independent web browser
LibWeb: Run custom element reactions for DOMStringMap's setter/deleter
Shannon Booth69f84cc52c99
diff --git a/Libraries/LibWeb/HTML/DOMStringMap.idl b/Libraries/LibWeb/HTML/DOMStringMap.idlindex 1534a9e7e65..31856ec57bb 100644--- a/Libraries/LibWeb/HTML/DOMStringMap.idl+++ b/Libraries/LibWeb/HTML/DOMStringMap.idl@@ -3,7 +3,6 @@interface DOMStringMap {getter DOMString (DOMString name);- // FIXME: Extended attributes are currently not applied to special operations.[CEReactions] setter undefined (DOMString name, DOMString value);[CEReactions] deleter undefined (DOMString name);};diff --git a/Meta/Generators/libweb_bindings/rust_bindings.py b/Meta/Generators/libweb_bindings/rust_bindings.pyindex 4edaf44b506..9e5fa7463a1 100644--- a/Meta/Generators/libweb_bindings/rust_bindings.py+++ b/Meta/Generators/libweb_bindings/rust_bindings.py@@ -2049,6 +2049,9 @@ def write_rust_named_properties()for hook, entry_point in named_property_setter_hooks_and_entry_points(interface, setter):method = setter.method if setter.operation.name else hook+ call = f"Implementation::{method}(&implementation, &mut cx, name, idl_value)"+ if "CEReactions" in setter.operation.extended_attributes:+ call = with_ce_reactions(call)out.write(f"""/// Sets the named property of the wrapper, https://webidl.spec.whatwg.org/#invoke-named-setter@@ -2075,7 +2078,7 @@ def write_rust_named_properties(let mut cx = CallContext::new(vm, realm);let steps = || -> ThrowCompletionOr<Value> {{let idl_value = {value_conversion}?;- Implementation::{method}(&implementation, &mut cx, name, idl_value)+ {call}.map_err(|exception| exception.throw_in_current_realm(cx.vm()))?;Ok(Value::UNDEFINED)}};@@ -2085,6 +2088,9 @@ def write_rust_named_properties()if named_properties.deleter is not None:deleter = named_properties.deleter+ call = f"Implementation::{deleter.method}(&implementation, &mut cx, name)"+ if "CEReactions" in deleter.operation.extended_attributes:+ call = with_ce_reactions(call)out.write(f"""/// Deletes the named property of the wrapper, https://webidl.spec.whatwg.org/#legacy-platform-object-delete@@ -2106,7 +2112,7 @@ def write_rust_named_properties(let name = Utf16String::from(unsafe {{ Utf16FlyString::from_raw_borrowed(name) }});let implementation = implementation_of::<Implementation>(wrapper);let mut cx = CallContext::new(vm, realm);- let result = Implementation::{deleter.method}(&implementation, &mut cx, name)+ let result = {call}.map(|()| Value::UNDEFINED).map_err(|exception| exception.throw_in_current_realm(cx.vm()));RawNativeFunctionResult::from_completion(result)diff --git a/Meta/Generators/libweb_bindings/rust_members.py b/Meta/Generators/libweb_bindings/rust_members.pyindex 933cb74e82c..e0887959f6f 100644--- a/Meta/Generators/libweb_bindings/rust_members.py+++ b/Meta/Generators/libweb_bindings/rust_members.py@@ -496,7 +496,6 @@ def rust_members(interface: Interface) -> RustMembers:special_operation.extended_attributes,)if not special_operation.name:- # FIXME: Apply [CEReactions] to a named property setter or deleter, which the C++ bindings do not either.supported = set() if kind == "getter" else {"CEReactions"}check_extended_attributes(f"its named property {kind}", special_operation.extended_attributes, supported)return RustOperation(operation, anonymous_method)diff --git a/Tests/LibWeb/Text/expected/wpt-import/custom-elements/reactions/DOMStringMap.txt b/Tests/LibWeb/Text/expected/wpt-import/custom-elements/reactions/DOMStringMap.txtindex 0076cc64d21..344950d1a07 100644--- a/Tests/LibWeb/Text/expected/wpt-import/custom-elements/reactions/DOMStringMap.txt+++ b/Tests/LibWeb/Text/expected/wpt-import/custom-elements/reactions/DOMStringMap.txt@@ -2,13 +2,12 @@ Harness status: OKFound 8 tests-4 Pass-4 Fail-Fail setter on DOMStringMap must enqueue an attributeChanged reaction when adding an observed data attribute+8 Pass+Pass setter on DOMStringMap must enqueue an attributeChanged reaction when adding an observed data attributePass setter on DOMStringMap must not enqueue an attributeChanged reaction when adding an unobserved data attribute-Fail setter on DOMStringMap must enqueue an attributeChanged reaction when mutating the value of an observed data attribute-Fail setter on DOMStringMap must enqueue an attributeChanged reaction when mutating the value of an observed data attribute to the same value+Pass setter on DOMStringMap must enqueue an attributeChanged reaction when mutating the value of an observed data attribute+Pass setter on DOMStringMap must enqueue an attributeChanged reaction when mutating the value of an observed data attribute to the same valuePass setter on DOMStringMap must not enqueue an attributeChanged reaction when mutating the value of an unobserved data attribute-Fail deleter on DOMStringMap must enqueue an attributeChanged reaction when removing an observed data attribute+Pass deleter on DOMStringMap must enqueue an attributeChanged reaction when removing an observed data attributePass deleter on DOMStringMap must not enqueue an attributeChanged reaction when removing an unobserved data attributePass deleter on DOMStringMap must not enqueue an attributeChanged reaction when it does not remove a data attribute\ No newline at end of file