1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:18:12 +00:00

LibJS: Don't remove non-configurable items in Array when setting length

This commit is contained in:
davidot 2021-06-25 16:55:38 +02:00 committed by Linus Groh
parent c7aaf40a35
commit b38fb418f8
2 changed files with 31 additions and 2 deletions

View file

@ -44,4 +44,14 @@ describe("normal behavior", () => {
b.length = 0x80000001;
expect(b.length).toEqual(0x80000001);
});
test("should not remove non-configurable values", () => {
var a = [1, undefined, 3];
Object.defineProperty(a, 1, { configurable: false, value: 2 });
expect(a.length).toEqual(3);
expect((a.length = 1)).toEqual(1);
expect(a.length).toEqual(2);
expect(a[1]).toEqual(2);
});
});