mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 21:17:45 +00:00
LibWeb: Expose the location object via Document.location
Both Window.location and Document.location use the same instance of the Location object. Some sites use it via Window, some via Document.
This commit is contained in:
parent
ee5bac0891
commit
678dd2d180
6 changed files with 34 additions and 1 deletions
|
@ -92,8 +92,12 @@ void WindowObject::initialize_global_object()
|
|||
// Legacy
|
||||
define_native_accessor("event", event_getter, event_setter, JS::Attribute::Enumerable);
|
||||
|
||||
m_location_object = heap().allocate<LocationObject>(*this, *this);
|
||||
|
||||
define_direct_property("navigator", heap().allocate<NavigatorObject>(*this, *this), JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
define_direct_property("location", heap().allocate<LocationObject>(*this, *this), JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
|
||||
// NOTE: location is marked as [LegacyUnforgeable], meaning it isn't configurable.
|
||||
define_direct_property("location", m_location_object, JS::Attribute::Enumerable);
|
||||
|
||||
// WebAssembly "namespace"
|
||||
define_direct_property("WebAssembly", heap().allocate<WebAssemblyObject>(*this, *this), JS::Attribute::Enumerable | JS::Attribute::Configurable);
|
||||
|
@ -108,6 +112,7 @@ WindowObject::~WindowObject()
|
|||
void WindowObject::visit_edges(Visitor& visitor)
|
||||
{
|
||||
GlobalObject::visit_edges(visitor);
|
||||
visitor.visit(m_location_object);
|
||||
for (auto& it : m_prototypes)
|
||||
visitor.visit(it.value);
|
||||
for (auto& it : m_constructors)
|
||||
|
|
|
@ -30,6 +30,9 @@ public:
|
|||
|
||||
Origin origin() const;
|
||||
|
||||
LocationObject* location_object() { return m_location_object; }
|
||||
LocationObject const* location_object() const { return m_location_object; }
|
||||
|
||||
JS::Object* web_prototype(const String& class_name) { return m_prototypes.get(class_name).value_or(nullptr); }
|
||||
JS::NativeFunction* web_constructor(const String& class_name) { return m_constructors.get(class_name).value_or(nullptr); }
|
||||
|
||||
|
@ -96,6 +99,8 @@ private:
|
|||
|
||||
NonnullRefPtr<DOM::Window> m_impl;
|
||||
|
||||
LocationObject* m_location_object;
|
||||
|
||||
HashMap<String, JS::Object*> m_prototypes;
|
||||
HashMap<String, JS::NativeFunction*> m_constructors;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue