From 802722f09a411592c642352f9ee6c9415aafb5d8 Mon Sep 17 00:00:00 2001 From: Edward <14011954+0xedward@users.noreply.github.com> Date: Fri, 16 Feb 2024 02:07:44 -0500 Subject: [PATCH] Add missing TypedArray prototype properties - https://262.ecma-international.org/14.0/#sec-%typedarray%.prototype.at - https://262.ecma-international.org/14.0/#sec-%typedarray%.prototype.findindex - https://262.ecma-international.org/14.0/#sec-%typedarray%.prototype.findlastindex - https://262.ecma-international.org/14.0/#sec-%typedarray%.prototype.toreversed - https://262.ecma-international.org/14.0/#sec-%typedarray%.prototype.tosorted --- Sources/Fuzzilli/Environment/JavaScriptEnvironment.swift | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Sources/Fuzzilli/Environment/JavaScriptEnvironment.swift b/Sources/Fuzzilli/Environment/JavaScriptEnvironment.swift index e8b8c4ee9..b62f2f737 100644 --- a/Sources/Fuzzilli/Environment/JavaScriptEnvironment.swift +++ b/Sources/Fuzzilli/Environment/JavaScriptEnvironment.swift @@ -583,7 +583,7 @@ public extension ILType { /// Type of a JavaScript TypedArray object of the given variant. static func jsTypedArray(_ variant: String) -> ILType { - return .iterable + .object(ofGroup: variant, withProperties: ["buffer", "byteOffset", "byteLength", "length"], withMethods: ["copyWithin", "fill", "find", "findIndex", "reverse", "slice", "sort", "includes", "indexOf", "keys", "entries", "forEach", "filter", "map", "every", "set", "some", "subarray", "reduce", "reduceRight", "join", "lastIndexOf", "values", "toLocaleString", "toString"]) + return .iterable + .object(ofGroup: variant, withProperties: ["buffer", "byteOffset", "byteLength", "length"], withMethods: ["at", "copyWithin", "fill", "find", "findIndex", "findLast", "findLastIndex", "reverse", "slice", "sort", "includes", "indexOf", "keys", "entries", "forEach", "filter", "map", "every", "set", "some", "subarray", "reduce", "reduceRight", "join", "lastIndexOf", "values", "toLocaleString", "toString", "toReversed", "toSorted"]) } /// Type of a JavaScript function. @@ -1034,12 +1034,15 @@ public extension ObjectGroup { "length" : .integer ], methods: [ + "at" : [.integer] => .anything, "copyWithin" : [.integer, .integer, .opt(.integer)] => .undefined, "entries" : [] => .jsArray, "every" : [.function(), .opt(.object())] => .boolean, "fill" : [.anything, .opt(.integer), .opt(.integer)] => .undefined, "find" : [.function(), .opt(.object())] => .anything, "findIndex" : [.function(), .opt(.object())] => .integer, + "findLast" : [.function(), .opt(.object())] => .anything, + "findLastIndex" : [.function(), .opt(.object())] => .integer, "forEach" : [.function(), .opt(.object())] => .undefined, "includes" : [.anything, .opt(.integer)] => .boolean, "indexOf" : [.anything, .opt(.integer)] => .integer, @@ -1058,7 +1061,9 @@ public extension ObjectGroup { "slice" : [.opt(.integer), .opt(.integer)] => .jsTypedArray(variant), "subarray" : [.opt(.integer), .opt(.integer)] => .jsTypedArray(variant), "toString" : [] => .jsString, - "toLocaleString" : [.opt(.string), .opt(.object())] => .jsString + "toLocaleString" : [.opt(.string), .opt(.object())] => .jsString, + "toReversed" : [] => .jsTypedArray(variant), + "toSorted" : [.opt(.function())] => .jsTypedArray(variant), ] ) }