LibWeb: Stub out missing cross origin properties on the window object

Previously, trying to access the `close`, `closed` or `blur` properties
on a cross origin window would cause a crash.
This commit is contained in:
Tim Ledbetter 2024-03-30 10:04:31 +00:00 committed by Andreas Kling
commit 3876875bd8
Notes: sideshowbarker 2024-07-17 18:23:22 +09:00
5 changed files with 63 additions and 0 deletions

View file

@ -874,6 +874,21 @@ String Window::status() const
return m_status;
}
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-window-close
void Window::close()
{
// FIXME: Implement this properly
dbgln("(STUBBED) Window::close()");
}
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-window-closed
bool Window::closed() const
{
// FIXME: Implement this properly
dbgln("(STUBBED) Window::closed");
return false;
}
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-window-status
void Window::set_status(String const& status)
{
@ -918,6 +933,12 @@ void Window::focus()
// indicate to the user that the page is attempting to gain focus.
}
// https://html.spec.whatwg.org/multipage/interaction.html#dom-window-blur
void Window::blur()
{
// The blur() method steps are to do nothing.
}
// https://html.spec.whatwg.org/multipage/window-object.html#dom-frames
JS::NonnullGCPtr<WindowProxy> Window::frames() const
{

View file

@ -135,11 +135,14 @@ public:
String name() const;
void set_name(String const&);
String status() const;
void close();
bool closed() const;
void set_status(String const&);
[[nodiscard]] JS::NonnullGCPtr<Location> location();
JS::NonnullGCPtr<History> history() const;
JS::NonnullGCPtr<Navigation> navigation();
void focus();
void blur();
JS::NonnullGCPtr<WindowProxy> frames() const;
u32 length();

View file

@ -24,11 +24,14 @@ interface Window : EventTarget {
[LegacyUnforgeable] readonly attribute Document document;
attribute DOMString name;
attribute DOMString status;
undefined close();
readonly attribute boolean closed;
[PutForwards=href, LegacyUnforgeable] readonly attribute Location location;
readonly attribute History history;
readonly attribute Navigation navigation;
readonly attribute CustomElementRegistry customElements;
undefined focus();
undefined blur();
// other browsing contexts
[Replaceable] readonly attribute WindowProxy frames;