mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:27:34 +00:00
LibJS: Implement missing conditional when creating a TypedArray subarray
This commit is contained in:
parent
522302d5d6
commit
f1e01a681e
2 changed files with 19 additions and 1 deletions
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue