@@ -657,11 +657,35 @@ bool Object::put_own_property(const StringOrSymbol& property_name, Value value,
657
657
VERIFY (metadata.has_value ());
658
658
}
659
659
660
- if (!new_property && mode == PutOwnPropertyMode::DefineProperty && !metadata.value ().attributes .is_configurable () && attributes != metadata.value ().attributes ) {
661
- dbgln_if (OBJECT_DEBUG, " Disallow reconfig of non-configurable property" );
662
- if (throw_exceptions)
663
- vm ().throw_exception <TypeError>(global_object (), ErrorType::DescChangeNonConfigurable, property_name.to_display_string ());
664
- return false ;
660
+ auto value_here = m_storage[metadata.value ().offset ];
661
+ if (!new_property && mode == PutOwnPropertyMode::DefineProperty && !metadata.value ().attributes .is_configurable ()) {
662
+ if ((attributes.has_configurable () && attributes.is_configurable ()) || (attributes.has_enumerable () && attributes.is_enumerable () != metadata.value ().attributes .is_enumerable ())) {
663
+ dbgln_if (OBJECT_DEBUG, " Disallow reconfig of non-configurable property" );
664
+ if (throw_exceptions)
665
+ vm ().throw_exception <TypeError>(global_object (), ErrorType::DescChangeNonConfigurable, property_name.to_display_string ());
666
+ return false ;
667
+ }
668
+
669
+ if (value_here.is_accessor () != value.is_accessor ()) {
670
+ dbgln_if (OBJECT_DEBUG, " Disallow reconfig of non-configurable property" );
671
+ if (throw_exceptions)
672
+ vm ().throw_exception <TypeError>(global_object (), ErrorType::DescChangeNonConfigurable, property_name.to_display_string ());
673
+ return false ;
674
+ }
675
+
676
+ if (!value_here.is_accessor () && !metadata.value ().attributes .is_writable () && ((attributes.has_writable () && attributes.is_writable ()) || (!value.is_empty () && !same_value (value, value_here)))) {
677
+ dbgln_if (OBJECT_DEBUG, " Disallow reconfig of non-configurable property" );
678
+ if (throw_exceptions)
679
+ vm ().throw_exception <TypeError>(global_object (), ErrorType::DescChangeNonConfigurable, property_name.to_display_string ());
680
+ return false ;
681
+ }
682
+
683
+ if (value_here.is_accessor () && ((attributes.has_setter () && value.as_accessor ().setter () != value_here.as_accessor ().setter ()) || (attributes.has_getter () && value.as_accessor ().getter () != value_here.as_accessor ().getter ()))) {
684
+ dbgln_if (OBJECT_DEBUG, " Disallow reconfig of non-configurable property" );
685
+ if (throw_exceptions)
686
+ vm ().throw_exception <TypeError>(global_object (), ErrorType::DescChangeNonConfigurable, property_name.to_display_string ());
687
+ return false ;
688
+ }
665
689
}
666
690
667
691
if (mode == PutOwnPropertyMode::DefineProperty && attributes != metadata.value ().attributes ) {
@@ -675,7 +699,6 @@ bool Object::put_own_property(const StringOrSymbol& property_name, Value value,
675
699
dbgln_if (OBJECT_DEBUG, " Reconfigured property {}, new shape says offset is {} and my storage capacity is {}" , property_name.to_display_string (), metadata.value ().offset , m_storage.size ());
676
700
}
677
701
678
- auto value_here = m_storage[metadata.value ().offset ];
679
702
if (!new_property && mode == PutOwnPropertyMode::Put && !value_here.is_accessor () && !metadata.value ().attributes .is_writable ()) {
680
703
dbgln_if (OBJECT_DEBUG, " Disallow write to non-writable property" );
681
704
if (throw_exceptions && vm ().in_strict_mode ())
0 commit comments