From f218a4b5488aeec968153c5e3f70c7449dd95427 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Fri, 11 Jun 2021 00:22:53 +0100 Subject: LibJS: Set Error message attributes to writable and configurable only 20.5.1.1 Error ( message ) When the Error function is called with argument message, the following steps are taken: [...] 3b. Let msgDesc be the PropertyDescriptor { [[Value]]: msg, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }. 3c. Perform ! DefinePropertyOrThrow(O, "message", msgDesc). --- Userland/Libraries/LibJS/Runtime/Error.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'Userland/Libraries/LibJS/Runtime/Error.cpp') diff --git a/Userland/Libraries/LibJS/Runtime/Error.cpp b/Userland/Libraries/LibJS/Runtime/Error.cpp index 04a4d5ec04..88cc732e7e 100644 --- a/Userland/Libraries/LibJS/Runtime/Error.cpp +++ b/Userland/Libraries/LibJS/Runtime/Error.cpp @@ -14,8 +14,10 @@ Error* Error::create(GlobalObject& global_object, const String& message) { auto& vm = global_object.vm(); auto* error = global_object.heap().allocate(global_object, *global_object.error_prototype()); - if (!message.is_null()) - error->define_property(vm.names.message, js_string(vm, message)); + if (!message.is_null()) { + u8 attr = Attribute::Writable | Attribute::Configurable; + error->define_property(vm.names.message, js_string(vm, message), attr); + } return error; } @@ -29,8 +31,10 @@ Error::Error(Object& prototype) { \ auto& vm = global_object.vm(); \ auto* error = global_object.heap().allocate(global_object, *global_object.snake_name##_prototype()); \ - if (!message.is_null()) \ - error->define_property(vm.names.message, js_string(vm, message)); \ + if (!message.is_null()) { \ + u8 attr = Attribute::Writable | Attribute::Configurable; \ + error->define_property(vm.names.message, js_string(vm, message), attr); \ + } \ return error; \ } \ \ -- cgit v1.2.3