LibJS: Prevent extensions of TypedArray exotic objects

This is a normative change in the ECMA-262 spec. See:
c1040ff
This commit is contained in:
Timothy Flynn 2024-11-29 13:28:55 -05:00 committed by Andreas Kling
commit 53a507303c
Notes: github-actions[bot] 2024-11-30 10:21:05 +00:00
3 changed files with 75 additions and 16 deletions

View file

@ -83,3 +83,28 @@ test("freeze with huge number of properties doesn't crash", () => {
}
Object.freeze(o);
});
test("freeze with TypedArray", () => {
const TYPED_ARRAYS = [
Uint8Array,
Uint8ClampedArray,
Uint16Array,
Uint32Array,
Int8Array,
Int16Array,
Int32Array,
Float16Array,
Float32Array,
Float64Array,
];
const buffer = new ArrayBuffer(5, { maxByteLength: 10 });
TYPED_ARRAYS.forEach(T => {
const typedArray = new T(buffer, 0, 0);
expect(() => {
Object.freeze(typedArray);
}).toThrowWithMessage(TypeError, "Could not freeze object");
});
});