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

LibJS: Implement missing conditional when creating a TypedArray subarray

This commit is contained in:
Timothy Flynn 2023-12-27 14:18:06 -05:00 committed by Tim Flynn
parent 522302d5d6
commit f1e01a681e
2 changed files with 19 additions and 1 deletions

View file

@ -57,3 +57,21 @@ test("resizable ArrayBuffer", () => {
expect(typedArray.subarray(0, 1).byteLength).toBe(0);
});
});
test("resizable ArrayBuffer resized during `start` parameter access", () => {
TYPED_ARRAYS.forEach(T => {
let arrayBuffer = new ArrayBuffer(T.BYTES_PER_ELEMENT * 2, {
maxByteLength: T.BYTES_PER_ELEMENT * 4,
});
let badAccessor = {
valueOf: () => {
arrayBuffer.resize(T.BYTES_PER_ELEMENT * 4);
return 0;
},
};
let typedArray = new T(arrayBuffer);
expect(typedArray.subarray(badAccessor, typedArray.length).length).toBe(2);
});
});