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

LibJS: Add missing cyclic prototype check to Object.setPrototypeOf()

This commit is contained in:
Linus Groh 2021-06-07 22:56:16 +01:00
parent ebb40e7d7b
commit 4e555fae22
2 changed files with 30 additions and 4 deletions

View file

@ -40,4 +40,14 @@ describe("errors", () => {
expect(Object.setPrototypeOf(o, p)).toBe(o);
});
test("cyclic prototype chain", () => {
let o = {};
let p = {};
Object.setPrototypeOf(o, p);
expect(() => {
Object.setPrototypeOf(p, o);
}).toThrowWithMessage(TypeError, "Object's [[SetPrototypeOf]] method returned false");
});
});