mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibWeb: Define window.isSecureContext
This commit is contained in:
parent
f7fe9e3355
commit
204257526c
Notes:
sideshowbarker
2024-07-17 01:34:17 +09:00
Author: https://github.com/cammo1123 Commit: https://github.com/SerenityOS/serenity/commit/204257526c Pull-request: https://github.com/SerenityOS/serenity/pull/17074 Reviewed-by: https://github.com/linusg
2 changed files with 10 additions and 0 deletions
|
@ -1137,6 +1137,7 @@ void Window::initialize_web_interfaces(Badge<WindowEnvironmentSettingsObject>)
|
|||
define_native_accessor(realm, "localStorage", local_storage_getter, {}, attr);
|
||||
define_native_accessor(realm, "sessionStorage", session_storage_getter, {}, attr);
|
||||
define_native_accessor(realm, "origin", origin_getter, {}, attr);
|
||||
define_native_accessor(realm, "isSecureContext", is_secure_context_getter, {}, attr);
|
||||
|
||||
// Legacy
|
||||
define_native_accessor(realm, "event", event_getter, event_setter, JS::Attribute::Enumerable);
|
||||
|
@ -1863,6 +1864,14 @@ JS_DEFINE_NATIVE_FUNCTION(Window::origin_getter)
|
|||
return JS::PrimitiveString::create(vm, impl->associated_document().origin().serialize());
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#dom-issecurecontext
|
||||
JS_DEFINE_NATIVE_FUNCTION(Window::is_secure_context_getter)
|
||||
{
|
||||
auto* impl = TRY(impl_from(vm));
|
||||
// The isSecureContext getter steps are to return true if this's relevant settings object is a secure context, or false otherwise.
|
||||
return JS::Value(is_secure_context(impl->associated_document().relevant_settings_object()));
|
||||
}
|
||||
|
||||
JS_DEFINE_NATIVE_FUNCTION(Window::local_storage_getter)
|
||||
{
|
||||
auto* impl = TRY(impl_from(vm));
|
||||
|
|
|
@ -247,6 +247,7 @@ private:
|
|||
JS_DECLARE_NATIVE_FUNCTION(local_storage_getter);
|
||||
JS_DECLARE_NATIVE_FUNCTION(session_storage_getter);
|
||||
JS_DECLARE_NATIVE_FUNCTION(origin_getter);
|
||||
JS_DECLARE_NATIVE_FUNCTION(is_secure_context_getter);
|
||||
|
||||
JS_DECLARE_NATIVE_FUNCTION(open);
|
||||
JS_DECLARE_NATIVE_FUNCTION(alert);
|
||||
|
|
Loading…
Reference in a new issue