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

LibJS: Don't coerce this value to an object in Function.prototype.apply

This commit is contained in:
Luke Wilde 2022-02-10 00:00:27 +00:00 committed by Linus Groh
parent 898ad7c682
commit 12231068bd
2 changed files with 38 additions and 5 deletions

View file

@ -49,3 +49,19 @@ test("basic functionality", () => {
expect((() => this).apply("foo")).toBe(globalThis);
});
describe("errors", () => {
test("does not accept non-function values", () => {
expect(() => {
Function.prototype.apply.call("foo");
}).toThrowWithMessage(TypeError, "foo is not a function");
expect(() => {
Function.prototype.apply.call(undefined);
}).toThrowWithMessage(TypeError, "undefined is not a function");
expect(() => {
Function.prototype.apply.call(null);
}).toThrowWithMessage(TypeError, "null is not a function");
});
});