mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
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:
parent
e1ce7dd727
commit
1523ca3b26
@ -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),
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user