diff options
author | Linus Groh <mail@linusgroh.de> | 2021-06-08 21:53:36 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-08 23:53:13 +0200 |
commit | 83be39c91aeff53c5dfd158844e8ad73f10ae9d2 (patch) | |
tree | a7b493153ec3319a886a493a962d6541ae6a4ff9 /Userland/Libraries/LibJS/Runtime/StringConstructor.cpp | |
parent | 9b35231453ddcf939dd10c40787ee7e5ef5b5fe0 (diff) | |
download | serenity-83be39c91aeff53c5dfd158844e8ad73f10ae9d2.zip |
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.
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/StringConstructor.cpp')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/StringConstructor.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp index 30746e16e4..f27a47be6f 100644 --- a/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringConstructor.cpp @@ -72,7 +72,8 @@ JS_DEFINE_NATIVE_FUNCTION(StringConstructor::raw) vm.throw_exception<TypeError>(global_object, ErrorType::StringRawCannotConvert, raw.is_null() ? "null" : "undefined"); return {}; } - if (!raw.is_array()) + // FIXME: This should use length_of_array_like() and work with any object + if (!raw.is_object() || !raw.as_object().is_array()) return js_string(vm, ""); auto* array = static_cast<Array*>(raw.to_object(global_object)); |