mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:37:45 +00:00
LibWeb: Implement window.location.origin
This commit is contained in:
parent
0b7f5bbdfb
commit
de494ccf38
2 changed files with 13 additions and 0 deletions
|
@ -50,6 +50,7 @@ void LocationObject::initialize(JS::Realm& realm)
|
|||
define_native_accessor(realm, "search", search_getter, {}, attr);
|
||||
define_native_accessor(realm, "protocol", protocol_getter, {}, attr);
|
||||
define_native_accessor(realm, "port", port_getter, {}, attr);
|
||||
define_native_accessor(realm, "origin", origin_getter, {}, attr);
|
||||
|
||||
define_native_function(realm, "reload", reload, 0, JS::Attribute::Enumerable);
|
||||
define_native_function(realm, "replace", replace, 1, JS::Attribute::Enumerable);
|
||||
|
@ -222,6 +223,17 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::port_getter)
|
|||
return JS::js_string(vm, String::number(*location_object->url().port()));
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-location-origin
|
||||
JS_DEFINE_NATIVE_FUNCTION(LocationObject::origin_getter)
|
||||
{
|
||||
auto* location_object = TRY(typed_this_value(vm));
|
||||
|
||||
// FIXME: 1. If this's relevant Document is non-null and its origin is not same origin-domain with the entry settings object's origin, then throw a "SecurityError" DOMException.
|
||||
|
||||
// 2. Return the serialization of this's url's origin.
|
||||
return JS::js_string(vm, location_object->url().serialize_origin());
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/history.html#dom-location-reload
|
||||
JS_DEFINE_NATIVE_FUNCTION(LocationObject::reload)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue