Fix prototype of the values returned by Promise.allSettled (#4758)

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg 2021-09-03 12:15:06 +02:00 committed by GitHub
parent e1ce7dd727
commit 1523ca3b26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 4 deletions

View File

@ -630,11 +630,13 @@ ecma_promise_all_or_all_settled_handler_cb (ecma_object_t *function_obj_p, /**<
if (promise_type == ECMA_PROMISE_ALLSETTLED_RESOLVE)
{
status_property_val = LIT_MAGIC_STRING_FULFILLED;
status_property_val = LIT_MAGIC_STRING_FULFILLED;
data_propery_name = LIT_MAGIC_STRING_VALUE;
}
ecma_object_t *obj_p = ecma_create_object (NULL, 0, ECMA_OBJECT_TYPE_GENERAL);
ecma_object_t *obj_p = ecma_create_object (ecma_builtin_get (ECMA_BUILTIN_ID_OBJECT_PROTOTYPE),
0,
ECMA_OBJECT_TYPE_GENERAL);
ecma_property_value_t *prop_value_p;
prop_value_p = ecma_create_named_data_property (obj_p,
ecma_get_magic_string (LIT_MAGIC_STRING_STATUS),

View File

@ -76,8 +76,26 @@ var rejects = Promise.allSettled(createIterable([
new Promise((_, reject) => { reject("qux"); }),
]));
fulfills.then(result => { assert (result + "" === "foo,bar"); });
rejects.catch(result => { assert (result === "baz"); });
fulfills.then(result => {
assert(Object.getPrototypeOf(result) === Array.prototype);
assert(result.length === 2)
assert(Object.getPrototypeOf(result[0]) === Object.prototype);
assert(result[0].status === "fulfilled");
assert(result[0].value === "foo");
assert(Object.getPrototypeOf(result[1]) === Object.prototype);
assert(result[1].status === "fulfilled");
assert(result[1].value === "bar");
});
rejects.then(result => {
assert(Object.getPrototypeOf(result) === Array.prototype);
assert(result.length === 2)
assert(Object.getPrototypeOf(result[0]) === Object.prototype);
assert(result[0].status === "rejected");
assert(result[0].reason === "baz");
assert(Object.getPrototypeOf(result[1]) === Object.prototype);
assert(result[1].status === "rejected");
assert(result[1].reason === "qux");
});
var closed = true;
delete Promise.resolve;