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

LibJS: Make ObjectPrototype an immutable prototype exotic object

To make this happen, this patch implements the SetImmutablePrototype
abstract operation (as a method on Object) and then overrides
[[SetPrototypeOf]] on ObjectPrototype.
This commit is contained in:
Linus Groh 2021-07-04 23:48:47 +01:00
parent fac8f9a94d
commit cb20baebae
5 changed files with 41 additions and 0 deletions

View file

@ -3,3 +3,10 @@ test("basic functionality", () => {
Object.prototype.foo = 123;
expect(o.foo).toBe(123);
});
test("is an immutable prototype exotic object", () => {
const p = Object.create(null);
expect(() => {
Object.setPrototypeOf(Object.prototype, p);
}).toThrowWithMessage(TypeError, "Object's [[SetPrototypeOf]] method returned false");
});