From 4bd089616e418ddb035b997c36e830d6a8b5b062 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Mon, 4 Oct 2021 20:39:17 +0300 Subject: [PATCH] LibWeb: Implement window.location's stringifier The location IDL interface includes a stringifier on the href attribute i.e. the object's toString should return the value of the href attribute. --- Userland/Libraries/LibWeb/Bindings/LocationObject.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp b/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp index 6573383e93..f09f1778ce 100644 --- a/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp +++ b/Userland/Libraries/LibWeb/Bindings/LocationObject.cpp @@ -21,6 +21,8 @@ LocationObject::LocationObject(JS::GlobalObject& global_object) void LocationObject::initialize(JS::GlobalObject& global_object) { + auto& vm = global_object.vm(); + Object::initialize(global_object); u8 attr = JS::Attribute::Writable | JS::Attribute::Enumerable; define_native_accessor("href", href_getter, href_setter, attr); @@ -34,6 +36,8 @@ void LocationObject::initialize(JS::GlobalObject& global_object) define_native_function("reload", reload, 0, JS::Attribute::Enumerable); define_native_function("replace", replace, 1, JS::Attribute::Enumerable); + + define_native_function(vm.names.toString, href_getter, 0, JS::Attribute::Enumerable); } LocationObject::~LocationObject()