1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 20:47:45 +00:00

LibJS: Guard IntegerIndexedElementSet with receiver check

This is a normative change in the ECMA-262 spec. See:
3620f11
This commit is contained in:
Timothy Flynn 2022-08-25 13:50:58 -04:00 committed by Linus Groh
parent a803d9226f
commit 6309b8773d
2 changed files with 42 additions and 4 deletions

View file

@ -359,3 +359,34 @@ TYPED_ARRAYS.forEach(T => {
expectValueNotSet("1e-10");
});
});
test("source is the same value as the receiver", () => {
TYPED_ARRAYS.forEach(T => {
let target = new T([1, 2]);
target[0] = 3;
expect(target[0]).toBe(3);
});
});
test("source is not the same value as the receiver", () => {
TYPED_ARRAYS.forEach(T => {
let target = new T([1, 2]);
let receiver = Object.create(target);
receiver[0] = 3;
expect(target[0]).toBe(1);
expect(receiver[0]).toBe(3);
});
});
test("source is not the same value as the receiver, and the index is invalid", () => {
TYPED_ARRAYS.forEach(T => {
let target = new T([1, 2]);
let receiver = Object.create(target);
receiver[2] = 3;
expect(target[2]).toBeUndefined();
expect(receiver[2]).toBeUndefined();
});
});