mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:27:34 +00:00
LibWeb: Add origin property to window object
This commit is contained in:
parent
39f92fa131
commit
f0f2009170
3 changed files with 35 additions and 0 deletions
|
@ -115,6 +115,7 @@ void WindowObject::initialize_global_object()
|
|||
define_direct_property("CSS", heap().allocate<CSSNamespace>(*this, *this), 0);
|
||||
|
||||
define_native_accessor("localStorage", local_storage_getter, {}, attr);
|
||||
define_native_accessor("origin", origin_getter, {}, attr);
|
||||
|
||||
// Legacy
|
||||
define_native_accessor("event", event_getter, event_setter, JS::Attribute::Enumerable);
|
||||
|
@ -651,6 +652,13 @@ JS_DEFINE_NATIVE_FUNCTION(WindowObject::post_message)
|
|||
return JS::js_undefined();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#dom-origin
|
||||
JS_DEFINE_NATIVE_FUNCTION(WindowObject::origin_getter)
|
||||
{
|
||||
auto* impl = TRY(impl_from(vm, global_object));
|
||||
return JS::js_string(vm, impl->associated_document().origin().serialize());
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(WindowObject::local_storage_getter)
|
||||
{
|
||||
auto* impl = TRY(impl_from(vm, global_object));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue