1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:37:35 +00:00

LibJS/Bytecode: Check if eval function is a function

When overriding 'eval' to a non-function value, the interpreter would
crash. Now it handles this case swiftly, throwing a TypeError.
This commit is contained in:
Jesús (gsus) Lapastora 2023-11-09 21:53:22 +01:00 committed by Andreas Kling
parent a9ef65e64a
commit 1850652881
2 changed files with 7 additions and 1 deletions

View file

@ -13,3 +13,8 @@ test("variable named 'eval' pointing to real eval works as a direct eval", funct
var eval = globalThis.eval;
expect(eval("testValue")).toEqual("inner");
});
test("variable named 'eval' pointing to a non-function raises a TypeError", function () {
var eval = "borked";
expect(() => eval("something").toThrowWithMessage(TypeError, "borked is not a function"));
});