diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp index 9bdce54c0e..d2eb79a7bc 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp @@ -3187,16 +3187,27 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@attribute.setter_callback@) } )~~~"); } else if (attribute.extended_attributes.contains("Replaceable"sv)) { - if (interface.name.is_one_of("Window")) { + if (interface.name == "Window"sv) { attribute_generator.append(R"~~~( JS_DEFINE_NATIVE_FUNCTION(@class_name@::@attribute.setter_callback@) { auto this_value = vm.this_value(); - if (!this_value.is_object() || !is(this_value.as_object())) - return vm.throw_completion(JS::ErrorType::NotAnObjectOfType, "@namespaced_name@"); - auto& window_proxy = static_cast(this_value.as_object()); - TRY(window_proxy.window()->internal_define_own_property("@attribute.name@", JS::PropertyDescriptor { .value = vm.argument(0), .writable = true })); - return JS::js_undefined(); + JS::GCPtr window; + if (this_value.is_object()) { + if (is(this_value.as_object())) { + auto& window_proxy = static_cast(this_value.as_object()); + window = window_proxy.window(); + } else if (is(this_value.as_object())) { + window = &static_cast(this_value.as_object()); + } + } + + if (window) { + TRY(window->internal_define_own_property("@attribute.name@", JS::PropertyDescriptor { .value = vm.argument(0), .writable = true })); + return JS::js_undefined(); + } + + return vm.throw_completion(JS::ErrorType::NotAnObjectOfType, "@namespaced_name@"); } )~~~"); } else { diff --git a/Tests/LibWeb/Text/expected/global-performance-property.txt b/Tests/LibWeb/Text/expected/global-performance-property.txt new file mode 100644 index 0000000000..7ef22e9a43 --- /dev/null +++ b/Tests/LibWeb/Text/expected/global-performance-property.txt @@ -0,0 +1 @@ +PASS diff --git a/Tests/LibWeb/Text/input/global-performance-property.html b/Tests/LibWeb/Text/input/global-performance-property.html new file mode 100644 index 0000000000..7641d2f221 --- /dev/null +++ b/Tests/LibWeb/Text/input/global-performance-property.html @@ -0,0 +1,9 @@ + +