summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2023-03-11 17:28:42 +0000
committerLinus Groh <mail@linusgroh.de>2023-03-11 17:32:07 +0000
commit22552382ffcd348bf9d79b00036d1fb882162d57 (patch)
treedb46fe2d715f607139281a0ddcadebb9ee30c452
parentbe0dcd465f3308bfb4221f11dd56900c78eacf10 (diff)
downloadserenity-22552382ffcd348bf9d79b00036d1fb882162d57.zip
LibWeb/HTML: Use CreateMethodProperty for Window namespace properties
This makes sure the property attributes are correct (writable and configurable), which they currently aren't for either CSS or WebAssembly.
-rw-r--r--Userland/Libraries/LibWeb/HTML/Window.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/Window.cpp b/Userland/Libraries/LibWeb/HTML/Window.cpp
index 30db5318f2..a115d8aecc 100644
--- a/Userland/Libraries/LibWeb/HTML/Window.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Window.cpp
@@ -870,15 +870,18 @@ WebIDL::ExceptionOr<void> Window::initialize_web_interfaces(Badge<WindowEnvironm
define_native_function(realm, "clearInterval", clear_interval, 1, attr);
define_native_function(realm, "clearTimeout", clear_timeout, 1, attr);
- define_direct_property("CSS", MUST_OR_THROW_OOM(heap().allocate<Bindings::CSSNamespace>(realm, realm)), 0);
+ // https://webidl.spec.whatwg.org/#define-the-global-property-references
+ // 5. For every namespace namespace that is exposed in realm:
+ // 1. Let id be namespace’s identifier.
+ // 3. Let namespaceObject be the result of creating a namespace object for namespace in realm.
+ // 3. Perform CreateMethodProperty(target, id, namespaceObject).
+ create_method_property("CSS", MUST_OR_THROW_OOM(heap().allocate<Bindings::CSSNamespace>(realm, realm)));
+ create_method_property("WebAssembly", MUST_OR_THROW_OOM(heap().allocate<Bindings::WebAssemblyObject>(realm, realm)));
// FIXME: Implement codegen for readonly properties with [PutForwards]
auto& location_accessor = storage_get("location")->value.as_accessor();
location_accessor.set_setter(JS::NativeFunction::create(realm, location_setter, 1, "location", &realm, {}, "set"sv));
- // WebAssembly "namespace"
- define_direct_property("WebAssembly", MUST_OR_THROW_OOM(heap().allocate<Bindings::WebAssemblyObject>(realm, realm)), JS::Attribute::Enumerable | JS::Attribute::Configurable);
-
return {};
}