mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:57:45 +00:00
LibWeb: Implement some custom JS internal overrides for Location
As required by the spec. Note that this isn't the full suite of overrides.
This commit is contained in:
parent
7991077284
commit
ee5bac0891
2 changed files with 27 additions and 2 deletions
|
@ -11,8 +11,7 @@
|
||||||
#include <LibWeb/DOM/Document.h>
|
#include <LibWeb/DOM/Document.h>
|
||||||
#include <LibWeb/DOM/Window.h>
|
#include <LibWeb/DOM/Window.h>
|
||||||
|
|
||||||
namespace Web {
|
namespace Web::Bindings {
|
||||||
namespace Bindings {
|
|
||||||
|
|
||||||
LocationObject::LocationObject(JS::GlobalObject& global_object)
|
LocationObject::LocationObject(JS::GlobalObject& global_object)
|
||||||
: Object(*global_object.object_prototype())
|
: Object(*global_object.object_prototype())
|
||||||
|
@ -118,6 +117,25 @@ JS_DEFINE_NATIVE_FUNCTION(LocationObject::reload)
|
||||||
return JS::js_undefined();
|
return JS::js_undefined();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/history.html#location-setprototypeof
|
||||||
|
bool LocationObject::internal_set_prototype_of(Object* prototype)
|
||||||
|
{
|
||||||
|
// 1. Return ! SetImmutablePrototype(this, V).
|
||||||
|
return set_immutable_prototype(prototype);
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/history.html#location-isextensible
|
||||||
|
bool LocationObject::internal_is_extensible() const
|
||||||
|
{
|
||||||
|
// 1. Return true.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/history.html#location-preventextensions
|
||||||
|
bool LocationObject::internal_prevent_extensions()
|
||||||
|
{
|
||||||
|
// 1. Return false.
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,13 @@ public:
|
||||||
virtual void initialize(JS::GlobalObject&) override;
|
virtual void initialize(JS::GlobalObject&) override;
|
||||||
virtual ~LocationObject() override;
|
virtual ~LocationObject() override;
|
||||||
|
|
||||||
|
virtual bool internal_set_prototype_of(Object* prototype) override;
|
||||||
|
virtual bool internal_is_extensible() const override;
|
||||||
|
virtual bool internal_prevent_extensions() override;
|
||||||
|
|
||||||
|
// FIXME: There should also be a custom [[GetPrototypeOf]], [[GetOwnProperty]], [[DefineOwnProperty]], [[Get]], [[Set]], [[Delete]] and [[OwnPropertyKeys]],
|
||||||
|
// but we don't have the infrastructure in place to implement them yet.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
JS_DECLARE_NATIVE_FUNCTION(reload);
|
JS_DECLARE_NATIVE_FUNCTION(reload);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue