diff options
author | davidot <davidot@serenityos.org> | 2021-10-14 02:06:53 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-10-15 10:27:16 +0100 |
commit | 021691753df3fa87e0e538c7d41c7534fc020dba (patch) | |
tree | 5e18f4a060227a0e074121ecb62b3a85d645595d /Userland/Libraries/LibJS/Runtime | |
parent | 1c7c53e5a07b090a32cb726f27fa0d1d7491a0eb (diff) | |
download | serenity-021691753df3fa87e0e538c7d41c7534fc020dba.zip |
LibJS: Fix that proxy always said that it had a [[Construct]] slot
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/ProxyObject.cpp | 10 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/ProxyObject.h | 2 |
2 files changed, 11 insertions, 1 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp index 7181b0aa9b..8953a2c0ca 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ProxyObject.cpp @@ -799,6 +799,16 @@ ThrowCompletionOr<Value> ProxyObject::internal_call(Value this_argument, MarkedV return call(global_object, trap, &m_handler, &m_target, this_argument, arguments_array); } +bool ProxyObject::has_constructor() const +{ + // Note: A Proxy exotic object only has a [[Construct]] internal method if the initial value of + // its [[ProxyTarget]] internal slot is an object that has a [[Construct]] internal method. + if (!is_function()) + return false; + + return static_cast<FunctionObject&>(m_target).has_constructor(); +} + // 10.5.13 [[Construct]] ( argumentsList, newTarget ), https://tc39.es/ecma262/#sec-proxy-object-internal-methods-and-internal-slots-construct-argumentslist-newtarget ThrowCompletionOr<Object*> ProxyObject::internal_construct(MarkedValueList arguments_list, FunctionObject& new_target) { diff --git a/Userland/Libraries/LibJS/Runtime/ProxyObject.h b/Userland/Libraries/LibJS/Runtime/ProxyObject.h index f8aebcf77f..6a72dd73db 100644 --- a/Userland/Libraries/LibJS/Runtime/ProxyObject.h +++ b/Userland/Libraries/LibJS/Runtime/ProxyObject.h @@ -22,7 +22,7 @@ public: virtual ~ProxyObject() override; virtual const FlyString& name() const override; - virtual bool has_constructor() const override { return true; } + virtual bool has_constructor() const override; const Object& target() const { return m_target; } const Object& handler() const { return m_handler; } |