1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 09:28:11 +00:00

LibJS: Handle Proxy with Array target in IsArray() abstract operation

This was missing from Value::is_array(), which is equivalent to the
spec's IsArray() abstract operation - it treats a Proxy value with an
Array target object as being an Array.
It can throw, so needs both the global object and an exception check
now.
This commit is contained in:
Linus Groh 2021-06-08 21:53:36 +01:00 committed by Andreas Kling
parent 9b35231453
commit 83be39c91a
11 changed files with 52 additions and 24 deletions

View file

@ -22,4 +22,13 @@ test("arguments that evaluate to true", () => {
expect(Array.isArray(new Array(10))).toBeTrue();
expect(Array.isArray(new Array("a", "b", "c"))).toBeTrue();
expect(Array.isArray(Array.prototype)).toBeTrue();
expect(Array.isArray(new Proxy([], {}))).toBeTrue();
});
test("Revoked Proxy as argument throws", () => {
const revocable = Proxy.revocable([], {});
revocable.revoke();
expect(() => {
Array.isArray(revocable.proxy);
}).toThrowWithMessage(TypeError, "An operation was performed on a revoked Proxy object");
});