diff options
author | Linus Groh <mail@linusgroh.de> | 2021-06-11 00:22:53 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-06-11 00:23:13 +0100 |
commit | f218a4b5488aeec968153c5e3f70c7449dd95427 (patch) | |
tree | 533bb89e2cf1bc5aff8576d5584d75f223d92111 /Userland/Libraries/LibJS/Runtime/Error.cpp | |
parent | 0e38c9b2f76bc4877dec7447b700c5651f181ace (diff) | |
download | serenity-f218a4b5488aeec968153c5e3f70c7449dd95427.zip |
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).
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/Error.cpp')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Error.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
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<Error>(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<ClassName>(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; \ } \ \ |