Skip to content

Truly independent web browser

LibWeb: Make CSS property accessors enumerable

sideshowbarkerc080602ad00e
diff --git a/Libraries/LibWeb/Bindings/Rust/src/css/css_style_properties.rs b/Libraries/LibWeb/Bindings/Rust/src/css/css_style_properties.rs
index 31363a21eb9..ec9b47d80da 100644
--- a/Libraries/LibWeb/Bindings/Rust/src/css/css_style_properties.rs
+++ b/Libraries/LibWeb/Bindings/Rust/src/css/css_style_properties.rs
@@ -117,8 +117,7 @@ impl CSSStyleProperties {
self.declaration.set(property.property_name, value)
}
- /// Defines the accessors of the CSS properties on the interface prototype object. They are not enumerable, so that
- /// enumerating the object only finds its indexed properties.
+ /// Defines the accessors of the CSS properties on the interface prototype object.
pub(crate) fn define_property_accessors<Getter, Setter>(
vm: &Vm,
realm: Gc<Realm>,
@@ -129,7 +128,7 @@ impl CSSStyleProperties {
Getter: Fn(&Vm, &CSSPropertyAccessor) -> ThrowCompletionOr<Value> + Copy + 'static,
Setter: Fn(&Vm, &CSSPropertyAccessor) -> ThrowCompletionOr<Value> + Copy + 'static,
{
- let attributes = PropertyAttributes::new(Attribute::CONFIGURABLE | Attribute::WRITABLE);
+ let attributes = PropertyAttributes::new(Attribute::CONFIGURABLE | Attribute::ENUMERABLE);
let define = |attribute: &str, property_name: &'static str| {
let key = PropertyKey::from_utf8(attribute);
let capture = || CSSPropertyAccessor { property_name };
diff --git a/Tests/LibWeb/Text/expected/css/CSSStyleProperties-accessors.txt b/Tests/LibWeb/Text/expected/css/CSSStyleProperties-accessors.txt
index 8072a6c9c84..fbf11026912 100644
--- a/Tests/LibWeb/Text/expected/css/CSSStyleProperties-accessors.txt
+++ b/Tests/LibWeb/Text/expected/css/CSSStyleProperties-accessors.txt
@@ -4,7 +4,7 @@ dashed: blue, color: red; float: left; background-color: blue;
webkit: green, green
legacy alias: center, center
null clears: "", float: left; background-color: blue; -webkit-text-fill-color: green; align-content: center;
-enumerable: false, configurable: true
+enumerable: true, configurable: true
getter: get color, 0; setter: set color, 1
own keys on the object: 0,1,2,3
wrong this: TypeError
diff --git a/Tests/LibWeb/Text/expected/css/css-style-properties-enumeration.txt b/Tests/LibWeb/Text/expected/css/css-style-properties-enumeration.txt
new file mode 100644
index 00000000000..d639a35f1cf
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/css-style-properties-enumeration.txt
@@ -0,0 +1,4 @@
+true
+true
+true
+3px
diff --git a/Tests/LibWeb/Text/input/css/css-style-properties-enumeration.html b/Tests/LibWeb/Text/input/css/css-style-properties-enumeration.html
new file mode 100644
index 00000000000..c4000d6b7df
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/css-style-properties-enumeration.html
@@ -0,0 +1,14 @@
+<!doctype html>
+<script src="../include.js"></script>
+<script>
+ test(() => {
+ const style = document.createElement("div").style;
+ const names = new Set();
+ for (const name in style)
+ names.add(name);
+ for (const name of ["color", "marginLeft", "margin-left"])
+ println(names.has(name));
+ style.marginLeft = "3px";
+ println(style.getPropertyValue("margin-left"));
+ });
+</script>