mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 10:47:36 +00:00
LibWeb/HTML: Port Window.navigator to IDL
This commit is contained in:
parent
c219e6d9c1
commit
eb2425040b
3 changed files with 14 additions and 11 deletions
|
@ -1160,9 +1160,6 @@ WebIDL::ExceptionOr<void> Window::initialize_web_interfaces(Badge<WindowEnvironm
|
||||||
// Legacy
|
// Legacy
|
||||||
define_native_accessor(realm, "event", event_getter, event_setter, JS::Attribute::Enumerable);
|
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.
|
// NOTE: location is marked as [LegacyUnforgeable], meaning it isn't configurable.
|
||||||
define_native_accessor(realm, "location", location_getter, location_setter, JS::Attribute::Enumerable);
|
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");
|
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
|
// https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#dom-alert
|
||||||
void Window::alert(String const& message)
|
void Window::alert(String const& message)
|
||||||
{
|
{
|
||||||
|
@ -1912,10 +1916,4 @@ JS_DEFINE_NATIVE_FUNCTION(Window::name_setter)
|
||||||
return JS::js_undefined();
|
return JS::js_undefined();
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_DEFINE_NATIVE_FUNCTION(Window::navigator_getter)
|
|
||||||
{
|
|
||||||
auto* impl = TRY(impl_from(vm));
|
|
||||||
return impl->m_navigator;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,6 +140,8 @@ public:
|
||||||
Vector<JS::NonnullGCPtr<MimeType>> pdf_viewer_mime_type_objects();
|
Vector<JS::NonnullGCPtr<MimeType>> pdf_viewer_mime_type_objects();
|
||||||
|
|
||||||
// JS API functions
|
// JS API functions
|
||||||
|
JS::NonnullGCPtr<Navigator> navigator() const;
|
||||||
|
|
||||||
void alert(String const& message = {});
|
void alert(String const& message = {});
|
||||||
bool confirm(Optional<String> const& message);
|
bool confirm(Optional<String> const& message);
|
||||||
Optional<String> prompt(Optional<String> const& message, Optional<String> const& default_);
|
Optional<String> prompt(Optional<String> const& message, Optional<String> const& default_);
|
||||||
|
@ -288,8 +290,6 @@ private:
|
||||||
|
|
||||||
JS_DECLARE_NATIVE_FUNCTION(crypto_getter);
|
JS_DECLARE_NATIVE_FUNCTION(crypto_getter);
|
||||||
|
|
||||||
JS_DECLARE_NATIVE_FUNCTION(navigator_getter);
|
|
||||||
|
|
||||||
HTML::Location* m_location { nullptr };
|
HTML::Location* m_location { nullptr };
|
||||||
|
|
||||||
// [[CrossOriginPropertyDescriptorMap]], https://html.spec.whatwg.org/multipage/browsers.html#crossoriginpropertydescriptormap
|
// [[CrossOriginPropertyDescriptorMap]], https://html.spec.whatwg.org/multipage/browsers.html#crossoriginpropertydescriptormap
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
#import <DOM/EventHandler.idl>
|
#import <DOM/EventHandler.idl>
|
||||||
#import <DOM/EventTarget.idl>
|
#import <DOM/EventTarget.idl>
|
||||||
|
#import <HTML/Navigator.idl>
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#window
|
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#window
|
||||||
[Global=Window, Exposed=Window, LegacyUnenumerableNamedProperties, UseNewAKString]
|
[Global=Window, Exposed=Window, LegacyUnenumerableNamedProperties, UseNewAKString]
|
||||||
interface Window : EventTarget {
|
interface Window : EventTarget {
|
||||||
|
// the user agent
|
||||||
|
readonly attribute Navigator navigator;
|
||||||
|
[ImplementedAs=navigator] readonly attribute Navigator clientInformation; // legacy alias of .navigator
|
||||||
|
|
||||||
// user prompts
|
// user prompts
|
||||||
undefined alert();
|
undefined alert();
|
||||||
undefined alert(DOMString message);
|
undefined alert(DOMString message);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue