1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:08:10 +00:00

LibWeb/HTML: Port Window.navigator to IDL

This commit is contained in:
Linus Groh 2023-03-05 17:55:03 +00:00
parent c219e6d9c1
commit eb2425040b
3 changed files with 14 additions and 11 deletions

View file

@ -1160,9 +1160,6 @@ WebIDL::ExceptionOr<void> Window::initialize_web_interfaces(Badge<WindowEnvironm
// Legacy
define_native_accessor(realm, "event", event_getter, event_setter, JS::Attribute::Enumerable);
define_native_accessor(realm, "navigator", navigator_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable);
define_native_accessor(realm, "clientInformation", navigator_getter, {}, JS::Attribute::Enumerable | JS::Attribute::Configurable);
// NOTE: location is marked as [LegacyUnforgeable], meaning it isn't configurable.
define_native_accessor(realm, "location", location_getter, location_setter, JS::Attribute::Enumerable);
@ -1207,6 +1204,13 @@ static JS::ThrowCompletionOr<HTML::Window*> impl_from(JS::VM& vm)
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "Window");
}
// https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator
JS::NonnullGCPtr<Navigator> Window::navigator() const
{
// The navigator and clientInformation getter steps are to return this's associated Navigator.
return *m_navigator;
}
// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-alert
void Window::alert(String const& message)
{
@ -1912,10 +1916,4 @@ JS_DEFINE_NATIVE_FUNCTION(Window::name_setter)
return JS::js_undefined();
}
JS_DEFINE_NATIVE_FUNCTION(Window::navigator_getter)
{
auto* impl = TRY(impl_from(vm));
return impl->m_navigator;
}
}