/* * Copyright (c) 2022, Linus Groh * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include namespace Web::Bindings { class WindowProxy final : public JS::Object { JS_OBJECT(WindowProxy, JS::Object); public: WindowProxy(JS::GlobalObject&, WindowObject&); virtual ~WindowProxy() override = default; virtual JS::ThrowCompletionOr internal_get_prototype_of() const override; virtual JS::ThrowCompletionOr internal_set_prototype_of(Object* prototype) override; virtual JS::ThrowCompletionOr internal_is_extensible() const override; virtual JS::ThrowCompletionOr internal_prevent_extensions() override; virtual JS::ThrowCompletionOr> internal_get_own_property(JS::PropertyKey const&) const override; virtual JS::ThrowCompletionOr internal_define_own_property(JS::PropertyKey const&, JS::PropertyDescriptor const&) override; virtual JS::ThrowCompletionOr internal_get(JS::PropertyKey const&, JS::Value receiver) const override; virtual JS::ThrowCompletionOr internal_set(JS::PropertyKey const&, JS::Value value, JS::Value receiver) override; virtual JS::ThrowCompletionOr internal_delete(JS::PropertyKey const&) override; virtual JS::ThrowCompletionOr> internal_own_property_keys() const override; WindowObject& window() { return *m_window; } WindowObject const& window() const { return *m_window; } // NOTE: Someone will have to replace the wrapped window object as well: // "When the browsing context is navigated, the Window object wrapped by the browsing context's associated WindowProxy object is changed." // I haven't found where that actually happens yet. Make sure to use a Badge guarded setter. private: virtual void visit_edges(JS::Cell::Visitor&) override; // [[Window]], https://html.spec.whatwg.org/multipage/window-object.html#concept-windowproxy-window WindowObject* m_window { nullptr }; }; }