Commit 3f0b0070 authored by Z Duong Nguyen-Huu's avatar Z Duong Nguyen-Huu Committed by Commit Bot

Fix Object.defineProperty for sealed object with unchanged value

It should work when Object.defineProperty is used to set a new value for seal object.
Add more test to cover this case as well.

Bug: chromium:951374
Change-Id: Idbbcc052b627587c71d5b5252340130d0fdfd595
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1562470Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Z Nguyen-Huu <duongn@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#60786}
parent caec0441
......@@ -331,7 +331,8 @@ MapUpdater::State MapUpdater::FindRootMap() {
// the seal transitions), so change {to_kind} accordingly.
DCHECK(to_kind == DICTIONARY_ELEMENTS ||
to_kind == SLOW_STRING_WRAPPER_ELEMENTS ||
IsFixedTypedArrayElementsKind(to_kind));
IsFixedTypedArrayElementsKind(to_kind) ||
IsFrozenOrSealedElementsKind(to_kind));
to_kind = integrity_source_map_->elements_kind();
}
......
......@@ -517,3 +517,28 @@ assertFalse(Object.isFrozen(typedArray));
var typedArray = new Uint8Array(0);
Object.freeze(typedArray);
assertTrue(Object.isFrozen(typedArray));
// Test regression with Object.defineProperty
var obj = [];
obj.propertyA = 42;
obj[0] = true;
Object.freeze(obj);
assertThrows(function() {
Object.defineProperty(obj, 'propertyA', {
value: obj,
});
}, TypeError);
assertEquals(42, obj.propertyA);
assertThrows(function() {
Object.defineProperty(obj, 'propertyA', {
value: obj,
writable: false,
});
}, TypeError);
assertDoesNotThrow(function() {obj.propertyA = 2;});
assertEquals(obj.propertyA, 42);
assertThrows(function() {
Object.defineProperty(obj, 'abc', {
value: obj,
});
}, TypeError);
......@@ -493,3 +493,28 @@ assertTrue(%HasPackedElements(arr2));
Object.preventExtensions(arr2);
Object.seal(arr2);
testPackedSealedArray2(arr2);
// Test regression with Object.defineProperty
var obj = [];
obj.propertyA = 42;
obj[0] = true;
Object.seal(obj);
assertDoesNotThrow(function() {
Object.defineProperty(obj, 'propertyA', {
value: obj,
});
});
assertEquals(obj, obj.propertyA);
assertDoesNotThrow(function() {
Object.defineProperty(obj, 'propertyA', {
value: obj,
writable: false,
});
});
obj.propertyA = 42;
assertEquals(obj.propertyA, 42);
assertThrows(function() {
Object.defineProperty(obj, 'abc', {
value: obj,
});
}, TypeError);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment