From e0a135e46ae1a85063eed6b73a602e557994f961 Mon Sep 17 00:00:00 2001 From: tofpie <75836434+tofpie@users.noreply.github.com> Date: Fri, 1 Jan 2021 23:25:04 +0100 Subject: [PATCH] Fix attributes on properties of functions and constructors (#1023) Co-authored-by: tofpie --- boa/src/builtins/function/mod.rs | 15 +++++++++------ boa/src/object/mod.rs | 6 +++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/boa/src/builtins/function/mod.rs b/boa/src/builtins/function/mod.rs index 286666ff16..8907ac2c98 100644 --- a/boa/src/builtins/function/mod.rs +++ b/boa/src/builtins/function/mod.rs @@ -237,12 +237,15 @@ pub fn make_builtin_fn( .prototype() .into(), ); - function.insert_property("length", length, Attribute::all()); - - parent - .as_object() - .unwrap() - .insert_property(name, function, Attribute::all()); + let attribute = Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE; + function.insert_property("length", length, attribute); + function.insert_property("name", name.as_str(), attribute); + + parent.as_object().unwrap().insert_property( + name, + function, + Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE, + ); } #[derive(Debug, Clone, Copy)] diff --git a/boa/src/object/mod.rs b/boa/src/object/mod.rs index 08c30a5beb..f34e68ec47 100644 --- a/boa/src/object/mod.rs +++ b/boa/src/object/mod.rs @@ -701,7 +701,7 @@ impl<'context> FunctionBuilder<'context> { .prototype() .into(), ); - let attribute = Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::PERMANENT; + let attribute = Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE; if let Some(name) = self.name.take() { function.insert_property("name", name, attribute); } else { @@ -1014,11 +1014,11 @@ impl<'context> ConstructorBuilder<'context> { let length = DataDescriptor::new( self.length, - Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::PERMANENT, + Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE, ); let name = DataDescriptor::new( self.name.take().unwrap_or_else(|| String::from("[object]")), - Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::PERMANENT, + Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE, ); {