1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 03:17:34 +00:00

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

This commit is contained in:
Luke Wilde 2022-02-10 00:00:39 +00:00 committed by Linus Groh
parent 12231068bd
commit 1bfbc0b6af
2 changed files with 29 additions and 4 deletions

View file

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