Correct Object.keys to collect only enumerable property names (#3952)

In case of Proxy objects, there were no property descriptor checks when
collecting enumerable properties. Therefore, all the non-enumerable
Proxy.target properties were listed as well.

JerryScript-DCO-1.0-Signed-off-by: Roland Takacs rtakacs@inf.u-szeged.hu
This commit is contained in:
Roland Takacs
2020-06-30 13:13:18 +02:00
committed by GitHub
parent 89342ea503
commit 034b3b63f5
2 changed files with 49 additions and 2 deletions
+30 -1
View File
@@ -2064,7 +2064,36 @@ ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */
}
else if (!prop_is_symbol && (opts & ECMA_LIST_SYMBOLS_ONLY) == 0)
{
ecma_collection_push_back (return_keys, entry);
if ((opts & ECMA_LIST_ENUMERABLE) == 0)
{
ecma_collection_push_back (return_keys, entry);
}
else
{
ecma_property_descriptor_t prop_desc;
ecma_value_t status = ecma_proxy_object_get_own_property_descriptor (obj_p, prop_name_p, &prop_desc);
if (ECMA_IS_VALUE_ERROR (status))
{
ecma_collection_destroy (proxy_keys);
return NULL;
}
if ((prop_desc.flags & ECMA_PROP_IS_ENUMERABLE) == 0)
{
ecma_deref_ecma_string (prop_name_p);
}
else
{
ecma_collection_push_back (return_keys, entry);
}
if (ecma_is_value_true (status))
{
ecma_free_property_descriptor (&prop_desc);
}
}
}
else
{