mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 10:37:17 +02: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:
Notes:
sideshowbarker
2024-07-17 09:39:20 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/028a6b90b1 Pull-request: https://github.com/SerenityOS/serenity/pull/14500 Reviewed-by: https://github.com/IdanHo ✅
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user