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

LibJS: Revert partial resizable ArrayBuffer implementation

This is a manual but clean revert of all commits from #12595.

Adding a partial implementation of the resizable ArrayBuffer proposal
without implementing all the updates to TypedArray infrastructure that
is also covered by the spec introduced a bunch of crashes, so we
decided to revert it for now until a full implementation is completed.
This commit is contained in:
Linus Groh 2022-07-06 14:19:20 +02:00
parent 69a385f559
commit 028a6b90b1
12 changed files with 10 additions and 309 deletions

View file

@ -11,57 +11,3 @@ test("ArrayBuffer constructor must be invoked with 'new'", () => {
ArrayBuffer();
}).toThrowWithMessage(TypeError, "ArrayBuffer constructor must be called with 'new'");
});
describe("resizable array buffer", () => {
test("construct with options", () => {
expect(new ArrayBuffer(5, { maxByteLength: 5 })).toBeInstanceOf(ArrayBuffer);
});
test("resizable when provided max byte length", () => {
expect(new ArrayBuffer(1).resizable).toEqual(false);
expect(new ArrayBuffer(1, {}).resizable).toEqual(false);
expect(new ArrayBuffer(1, { maxByteLength: undefined }).resizable).toEqual(false);
expect(new ArrayBuffer(1, { maxByteLength: 1 }).resizable).toEqual(true);
});
test("byte length must be shorter than max byte length", () => {
expect(() => {
new ArrayBuffer(1, { maxByteLength: 0 });
}).toThrowWithMessage(RangeError, "Byte length exceeds maxByteLength option");
});
test("max byte length cannot be too large", () => {
expect(() => {
new ArrayBuffer(0, { maxByteLength: 9007199254740992 });
}).toThrowWithMessage(RangeError, "Index must be a positive integer");
});
test("max byte length cannot be negative", () => {
expect(() => {
new ArrayBuffer(0, { maxByteLength: -1 });
}).toThrowWithMessage(RangeError, "Index must be a positive integer");
});
test("invalid max byte length object", () => {
expect(() => {
new ArrayBuffer(0, {
maxByteLength: {
toString: function () {
return {};
},
valueOf: function () {
return {};
},
},
});
}).toThrowWithMessage(TypeError, "Cannot convert object to number");
expect(() => {
new ArrayBuffer(0, {
get maxByteLength() {
throw "Exception";
},
});
}).toThrow();
});
});

View file

@ -1,35 +0,0 @@
test("length is 1", () => {
expect(ArrayBuffer.prototype.resize).toHaveLength(1);
});
test("resize up to max", () => {
let a = new ArrayBuffer(0, { maxByteLength: 10 });
a.resize(10);
expect(a.byteLength).toEqual(10);
});
test("resize less than max", () => {
let a = new ArrayBuffer(10, { maxByteLength: 10 });
a.resize(5);
expect(a.byteLength).toEqual(5);
});
test("resize with negative length", () => {
let a = new ArrayBuffer(10, { maxByteLength: 10 });
expect(() => {
a.resize(-1);
}).toThrowWithMessage(
RangeError,
"New byte length outside range supported by ArrayBuffer instance"
);
});
test("resize past max length", () => {
let a = new ArrayBuffer(10, { maxByteLength: 10 });
expect(() => {
a.resize(11);
}).toThrowWithMessage(
RangeError,
"New byte length outside range supported by ArrayBuffer instance"
);
});