quickjs-done-nextgen/tests/bug645/2.js
Saúl Ibarra Corretgé e30da0e8bc Don't throw oob exception when setting numeric indexes on TAs
Relevant spec section: https://tc39.es/ecma262/multipage/ordinary-and-exotic-objects-behaviours.html#sec-typedarraysetelement

It should only throw if Object.defineProperty is used and the TA is
detached or OOB if a RAB is used.

Fixes: https://github.com/quickjs-ng/quickjs/issues/645
2024-11-07 19:48:05 +01:00

7 lines
293 B
JavaScript

import { assert, assertThrows } from "../assert.js";
const ab = new ArrayBuffer(16, { maxByteLength: 32 });
const u8 = new Uint8Array(ab, 16);
ab.resize(8);
assert(ab.byteLength, 8);
u8[1] = 123; // Doesn't throw.
assertThrows(TypeError, () => Object.defineProperty(u8, "1", { value: 123 }));