LibWeb/HTML: Port Window.frames to IDL

This commit is contained in:
Linus Groh 2023-03-05 18:48:45 +00:00
parent 437a7c977e
commit dcff775ab1
Notes: sideshowbarker 2024-07-17 09:39:38 +09:00
3 changed files with 12 additions and 11 deletions

View file

@ -1092,7 +1092,6 @@ WebIDL::ExceptionOr<void> Window::initialize_web_interfaces(Badge<WindowEnvironm
// FIXME: These should be native accessors, not properties
define_native_accessor(realm, "top", top_getter, nullptr, JS::Attribute::Enumerable);
define_native_accessor(realm, "frames", frames_getter, {}, JS::Attribute::Enumerable);
define_native_accessor(realm, "parent", parent_getter, {}, JS::Attribute::Enumerable);
define_native_accessor(realm, "document", document_getter, {}, JS::Attribute::Enumerable);
define_native_accessor(realm, "frameElement", frame_element_getter, {}, JS::Attribute::Enumerable);
@ -1216,6 +1215,13 @@ JS::NonnullGCPtr<WindowProxy> Window::self() const
return verify_cast<WindowProxy>(relevant_realm(*this).global_environment().global_this_value());
}
// https://html.spec.whatwg.org/multipage/window-object.html#dom-frames
JS::NonnullGCPtr<WindowProxy> Window::frames() const
{
// The window, frames, and self getter steps are to return this's relevant realm.[[GlobalEnv]].[[GlobalThisValue]].
return verify_cast<WindowProxy>(relevant_realm(*this).global_environment().global_this_value());
}
// https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator
JS::NonnullGCPtr<Navigator> Window::navigator() const
{
@ -1536,14 +1542,6 @@ JS_DEFINE_NATIVE_FUNCTION(Window::top_getter)
return browsing_context->top_level_browsing_context().window_proxy();
}
// https://html.spec.whatwg.org/multipage/window-object.html#dom-frames
JS_DEFINE_NATIVE_FUNCTION(Window::frames_getter)
{
auto* impl = TRY(impl_from(vm));
// The window, frames, and self getter steps are to return this's relevant realm.[[GlobalEnv]].[[GlobalThisValue]].
return &relevant_realm(*impl).global_environment().global_this_value();
}
JS_DEFINE_NATIVE_FUNCTION(Window::parent_getter)
{
auto* impl = TRY(impl_from(vm));

View file

@ -143,6 +143,8 @@ public:
JS::NonnullGCPtr<WindowProxy> window() const;
JS::NonnullGCPtr<WindowProxy> self() const;
JS::NonnullGCPtr<WindowProxy> frames() const;
JS::NonnullGCPtr<Navigator> navigator() const;
void alert(String const& message = {});
@ -243,8 +245,6 @@ private:
JS_DECLARE_NATIVE_FUNCTION(inner_width_getter);
JS_DECLARE_NATIVE_FUNCTION(inner_height_getter);
JS_DECLARE_NATIVE_FUNCTION(frames_getter);
JS_DECLARE_NATIVE_FUNCTION(parent_getter);
JS_DECLARE_NATIVE_FUNCTION(device_pixel_ratio_getter);

View file

@ -9,6 +9,9 @@ interface Window : EventTarget {
[LegacyUnforgeable] readonly attribute WindowProxy window;
[Replaceable] readonly attribute WindowProxy self;
// other browsing contexts
[Replaceable] readonly attribute WindowProxy frames;
// the user agent
readonly attribute Navigator navigator;
[ImplementedAs=navigator] readonly attribute Navigator clientInformation; // legacy alias of .navigator