Default handlers should count as resolvers (#4611)

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2021-02-25 12:27:21 +01:00
committed by GitHub
parent c27047da03
commit 17ed855df5
2 changed files with 17 additions and 25 deletions
@@ -115,18 +115,14 @@ ecma_promise_set_state (ecma_object_t *obj_p, /**< points to promise object */
* Take a collection of Reactions and enqueue a new PromiseReactionJob for each Reaction.
*
* See also: ES2015 25.4.1.8
*
* @return true - if JERRY_PROMISE_CALLBACK define is 1, and at least one handler is found
* false - otherwise
*/
static bool
static void
ecma_promise_trigger_reactions (ecma_collection_t *reactions, /**< lists of reactions */
ecma_value_t value, /**< value for resolve or reject */
bool is_reject) /**< true if promise is rejected, false otherwise */
{
ecma_value_t *buffer_p = reactions->buffer_p;
ecma_value_t *buffer_end_p = buffer_p + reactions->item_count;
bool handler_found = false;
while (buffer_p < buffer_end_p)
{
@@ -137,9 +133,6 @@ ecma_promise_trigger_reactions (ecma_collection_t *reactions, /**< lists of reac
if (JMEM_CP_GET_THIRD_BIT_FROM_POINTER_TAG (object_with_tag))
{
ecma_enqueue_promise_async_reaction_job (object, value, is_reject);
#if JERRY_PROMISE_CALLBACK
handler_found = true;
#endif /* JERRY_PROMISE_CALLBACK */
continue;
}
@@ -150,9 +143,6 @@ ecma_promise_trigger_reactions (ecma_collection_t *reactions, /**< lists of reac
if (JMEM_CP_GET_FIRST_BIT_FROM_POINTER_TAG (object_with_tag))
{
handler = *buffer_p++;
#if JERRY_PROMISE_CALLBACK
handler_found = true;
#endif /* JERRY_PROMISE_CALLBACK */
}
ecma_enqueue_promise_reaction_job (object, handler, value);
@@ -169,9 +159,6 @@ ecma_promise_trigger_reactions (ecma_collection_t *reactions, /**< lists of reac
if (JMEM_CP_GET_SECOND_BIT_FROM_POINTER_TAG (object_with_tag))
{
handler = *buffer_p++;
#if JERRY_PROMISE_CALLBACK
handler_found = true;
#endif /* JERRY_PROMISE_CALLBACK */
}
ecma_enqueue_promise_reaction_job (object, handler, value);
@@ -181,8 +168,6 @@ ecma_promise_trigger_reactions (ecma_collection_t *reactions, /**< lists of reac
buffer_p++;
}
}
return handler_found;
} /* ecma_promise_trigger_reactions */
/**
@@ -246,8 +231,10 @@ ecma_reject_promise (ecma_value_t promise, /**< promise */
ecma_collection_t *reactions = promise_p->reactions;
/* Fulfill reactions will never be triggered. */
ecma_promise_trigger_reactions (reactions, reason, true);
#if JERRY_PROMISE_CALLBACK
if (!ecma_promise_trigger_reactions (reactions, reason, true))
if (reactions->item_count == 0)
{
((ecma_extended_object_t *) obj_p)->u.class_prop.extra_info |= ECMA_PROMISE_UNHANDLED_REJECT;
@@ -260,8 +247,6 @@ ecma_reject_promise (ecma_value_t promise, /**< promise */
JERRY_CONTEXT (promise_callback_user_p));
}
}
#else /* !JERRY_PROMISE_CALLBACK */
ecma_promise_trigger_reactions (reactions, reason, true);
#endif /* JERRY_PROMISE_CALLBACK */
promise_p->reactions = ecma_new_collection ();
@@ -946,8 +931,7 @@ ecma_promise_do_then (ecma_value_t promise, /**< the promise which call 'then' *
ecma_free_value (reason);
#if JERRY_PROMISE_CALLBACK
if (on_rejected != ECMA_VALUE_FALSE
&& ecma_promise_get_flags (promise_obj_p) & ECMA_PROMISE_UNHANDLED_REJECT)
if (ecma_promise_get_flags (promise_obj_p) & ECMA_PROMISE_UNHANDLED_REJECT)
{
promise_p->header.u.class_prop.extra_info &= (uint16_t) ~ECMA_PROMISE_UNHANDLED_REJECT;